diff --git a/src/system/kernel/locks/user_mutex.cpp b/src/system/kernel/locks/user_mutex.cpp index d6fb65b8e7..dad7328d43 100644 --- a/src/system/kernel/locks/user_mutex.cpp +++ b/src/system/kernel/locks/user_mutex.cpp @@ -222,9 +222,14 @@ user_mutex_unblock_locked(int32* mutex, phys_addr_t physicalAddress, uint32 flag } // Someone is waiting: try to hand off the lock to them, if possible. - int32 oldValue = user_atomic_or(mutex, B_USER_MUTEX_LOCKED); - if ((oldValue & B_USER_MUTEX_LOCKED) != 0) - return; + int32 oldValue = 0; + if ((flags & B_USER_MUTEX_UNBLOCK_ALL) == 0) { + oldValue = user_atomic_or(mutex, B_USER_MUTEX_LOCKED); + if ((oldValue & B_USER_MUTEX_LOCKED) != 0) + return; + } else { + oldValue = user_atomic_get(mutex); + } // unblock the first thread entry->locked = true; diff --git a/src/system/libroot/posix/pthread/pthread_barrier.cpp b/src/system/libroot/posix/pthread/pthread_barrier.cpp index 470fa1e6aa..c484165f72 100644 --- a/src/system/libroot/posix/pthread/pthread_barrier.cpp +++ b/src/system/libroot/posix/pthread/pthread_barrier.cpp @@ -97,7 +97,6 @@ pthread_barrier_wait(pthread_barrier_t* barrier) // Wake everyone else up. barrier->waiter_count = (-barrier->waiter_max) + 1; - atomic_and((int32*)&barrier->lock, ~(int32)B_USER_MUTEX_LOCKED); _kern_mutex_unblock((int32*)&barrier->lock, B_USER_MUTEX_UNBLOCK_ALL); // Return with the barrier mutex still locked, as waiter_count < 0.