src/hotspot/os/windows/os_windows.cpp
changeset 59252 623722a6aeb9
parent 59251 4cbfa5077d68
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
  2094 
  2094 
  2095 static int check_pending_signals() {
  2095 static int check_pending_signals() {
  2096   while (true) {
  2096   while (true) {
  2097     for (int i = 0; i < NSIG + 1; i++) {
  2097     for (int i = 0; i < NSIG + 1; i++) {
  2098       jint n = pending_signals[i];
  2098       jint n = pending_signals[i];
  2099       if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
  2099       if (n > 0 && n == Atomic::cmpxchg(&pending_signals[i], n, n - 1)) {
  2100         return i;
  2100         return i;
  2101       }
  2101       }
  2102     }
  2102     }
  2103     JavaThread *thread = JavaThread::current();
  2103     JavaThread *thread = JavaThread::current();
  2104 
  2104 
  3749       warning("crit_sect initialization failed in %s: %d\n", __FILE__, __LINE__);
  3749       warning("crit_sect initialization failed in %s: %d\n", __FILE__, __LINE__);
  3750     } else if (Atomic::load_acquire(&process_exiting) == 0) {
  3750     } else if (Atomic::load_acquire(&process_exiting) == 0) {
  3751       if (what != EPT_THREAD) {
  3751       if (what != EPT_THREAD) {
  3752         // Atomically set process_exiting before the critical section
  3752         // Atomically set process_exiting before the critical section
  3753         // to increase the visibility between racing threads.
  3753         // to increase the visibility between racing threads.
  3754         Atomic::cmpxchg(GetCurrentThreadId(), &process_exiting, (DWORD)0);
  3754         Atomic::cmpxchg(&process_exiting, (DWORD)0, GetCurrentThreadId());
  3755       }
  3755       }
  3756       EnterCriticalSection(&crit_sect);
  3756       EnterCriticalSection(&crit_sect);
  3757 
  3757 
  3758       if (what == EPT_THREAD && Atomic::load_acquire(&process_exiting) == 0) {
  3758       if (what == EPT_THREAD && Atomic::load_acquire(&process_exiting) == 0) {
  3759         // Remove from the array those handles of the threads that have completed exiting.
  3759         // Remove from the array those handles of the threads that have completed exiting.
  5134   // Consider: use atomic decrement instead of CAS-loop
  5134   // Consider: use atomic decrement instead of CAS-loop
  5135 
  5135 
  5136   int v;
  5136   int v;
  5137   for (;;) {
  5137   for (;;) {
  5138     v = _Event;
  5138     v = _Event;
  5139     if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
  5139     if (Atomic::cmpxchg(&_Event, v, v-1) == v) break;
  5140   }
  5140   }
  5141   guarantee((v == 0) || (v == 1), "invariant");
  5141   guarantee((v == 0) || (v == 1), "invariant");
  5142   if (v != 0) return OS_OK;
  5142   if (v != 0) return OS_OK;
  5143 
  5143 
  5144   // Do this the hard way by blocking ...
  5144   // Do this the hard way by blocking ...
  5196   // may call park().
  5196   // may call park().
  5197   // Consider: use atomic decrement instead of CAS-loop
  5197   // Consider: use atomic decrement instead of CAS-loop
  5198   int v;
  5198   int v;
  5199   for (;;) {
  5199   for (;;) {
  5200     v = _Event;
  5200     v = _Event;
  5201     if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
  5201     if (Atomic::cmpxchg(&_Event, v, v-1) == v) break;
  5202   }
  5202   }
  5203   guarantee((v == 0) || (v == 1), "invariant");
  5203   guarantee((v == 0) || (v == 1), "invariant");
  5204   if (v != 0) return;
  5204   if (v != 0) return;
  5205 
  5205 
  5206   // Do this the hard way by blocking ...
  5206   // Do this the hard way by blocking ...