diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-12 22:53:20 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-13 18:56:46 +0100 |
commit | 65cb40632740b445ca71b7585cca27dae4d05fe3 (patch) | |
tree | f854dbee3e2a04280608694e936dd4da109bd63c /Kernel/Thread.cpp | |
parent | 2a8de4cdec3775b0acf874baca4a0237837c7333 (diff) | |
download | serenity-65cb40632740b445ca71b7585cca27dae4d05fe3.zip |
Kernel: Allow unlocking a held Lock with interrupts disabled
This is needed to eliminate a race in Thread::wait_on() where we'd
otherwise have to wait until after unlocking the process lock before
we can disable interrupts.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 7e63c88ef9..3f050fd3cb 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -174,7 +174,7 @@ void Thread::die_if_needed() if (!m_should_die) return; - m_process.big_lock().unlock_if_locked(); + unlock_process_if_locked(); InterruptDisabler disabler; set_state(Thread::State::Dying); @@ -185,15 +185,15 @@ void Thread::die_if_needed() void Thread::yield_without_holding_big_lock() { - bool did_unlock = process().big_lock().unlock_if_locked(); + bool did_unlock = unlock_process_if_locked(); Scheduler::yield(); if (did_unlock) - process().big_lock().lock(); + relock_process(); } bool Thread::unlock_process_if_locked() { - return process().big_lock().unlock_if_locked(); + return process().big_lock().force_unlock_if_locked(); } void Thread::relock_process() @@ -785,8 +785,8 @@ const LogStream& operator<<(const LogStream& stream, const Thread& value) void Thread::wait_on(WaitQueue& queue, Atomic<bool>* lock, Thread* beneficiary, const char* reason) { - bool did_unlock = unlock_process_if_locked(); cli(); + bool did_unlock = unlock_process_if_locked(); if (lock) *lock = false; set_state(State::Queued); |