Skip to content
  • Jonas Termansen's avatar
    Fix deadlocks and lost wakeups in threading primitives. · 3154492d
    Jonas Termansen authored
    The futex and kutex implementations used the same linked list for waiting,
    however the futex implementation used kutexs and the same thread could be in
    the same list twice in the case of contention. This case corrupted the wait
    lists and led to deadlocks and lost wakeups. This change fixes the problem
    by having separate data structures for futexes and kutexes.
    
    Mutexes contended by multiple threads could lead to lost wakeups since only
    one contended thread was awoken and subsequent unlocks are unaware of the
    unawakened contended threads. This change fixes the problem with a temporary
    solution of waking all the contended threads until a better design is
    implemented.
    
    Additional details are tweaked to be more reliable and simpler.
    3154492d