Race conditions while writing a scheduler
Posted: Fri Apr 10, 2026 11:46 am
I am trying to write a scheduler but every time I run it the error changes (it switches between 3-4 different errors) and each small change (printf, moving code, etc.) changes the result completely.
It seems to be race conditions, as adding a delay (e.g. a busy-loop) shifts which error appears.
The errors include:
- General protection faults (always with eip=0x0, suggesting a null/corrupt function pointer)
- Page faults (sometimes at the same address, sometimes complete garbage)
- Divide by zero
- Random serial output and VGA going completely black
The source: git.sr.ht/~zevvi/aoposii, the code is mainly in kernel/scheduler.c
It seems to be race conditions, as adding a delay (e.g. a busy-loop) shifts which error appears.
The errors include:
- General protection faults (always with eip=0x0, suggesting a null/corrupt function pointer)
- Page faults (sometimes at the same address, sometimes complete garbage)
- Divide by zero
- Random serial output and VGA going completely black
The source: git.sr.ht/~zevvi/aoposii, the code is mainly in kernel/scheduler.c