Skip to main content

maybe_preempt

Function maybe_preempt 

Source
pub fn maybe_preempt()
Expand description

Called from the timer interrupt handler (or a resched IPI) to potentially preempt the current task.

This is safe to call from interrupt context because:

  1. IF is already cleared by the CPU when entering the interrupt.
  2. We use try_lock() - if the scheduler is already locked (e.g., yield_task() is in progress), we simply skip preemption for this tick.
  3. We honour the PreemptGuard: if preemption is disabled, we return.