mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:05:06 +00:00
Kernel: Add a blunt big process lock.
We can't have multiple threads in the same process running in the kernel at the same time, so let's have a per-process lock that threads have to acquire on syscall entry/exit (and yield while blocked.)
This commit is contained in:
parent
54ea35703a
commit
d5a9f4596b
5 changed files with 37 additions and 0 deletions
|
@ -112,6 +112,7 @@ void Thread::snooze_until(Alarm& alarm)
|
|||
|
||||
void Thread::block(Thread::State new_state)
|
||||
{
|
||||
bool did_unlock = process().big_lock().unlock_if_locked();
|
||||
if (state() != Thread::Running) {
|
||||
kprintf("Thread::block: %s(%u) block(%u/%s) with state=%u/%s\n", process().name().characters(), process().pid(), new_state, to_string(new_state), state(), to_string(state()));
|
||||
}
|
||||
|
@ -120,6 +121,8 @@ void Thread::block(Thread::State new_state)
|
|||
m_was_interrupted_while_blocked = false;
|
||||
set_state(new_state);
|
||||
Scheduler::yield();
|
||||
if (did_unlock)
|
||||
process().big_lock().lock();
|
||||
}
|
||||
|
||||
void Thread::sleep(dword ticks)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue