int pthread_join(pthread_t thread, void **retval){ int tid = -1; int ret; while(tid < 0) tid = get_thread_id(); sim_lib_printf(0, "pthread_join wrapper for %d thread\n", tid); threads_data[tid].joining = 1; /* Calling real pthread_join */ ret = real_pthread_join(thread, retval); threads_data[tid].joining = 0; return ret; }
//Termination void myth_fini_body(void) { //add context switch as a sentinel for emitting logs int i; for (i=0;i<g_worker_thread_num;i++){ myth_log_add_context_switch(&g_envs[i],THREAD_PTR_SCHED_TERM); } myth_startpoint_exit_ex_body(0); myth_running_env_t env; int rank; env=myth_get_current_env(); rank=env->rank; assert(rank==0); //Wait for other worker threads for (i=1;i<g_worker_thread_num;i++){ real_pthread_join(g_envs[i].worker,NULL); } myth_fini_ex_body(); }