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:
Augustin Cavalier 2023-06-12 23:27:45 -04:00
parent 901b48c2e8
commit ca458a2b55
2 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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.