DeanoBurrito / northport

Monolithic kernel and support libraries for riscv64 and x86_64.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deadlock in QueueClockEvent

DeanoBurrito opened this issue · comments

commented

QueueClockEvent can be called inside of an interrupt handler (in response to a timer interrupt firing), and if the event is periodic it will be re-queued. If the interrupted code was inside of one of the heap locks we may deadlock. This deadlock is pretty hard to come back, as it would use the smallest slab, which is mostly unused by the rest of the kernel, but still possible.

The line is question is: https://github.com/DeanoBurrito/northport/blob/master/kernel/tasking/Clock.cpp#L91

One possible solution would be to not free the memory when dequeuing the event initially (which is another possible deadlock), and then reuse this memory when re-adding later. This seems fine but is not scalable if we have the issue again in the future, maybe we add some sort of magazine allocator which caches extra entries?

commented

Fixed in cf8d1cb