void threads_test_case(int nthreads, int nyields) { test_thread_param_t* params = calloc(nthreads, sizeof(test_thread_param_t)); int counter = 0; int i; printf("Started test case with %d threads, each yielding %d times.\n", nthreads, nyields); for (i=0;i<nthreads;++i) { params[i].global_counter = &counter; params[i].nthreads = nthreads; params[i].num_yields = nyields; params[i].thread_id = i; } thread_manager_init(sched_init(stFifo)); for (i=0;i<nthreads;++i) { create_thread(&test_thread, ¶ms[i]); // printf("Thread %d created.\n", i); } // printf("Starting threads.\n"); threads_start(); // printf("All threads finished.\n"); }
int main() { thread_manager_init(); thread_startup_report(); /***********/ thread_launch( 4000, test_thread, 5 ); thread_manager_start(); /* control never reaches this point */ }
/** Create the threads that are used in the app. This function must be called before * call to start_threads. * * @param app_data the state of the app * */ static void initialize_threads(app_data_t* app_data) { unsigned i; if (app_data->sched == NULL) { app_data->sched = sched_init(stPrio); } thread_manager_init(app_data->sched); for (i=0;i<app_data->nthreads;++i) { app_data->thread_params[i].global_job_count = &app_data->job_count; app_data->thread_params[i].policy = &app_data->policy; create_thread(worker_thread,&app_data->thread_params[i]); } app_data->initialized = TRUE; }