mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
Kernel: Disable interrupts while setting up a thread blocker
There was a race window between instantiating a WaitQueueBlocker and setting the thread state to Blocked. If a thread was preempted between those steps, someone else might try to wake the wait queue and find an unblocked thread in a wait queue, which is not sane.
This commit is contained in:
parent
f067730f6b
commit
9ed272ce98
2 changed files with 24 additions and 3 deletions
|
@ -289,6 +289,21 @@ private:
|
|||
u32 m_flags;
|
||||
};
|
||||
|
||||
inline bool cli_and_save_interrupt_flag()
|
||||
{
|
||||
u32 flags = cpu_flags();
|
||||
cli();
|
||||
return flags & 0x200;
|
||||
}
|
||||
|
||||
inline void restore_interrupt_flag(bool flag)
|
||||
{
|
||||
if (flag)
|
||||
sti();
|
||||
else
|
||||
cli();
|
||||
}
|
||||
|
||||
class InterruptDisabler {
|
||||
public:
|
||||
InterruptDisabler()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue