Skip to main content

suspend_task

Function suspend_task 

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

Suspend a task by ID (best-effort).

Moves the task to the blocked map and marks it Blocked.

  • If the task is the current task on this CPU, a context switch is performed immediately.
  • If the task is the current task on another CPU, an IPI is sent to trigger preemption on that CPU. The task will not be re-queued at the next tick because its state is Blocked.

§Lock order

Canonical: BLOCKED (rank 3) → LOCAL (rank 4). First path (current task): re-acquires LOCAL only for yield_cpu_local, after BLOCKED has been released. Ready-queue path: acquires LOCAL to remove, releases it, then acquires BLOCKED to insert — this is safe because LOCAL is fully released before BLOCKED is acquired (no nesting).