void chpl_task_init(void) { chpl_thread_mutexInit(&threading_lock); chpl_thread_mutexInit(&extra_task_lock); chpl_thread_mutexInit(&task_id_lock); chpl_thread_mutexInit(&task_list_lock); queued_task_cnt = 0; running_task_cnt = 1; // only main task running blocked_thread_cnt = 0; idle_thread_cnt = 0; extra_task_cnt = 0; task_pool_head = task_pool_tail = NULL; chpl_thread_init(thread_begin, thread_end); // // Set main thread private data, so that things that require access // to it, like chpl_task_getID() and chpl_task_setSerial(), can be // called early (notably during standard module initialization). // // This needs to be done after the threading layer initialization, // because it's based on thread layer capabilities, but before we // install the signal handlers, because when those are invoked they // may use the thread private data. // setup_main_thread_private_data(); if (blockreport) { progress_cnt = 0; chpl_thread_mutexInit(&block_report_lock); } if (blockreport || taskreport) { signal(SIGINT, SIGINT_handler); } initialized = true; }
void chpl_task_init(void) { chpl_thread_mutexInit(&threading_lock); chpl_thread_mutexInit(&extra_task_lock); chpl_thread_mutexInit(&task_id_lock); chpl_thread_mutexInit(&task_list_lock); queued_task_cnt = 0; running_task_cnt = 1; // only main task running blocked_thread_cnt = 0; idle_thread_cnt = 0; extra_task_cnt = 0; task_pool_head = task_pool_tail = NULL; chpl_thread_init(thread_begin, thread_end); // // Set main thread private data, so that things that require access // to it, like chpl_task_getID() and chpl_task_setSerial(), can be // called early (notably during standard module initialization). // // This needs to be done after the threading layer initialization, // because it's based on thread layer capabilities, but before we // install the signal handlers, because when those are invoked they // may use the thread private data. // { thread_private_data_t* tp; tp = (thread_private_data_t*) chpl_mem_alloc(sizeof(thread_private_data_t), CHPL_RT_MD_THREAD_PRV_DATA, 0, 0); tp->ptask = (task_pool_p) chpl_mem_alloc(sizeof(task_pool_t), CHPL_RT_MD_TASK_POOL_DESC, 0, 0); tp->ptask->id = get_next_task_id(); tp->ptask->fun = NULL; tp->ptask->arg = NULL; tp->ptask->is_executeOn = false; tp->ptask->filename = CHPL_FILE_IDX_MAIN_PROGRAM; tp->ptask->lineno = 0; tp->ptask->p_list_head = NULL; tp->ptask->next = NULL; tp->lockRprt = NULL; // Set up task-private data for locale (architectural) support. tp->ptask->chpl_data.prvdata.serial_state = true; // Set to false in chpl_task_callMain(). chpl_thread_setPrivateData(tp); } if (blockreport) { progress_cnt = 0; chpl_thread_mutexInit(&block_report_lock); initializeLockReportForThread(); } if (blockreport || taskreport) { signal(SIGINT, SIGINT_handler); } initialized = true; }