equal
deleted
inserted
replaced
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 } |