• R
    another cond var fix: requeue count race condition · 3bec53e0
    Rich Felker 提交于
    lock out new waiters during the broadcast. otherwise the wait count
    added to the mutex might be lower than the actual number of waiters
    moved, and wakeups may be lost.
    
    this issue could also be solved by temporarily setting the mutex
    waiter count higher than any possible real count, then relying on the
    kernel to tell us how many waiters were requeued, and updating the
    counts afterwards. however the logic is more complex, and i don't
    really trust the kernel. the solution here is also nice in that it
    replaces some atomic cas loops with simple non-atomic ops under lock.
    3bec53e0
pthread_cond_broadcast.c 929 字节