• R
    simplify and improve new cond var implementation · 2c4b510b
    Rich Felker 提交于
    previously, wake order could be unpredictable: if a waiter happened to
    leave its futex wait on the state early, e.g. due to EAGAIN while
    restarting after a signal handler, it could acquire the mutex out of
    turn. handling this required ugly O(n) list walking in the unwait
    function and accounting to remove waiters that already woke from the
    list.
    
    with the new changes, the "barrier" locks in each waiter node are only
    unlocked in turn. in addition to simplifying the code, this seems to
    improve performance slightly, probably by reducing the number of
    accesses threads make to each other's stacks.
    
    as an additional benefit, unrecoverable mutex re-locking errors
    (mainly ENOTRECOVERABLE for robust mutexes) no longer need to be
    handled with deadlock; they can be reported to the caller, since the
    unlocking sequence makes it unnecessary to rely on the mutex to
    synchronize access to the waiter list.
    2c4b510b
pthread_cond_timedwait.c 5.4 KB