Summary
ready_queue_push updates the scheduler ready queues without a guaranteed atomic/scheduler-protected context on every caller path. In particular, proc_execute can enqueue a newly created process while interrupts are still enabled.
A timer interrupt can enter proc_switch while the ready queue list is mid-update, allowing the scheduler to traverse partially linked nodes and corrupt the queue.
Current Notes
Tracked locally in scheduler_issues.md as "Ready Queue Updates Are Not Atomic".
Relevant code:
src/kernel/proc/proc.c: ready_queue_push
src/kernel/proc/proc.c: proc_execute enqueue path
src/kernel/proc/proc.c: proc_mark_ready guarded path for comparison
Expected Behavior
All ready queue mutations should happen under one clear scheduler invariant: either interrupts are disabled around the mutation, or a scheduler/runqueue lock protects the list consistently.
Proposed Fix
Mirror the guarded path used by proc_mark_ready, or introduce a scheduler/runqueue lock and route all ready queue insertion/removal through that contract.
Dependencies
Blocks
Related Issues
Validation
- Add or update scheduler tests/stress coverage for process creation and ready queue transitions where practical.
- Boot smoke test with repeated fork/exec/wait workloads.
- Confirm
make test still passes.
Summary
ready_queue_pushupdates the scheduler ready queues without a guaranteed atomic/scheduler-protected context on every caller path. In particular,proc_executecan enqueue a newly created process while interrupts are still enabled.A timer interrupt can enter
proc_switchwhile the ready queue list is mid-update, allowing the scheduler to traverse partially linked nodes and corrupt the queue.Current Notes
Tracked locally in
scheduler_issues.mdas "Ready Queue Updates Are Not Atomic".Relevant code:
src/kernel/proc/proc.c:ready_queue_pushsrc/kernel/proc/proc.c:proc_executeenqueue pathsrc/kernel/proc/proc.c:proc_mark_readyguarded path for comparisonExpected Behavior
All ready queue mutations should happen under one clear scheduler invariant: either interrupts are disabled around the mutation, or a scheduler/runqueue lock protects the list consistently.
Proposed Fix
Mirror the guarded path used by
proc_mark_ready, or introduce a scheduler/runqueue lock and route all ready queue insertion/removal through that contract.Dependencies
Blocks
Related Issues
Validation
make teststill passes.