mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2026-01-31 01:21:46 -05:00
Previously, the scheduler unconditionally performed a full runqueue
search:(`find_next_runnable_desc`) on every invocation, including every
timer tick and syscall return. This resulted in unnecessary overhead.
This change introduces a "lazy preemption" model:
1. Fast-Path Optimization: `do_schedule` now checks if the current task
is valid, is not the Idle task, and still has virtual budget remaining.
If these conditions are met and `force_resched` is not set, the
scheduler returns immediately without locking the runqueue.
2. Preemption & Idle Handling:
- `insert_into_runq` now sets `force_resched` if the new task has an
earlier deadline than the current task, or if the current task is
Idle.
- The Idle task is explicitly excluded from the fast-path to ensure
immediate context switching when new work arrives.