Skip to main content

check_wake_deadlines

Function check_wake_deadlines 

Source
fn check_wake_deadlines(current_time_ns: u64)
Expand description

Check wake deadlines for all tasks and wake up those whose sleep has expired.

Called from timer_tick() with interrupts disabled. Uses try_lock() to avoid deadlock if called while scheduler lock is held.

§Lock discipline

The BLOCKED_TASKS lock is held only during the scan + re-enqueue phase. The lock is explicitly dropped before sending IPIs (which may acquire per-CPU data) and before any Arc<Task> drop (which reaches KernelStack::drop → free_frames → buddy_alloc.lock()).

To guarantee this, every Arc<Task> removed from blocked_tasks is moved into the deferred_drops array. Those Arcs are dropped after the guard goes out of scope, ensuring free_frames is never called while the scheduler lock is held.