src/hotspot/share/utilities/waitBarrier_generic.cpp
changeset 59252 623722a6aeb9
parent 59249 29b0d0b61615
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
    46     return 0;
    46     return 0;
    47   }
    47   }
    48   assert(w > 0, "Bad counting");
    48   assert(w > 0, "Bad counting");
    49   // We need an exact count which never goes below zero,
    49   // We need an exact count which never goes below zero,
    50   // otherwise the semaphore may be signalled too many times.
    50   // otherwise the semaphore may be signalled too many times.
    51   if (Atomic::cmpxchg(w - 1, &_waiters, w) == w) {
    51   if (Atomic::cmpxchg(&_waiters, w, w - 1) == w) {
    52     _sem_barrier.signal();
    52     _sem_barrier.signal();
    53     return w - 1;
    53     return w - 1;
    54   }
    54   }
    55   return w;
    55   return w;
    56 }
    56 }