1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-29 17:35:06 +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

@ -18,7 +18,7 @@ bool ProcFileSystem::initialize()
{
SyntheticFileSystem::initialize();
addFile(createGeneratedFile("summary", [] {
cli();
InterruptDisabler disabler;
auto tasks = Task::allTasks();
char* buffer;
auto stringImpl = StringImpl::createUninitialized(tasks.size() * 128, buffer);
@ -36,7 +36,6 @@ bool ProcFileSystem::initialize()
}
ptr += ksprintf(ptr, "kmalloc: alloc: %u / free: %u\n", sum_alloc, sum_free);
*ptr = '\0';
sti();
return ByteBuffer::copy((byte*)buffer, ptr - buffer);
}));
return true;