< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page

        

*** 3654,3664 **** static HANDLE handles[MAXIMUM_THREADS_TO_KEEP]; static int handle_count = 0; static INIT_ONCE init_once_crit_sect = INIT_ONCE_STATIC_INIT; static CRITICAL_SECTION crit_sect; ! static volatile int process_exiting = 0; int i, j; DWORD res; HANDLE hproc, hthr; // We only attempt to register threads until a process exiting --- 3654,3664 ---- static HANDLE handles[MAXIMUM_THREADS_TO_KEEP]; static int handle_count = 0; static INIT_ONCE init_once_crit_sect = INIT_ONCE_STATIC_INIT; static CRITICAL_SECTION crit_sect; ! static volatile DWORD process_exiting = 0; int i, j; DWORD res; HANDLE hproc, hthr; // We only attempt to register threads until a process exiting
*** 3673,3683 **** warning("crit_sect initialization failed in %s: %d\n", __FILE__, __LINE__); } else if (OrderAccess::load_acquire(&process_exiting) == 0) { if (what != EPT_THREAD) { // Atomically set process_exiting before the critical section // to increase the visibility between racing threads. ! Atomic::cmpxchg((int)GetCurrentThreadId(), &process_exiting, 0); } EnterCriticalSection(&crit_sect); if (what == EPT_THREAD && OrderAccess::load_acquire(&process_exiting) == 0) { // Remove from the array those handles of the threads that have completed exiting. --- 3673,3683 ---- warning("crit_sect initialization failed in %s: %d\n", __FILE__, __LINE__); } else if (OrderAccess::load_acquire(&process_exiting) == 0) { if (what != EPT_THREAD) { // Atomically set process_exiting before the critical section // to increase the visibility between racing threads. ! Atomic::cmpxchg(GetCurrentThreadId(), &process_exiting, (DWORD)0); } EnterCriticalSection(&crit_sect); if (what == EPT_THREAD && OrderAccess::load_acquire(&process_exiting) == 0) { // Remove from the array those handles of the threads that have completed exiting.
*** 3791,3801 **** LeaveCriticalSection(&crit_sect); } if (!registered && OrderAccess::load_acquire(&process_exiting) != 0 && ! process_exiting != (jint)GetCurrentThreadId()) { // Some other thread is about to call exit(), so we don't let // the current unregistered thread proceed to exit() or _endthreadex() while (true) { SuspendThread(GetCurrentThread()); // Avoid busy-wait loop, if SuspendThread() failed. --- 3791,3801 ---- LeaveCriticalSection(&crit_sect); } if (!registered && OrderAccess::load_acquire(&process_exiting) != 0 && ! process_exiting != GetCurrentThreadId()) { // Some other thread is about to call exit(), so we don't let // the current unregistered thread proceed to exit() or _endthreadex() while (true) { SuspendThread(GetCurrentThread()); // Avoid busy-wait loop, if SuspendThread() failed.
< prev index next >