kernel: Make sure mutex::holder is set to a valid value
This commit is contained in:
@@ -775,6 +775,9 @@ _mutex_unlock(mutex* lock)
|
|||||||
lock->waiters = waiter->next;
|
lock->waiters = waiter->next;
|
||||||
if (lock->waiters != NULL)
|
if (lock->waiters != NULL)
|
||||||
lock->waiters->last = waiter->last;
|
lock->waiters->last = waiter->last;
|
||||||
|
#if KDEBUG
|
||||||
|
thread_id unblockedThread = waiter->thread->id;
|
||||||
|
#endif
|
||||||
|
|
||||||
// unblock thread
|
// unblock thread
|
||||||
thread_unblock(waiter->thread, B_OK);
|
thread_unblock(waiter->thread, B_OK);
|
||||||
@@ -784,7 +787,7 @@ _mutex_unlock(mutex* lock)
|
|||||||
// actually reflects the current situation, setting it to -1 would
|
// actually reflects the current situation, setting it to -1 would
|
||||||
// cause a race condition, since another locker could think the lock
|
// cause a race condition, since another locker could think the lock
|
||||||
// is not held by anyone.
|
// is not held by anyone.
|
||||||
lock->holder = waiter->thread->id;
|
lock->holder = unblockedThread;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// We've acquired the spinlock before the locker that is going to wait.
|
// We've acquired the spinlock before the locker that is going to wait.
|
||||||
|
|||||||
Reference in New Issue
Block a user