mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 11:45:11 +00:00
Kernel: Fix signal delivery
When delivering urgent signals to the current thread we need to check if we should be unblocked, and if not we need to yield to another process. We also need to make sure that we suppress context switches during Process::exec() so that we don't clobber the registers that it sets up (eip mainly) by a context switch. To be able to do that we add the concept of a critical section, which are similar to Process::m_in_irq but different in that they can be requested at any time. Calls to Scheduler::yield and Scheduler::donate_to will return instantly without triggering a context switch, but the processor will then asynchronously trigger a context switch once the critical section is left.
This commit is contained in:
parent
a308b176ce
commit
e373e5f007
12 changed files with 242 additions and 95 deletions
|
@ -39,13 +39,13 @@ WaitQueue::~WaitQueue()
|
|||
|
||||
void WaitQueue::enqueue(Thread& thread)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ScopedCritical critical;
|
||||
m_threads.append(thread);
|
||||
}
|
||||
|
||||
void WaitQueue::wake_one(Atomic<bool>* lock)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ScopedCritical critical;
|
||||
if (lock)
|
||||
*lock = false;
|
||||
if (m_threads.is_empty())
|
||||
|
@ -57,7 +57,7 @@ void WaitQueue::wake_one(Atomic<bool>* lock)
|
|||
|
||||
void WaitQueue::wake_n(i32 wake_count)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ScopedCritical critical;
|
||||
if (m_threads.is_empty())
|
||||
return;
|
||||
|
||||
|
@ -72,7 +72,7 @@ void WaitQueue::wake_n(i32 wake_count)
|
|||
|
||||
void WaitQueue::wake_all()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ScopedCritical critical;
|
||||
if (m_threads.is_empty())
|
||||
return;
|
||||
while (!m_threads.is_empty())
|
||||
|
@ -82,7 +82,7 @@ void WaitQueue::wake_all()
|
|||
|
||||
void WaitQueue::clear()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
ScopedCritical critical;
|
||||
m_threads.clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue