/* * pthread_barrier hooks */ int reeact_policy_pthread_barrier_init(void *barrier, void *attr, unsigned count) { #ifdef _REEACT_DEFAULT_POLICY_ return real_pthread_barrier_init((pthread_barrier_t*)barrier, (pthread_barrierattr_t*)attr, count); #else // TODO: add user-policy here return 0; #endif }
//Initialize specifying the number of worker threads //If specified less than 1, MYTH_WORKER_NUM or the number of CPU cores used instead. int myth_init_ex_body(int worker_num, size_t def_stack_size) { intptr_t nthreads; myth_init_process_affinity_info(); //Load original functions //myth_get_original_funcs(); //Decide the number of worker threads. //If environment variable is set, use it. Otherwise use the number of CPU cores. char *env; env=getenv(ENV_MYTH_WORKER_NUM); nthreads=(worker_num>0)?worker_num:-1; if (nthreads<=0 && env){nthreads=atoi(env);} if (nthreads<=0){nthreads=myth_get_cpu_num();} g_worker_thread_num=nthreads; //set default stack size size_t s; env=getenv(ENV_MYTH_DEF_STKSIZE); s=def_stack_size; if (s==0 && env){ s=atoi(env); } if (s>0){myth_set_def_stack_size_body(s);} //Initialize logger myth_log_init(); //Initialize memory allocators myth_flmalloc_init(nthreads); myth_malloc_wrapper_init(nthreads); #ifdef MYTH_WRAP_SOCKIO //Initialize I/O myth_io_init(); #endif //Initialize TLS myth_tls_init(nthreads); //Create barrier real_pthread_barrier_init(&g_worker_barrier,NULL,nthreads); //Allocate worker thread descriptors g_envs=myth_malloc(sizeof(myth_running_env)*nthreads); //Initialize TLS for worker thread descriptor myth_env_init(); return nthreads; }