mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 18:56:49 +01:00
user_mutex: Adjust semantics of B_USER_MUTEX_UNBLOCK_ALL.
No longer is it required that the mutex be unlocked. This was the case before the recent refactor, though it wasn't noted anywhere. Now it is the case once more. Should fix #18445.
This commit is contained in:
parent
901b48c2e8
commit
ca458a2b55
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user