mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:57:45 +00:00
Kernel: Clean up around Scheduler::yield() a bit.
Also add assertion in Lock that the scheduler isn't currently active. I've been seeing occasional fuckups that I suspect might be someone called by the scheduler trying to take a busy lock.
This commit is contained in:
parent
27263b6172
commit
8cc6e304ca
4 changed files with 23 additions and 28 deletions
|
@ -3,7 +3,7 @@
|
|||
#include "Assertions.h"
|
||||
#include "Types.h"
|
||||
#include "i386.h"
|
||||
int sched_yield();
|
||||
#include <Kernel/Scheduler.h>
|
||||
|
||||
class Process;
|
||||
extern Process* current;
|
||||
|
@ -52,6 +52,7 @@ private:
|
|||
|
||||
inline void Lock::lock()
|
||||
{
|
||||
ASSERT(!Scheduler::is_active());
|
||||
for (;;) {
|
||||
if (CAS(&m_lock, 1, 0) == 0) {
|
||||
if (!m_holder || m_holder == current) {
|
||||
|
@ -63,7 +64,7 @@ inline void Lock::lock()
|
|||
}
|
||||
m_lock = 0;
|
||||
}
|
||||
sched_yield();
|
||||
Scheduler::yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +85,7 @@ inline void Lock::unlock()
|
|||
m_lock = 0;
|
||||
return;
|
||||
}
|
||||
sched_yield();
|
||||
Scheduler::yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue