1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

Add an InterruptDisabler helper class and use that for kmalloc.

The naive spinlock was not nearly enough to protect kmalloc from
reentrancy problems.

I don't want to deal with coming up with a fancy lock for kmalloc
right now, so I made an InterruptDisabler thingy instead.
It does CLI and then STI iff interrupts were previously enabled.
This commit is contained in:
Andreas Kling 2018-10-24 11:07:53 +02:00
parent 9a296d63f3
commit 0c5bbac86e
4 changed files with 35 additions and 14 deletions

View file

@ -185,7 +185,7 @@ Task* Task::create(const String& path, uid_t uid, gid_t gid)
if (!elfData)
return nullptr;
cli();
InterruptDisabler disabler; // FIXME: Get rid of this, jesus christ. This "critical" section is HUGE.
Task* t = new Task(parts.takeLast(), uid, gid);
ExecSpace space;
@ -218,7 +218,6 @@ Task* Task::create(const String& path, uid_t uid, gid_t gid)
#ifdef TASK_DEBUG
kprintf("Task %u (%s) spawned @ %p\n", t->pid(), t->name().characters(), t->m_tss.eip);
#endif
sti();
return t;
}
@ -461,11 +460,9 @@ void yield()
//kprintf("%s<%u> yield()\n", current->name().characters(), current->pid());
cli();
if (!scheduleNewTask()) {
sti();
InterruptDisabler disabler;
if (!scheduleNewTask())
return;
}
//kprintf("yield() jumping to new task: %x (%s)\n", current->farPtr().selector, current->name().characters());
switchNow();