kernel: simplify KAbstractSchedulerLock::Lock
This commit is contained in:
parent
0746a2084e
commit
62711fec02
|
@ -31,22 +31,23 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsLockedByCurrentThread()) {
|
if (IsLockedByCurrentThread()) {
|
||||||
// If we already own the lock, we can just increment the count.
|
// If we already own the lock, the lock count should be > 0.
|
||||||
|
// For debug, ensure this is true.
|
||||||
ASSERT(lock_count > 0);
|
ASSERT(lock_count > 0);
|
||||||
lock_count++;
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, we want to disable scheduling and acquire the spinlock.
|
// Otherwise, we want to disable scheduling and acquire the spinlock.
|
||||||
SchedulerType::DisableScheduling(kernel);
|
SchedulerType::DisableScheduling(kernel);
|
||||||
spin_lock.Lock();
|
spin_lock.Lock();
|
||||||
|
|
||||||
// For debug, ensure that our state is valid.
|
|
||||||
ASSERT(lock_count == 0);
|
ASSERT(lock_count == 0);
|
||||||
ASSERT(owner_thread == nullptr);
|
ASSERT(owner_thread == nullptr);
|
||||||
|
|
||||||
// Increment count, take ownership.
|
// Take ownership of the lock.
|
||||||
lock_count = 1;
|
|
||||||
owner_thread = GetCurrentThreadPointer(kernel);
|
owner_thread = GetCurrentThreadPointer(kernel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Increment the lock count.
|
||||||
|
lock_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unlock() {
|
void Unlock() {
|
||||||
|
|
Loading…
Reference in a new issue