Skip to main content

wake_task

Function wake_task 

Source
pub fn wake_task(id: TaskId) -> bool
Expand description

Wake a blocked task by its ID.

Moves the task from blocked_tasks to the ready queue and sets its state to Ready. Returns true if the task was found and woken.

§Lock design

The primary path (task found in BLOCKED_TASKS) acquires only the BLOCKED_TASKS lock + the target CPU’s LOCAL_SCHEDULERS[cpu] lock. It does not touch GLOBAL_SCHED_STATE, avoiding contention with cold-path operations (fork, exit, kill).

§Lost-wakeup prevention

If the task is not yet in blocked_tasks (it is still transitioning from Ready -> Blocked inside block_current_task()), this function sets the task’s wake_pending flag so that block_current_task() will see the pending wakeup and return immediately without actually blocking.