Lines Matching refs:th

389   kmp_info_t *th = __kmp_threads[gtid];  in __kmp_terminate_thread()  local
391 if (!th) in __kmp_terminate_thread()
396 status = pthread_cancel(th->th.th_info.ds.ds_thread); in __kmp_terminate_thread()
409 static kmp_int32 __kmp_set_stack_info(int gtid, kmp_info_t *th) { in __kmp_set_stack_info() argument
445 TCW_PTR(th->th.th_info.ds.ds_stackbase, (((char *)addr) + size)); in __kmp_set_stack_info()
446 TCW_PTR(th->th.th_info.ds.ds_stacksize, size); in __kmp_set_stack_info()
447 TCW_4(th->th.th_info.ds.ds_stackgrow, FALSE); in __kmp_set_stack_info()
453 TCW_PTR(th->th.th_info.ds.ds_stacksize, 0); in __kmp_set_stack_info()
454 TCW_PTR(th->th.th_info.ds.ds_stackbase, &stack_data); in __kmp_set_stack_info()
455 TCW_4(th->th.th_info.ds.ds_stackgrow, TRUE); in __kmp_set_stack_info()
471 gtid = ((kmp_info_t *)thr)->th.th_info.ds.ds_gtid; in __kmp_launch_worker()
478 __kmp_stats_thread_ptr = ((kmp_info_t *)thr)->th.th_stats; in __kmp_launch_worker()
564 __kmp_set_stack_info(((kmp_info_t *)thr)->th.th_info.ds.ds_gtid, in __kmp_launch_monitor()
711 void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) { in __kmp_create_worker() argument
716 th->th.th_info.ds.ds_gtid = gtid; in __kmp_create_worker()
727 th->th.th_stats = __kmp_stats_list->push_back(gtid); in __kmp_create_worker()
731 th->th.th_stats = __kmp_stats_thread_ptr; in __kmp_create_worker()
739 th->th.th_info.ds.ds_thread = pthread_self(); in __kmp_create_worker()
740 __kmp_set_stack_info(gtid, th); in __kmp_create_worker()
741 __kmp_check_stack_overlap(th); in __kmp_create_worker()
803 pthread_create(&handle, &thread_attr, __kmp_launch_worker, (void *)th); in __kmp_create_worker()
822 th->th.th_info.ds.ds_thread = handle; in __kmp_create_worker()
843 void __kmp_create_monitor(kmp_info_t *th) { in __kmp_create_monitor() argument
854 th->th.th_info.ds.ds_tid = 0; // this makes reap_monitor no-op in __kmp_create_monitor()
855 th->th.th_info.ds.ds_gtid = 0; in __kmp_create_monitor()
862 th->th.th_info.ds.ds_tid = KMP_GTID_MONITOR; in __kmp_create_monitor()
863 th->th.th_info.ds.ds_gtid = KMP_GTID_MONITOR; in __kmp_create_monitor()
927 pthread_create(&handle, &thread_attr, __kmp_launch_monitor, (void *)th); in __kmp_create_monitor()
953 th->th.th_info.ds.ds_thread = handle; in __kmp_create_monitor()
978 th->th.th_info.ds.ds_thread)); in __kmp_create_monitor()
990 void __kmp_reap_monitor(kmp_info_t *th) { in __kmp_reap_monitor() argument
996 th->th.th_info.ds.ds_thread)); in __kmp_reap_monitor()
1001 KMP_DEBUG_ASSERT(th->th.th_info.ds.ds_tid == th->th.th_info.ds.ds_gtid); in __kmp_reap_monitor()
1002 if (th->th.th_info.ds.ds_gtid != KMP_GTID_MONITOR) { in __kmp_reap_monitor()
1013 status = pthread_kill(th->th.th_info.ds.ds_thread, 0); in __kmp_reap_monitor()
1018 status = pthread_join(th->th.th_info.ds.ds_thread, &exit_val); in __kmp_reap_monitor()
1019 if (exit_val != th) { in __kmp_reap_monitor()
1023 th->th.th_info.ds.ds_tid = KMP_GTID_DNE; in __kmp_reap_monitor()
1024 th->th.th_info.ds.ds_gtid = KMP_GTID_DNE; in __kmp_reap_monitor()
1028 th->th.th_info.ds.ds_thread)); in __kmp_reap_monitor()
1034 void __kmp_reap_worker(kmp_info_t *th) { in __kmp_reap_worker() argument
1041 10, ("__kmp_reap_worker: try to reap T#%d\n", th->th.th_info.ds.ds_gtid)); in __kmp_reap_worker()
1043 status = pthread_join(th->th.th_info.ds.ds_thread, &exit_val); in __kmp_reap_worker()
1049 if (exit_val != th) { in __kmp_reap_worker()
1052 th->th.th_info.ds.ds_gtid, exit_val)); in __kmp_reap_worker()
1059 th->th.th_info.ds.ds_gtid)); in __kmp_reap_worker()
1336 void __kmp_suspend_initialize_thread(kmp_info_t *th) { in __kmp_suspend_initialize_thread() argument
1337 int old_value = KMP_ATOMIC_LD_RLX(&th->th.th_suspend_init_count); in __kmp_suspend_initialize_thread()
1344 &th->th.th_suspend_init_count, old_value, -1)) { in __kmp_suspend_initialize_thread()
1345 while (KMP_ATOMIC_LD_ACQ(&th->th.th_suspend_init_count) != new_value) { in __kmp_suspend_initialize_thread()
1351 status = pthread_cond_init(&th->th.th_suspend_cv.c_cond, in __kmp_suspend_initialize_thread()
1354 status = pthread_mutex_init(&th->th.th_suspend_mx.m_mutex, in __kmp_suspend_initialize_thread()
1357 KMP_ATOMIC_ST_REL(&th->th.th_suspend_init_count, new_value); in __kmp_suspend_initialize_thread()
1361 void __kmp_suspend_uninitialize_thread(kmp_info_t *th) { in __kmp_suspend_uninitialize_thread() argument
1362 if (KMP_ATOMIC_LD_ACQ(&th->th.th_suspend_init_count) > __kmp_fork_count) { in __kmp_suspend_uninitialize_thread()
1367 status = pthread_cond_destroy(&th->th.th_suspend_cv.c_cond); in __kmp_suspend_uninitialize_thread()
1371 status = pthread_mutex_destroy(&th->th.th_suspend_mx.m_mutex); in __kmp_suspend_uninitialize_thread()
1375 --th->th.th_suspend_init_count; in __kmp_suspend_uninitialize_thread()
1376 KMP_DEBUG_ASSERT(KMP_ATOMIC_LD_RLX(&th->th.th_suspend_init_count) == in __kmp_suspend_uninitialize_thread()
1382 int __kmp_try_suspend_mx(kmp_info_t *th) { in __kmp_try_suspend_mx() argument
1383 return (pthread_mutex_trylock(&th->th.th_suspend_mx.m_mutex) == 0); in __kmp_try_suspend_mx()
1386 void __kmp_lock_suspend_mx(kmp_info_t *th) { in __kmp_lock_suspend_mx() argument
1387 int status = pthread_mutex_lock(&th->th.th_suspend_mx.m_mutex); in __kmp_lock_suspend_mx()
1391 void __kmp_unlock_suspend_mx(kmp_info_t *th) { in __kmp_unlock_suspend_mx() argument
1392 int status = pthread_mutex_unlock(&th->th.th_suspend_mx.m_mutex); in __kmp_unlock_suspend_mx()
1401 kmp_info_t *th = __kmp_threads[th_gtid]; in __kmp_suspend_template() local
1408 __kmp_suspend_initialize_thread(th); in __kmp_suspend_template()
1410 __kmp_lock_suspend_mx(th); in __kmp_suspend_template()
1418 TCW_PTR(th->th.th_sleep_loc, (void *)flag); in __kmp_suspend_template()
1419 th->th.th_sleep_loc_type = flag->get_type(); in __kmp_suspend_template()
1423 TCW_PTR(th->th.th_sleep_loc, NULL); in __kmp_suspend_template()
1424 th->th.th_sleep_loc_type = flag_unset; in __kmp_suspend_template()
1425 __kmp_unlock_suspend_mx(th); in __kmp_suspend_template()
1434 TCW_PTR(th->th.th_sleep_loc, NULL); in __kmp_suspend_template()
1435 th->th.th_sleep_loc_type = flag_unset; in __kmp_suspend_template()
1449 __kmp_print_cond(buffer, &th->th.th_suspend_cv); in __kmp_suspend_template()
1456 th->th.th_active = FALSE; in __kmp_suspend_template()
1457 if (th->th.th_active_in_pool) { in __kmp_suspend_template()
1458 th->th.th_active_in_pool = FALSE; in __kmp_suspend_template()
1465 KMP_DEBUG_ASSERT(th->th.th_sleep_loc); in __kmp_suspend_template()
1466 KMP_DEBUG_ASSERT(flag->get_type() == th->th.th_sleep_loc_type); in __kmp_suspend_template()
1484 status = pthread_cond_timedwait(&th->th.th_suspend_cv.c_cond, in __kmp_suspend_template()
1485 &th->th.th_suspend_mx.m_mutex, &now); in __kmp_suspend_template()
1490 status = pthread_cond_wait(&th->th.th_suspend_cv.c_cond, in __kmp_suspend_template()
1491 &th->th.th_suspend_mx.m_mutex); in __kmp_suspend_template()
1506 TCW_PTR(th->th.th_sleep_loc, NULL); in __kmp_suspend_template()
1507 th->th.th_sleep_loc_type = flag_unset; in __kmp_suspend_template()
1518 TCW_PTR(th->th.th_sleep_loc, NULL); in __kmp_suspend_template()
1519 th->th.th_sleep_loc_type = flag_unset; in __kmp_suspend_template()
1530 th->th.th_active = TRUE; in __kmp_suspend_template()
1531 if (TCR_4(th->th.th_in_pool)) { in __kmp_suspend_template()
1533 th->th.th_active_in_pool = TRUE; in __kmp_suspend_template()
1539 TCW_PTR(th->th.th_sleep_loc, NULL); in __kmp_suspend_template()
1540 th->th.th_sleep_loc_type = flag_unset; in __kmp_suspend_template()
1543 KMP_DEBUG_ASSERT(!th->th.th_sleep_loc); in __kmp_suspend_template()
1547 __kmp_print_cond(buffer, &th->th.th_suspend_cv); in __kmp_suspend_template()
1553 __kmp_unlock_suspend_mx(th); in __kmp_suspend_template()
1587 kmp_info_t *th = __kmp_threads[target_gtid]; in __kmp_resume_template() local
1598 __kmp_suspend_initialize_thread(th); in __kmp_resume_template()
1600 __kmp_lock_suspend_mx(th); in __kmp_resume_template()
1602 if (!flag || flag != th->th.th_sleep_loc) { in __kmp_resume_template()
1605 flag = (C *)CCAST(void *, th->th.th_sleep_loc); in __kmp_resume_template()
1614 __kmp_unlock_suspend_mx(th); in __kmp_resume_template()
1616 } else if (flag->get_type() != th->th.th_sleep_loc_type) { in __kmp_resume_template()
1624 th->th.th_sleep_loc_type)); in __kmp_resume_template()
1625 __kmp_unlock_suspend_mx(th); in __kmp_resume_template()
1626 __kmp_null_resume_wrapper(th); in __kmp_resume_template()
1634 __kmp_unlock_suspend_mx(th); in __kmp_resume_template()
1640 TCW_PTR(th->th.th_sleep_loc, NULL); in __kmp_resume_template()
1641 th->th.th_sleep_loc_type = flag_unset; in __kmp_resume_template()
1650 __kmp_print_cond(buffer, &th->th.th_suspend_cv); in __kmp_resume_template()
1655 status = pthread_cond_signal(&th->th.th_suspend_cv.c_cond); in __kmp_resume_template()
1657 __kmp_unlock_suspend_mx(th); in __kmp_resume_template()