Skip to content

Bug: ready queue updates are not atomic #425

Description

@pbalduino

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkernelKernel-level implementation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions