Skip to main content

boot_sched_task_index

Function boot_sched_task_index 

Source
pub fn boot_sched_task_index(
    sched_tasks: &[SchedTaskSpec<'_>],
    direction: PriorityDirection,
) -> usize
Expand description

Index of the sched task the BOOT task should run: the least urgent one.

The boot task owns the session and spins forever, so it must not outrank the sched tasks it spawned. See the module docs for what happened when it did.

  • Ties keep the earliest index, so a table whose sched tasks all declare the same priority (or none) behaves exactly as sched_tasks[0] did.
  • An undeclared priority is least urgent, but only where 0 is out of range. On bigger-wins kernels the valid range starts at 1 and 0 is the “inherit” sentinel every board already tests for, so a sched task that declared nothing makes no claim and is the safest owner. On smaller-wins kernels 0 is a REAL priority — a very urgent one on ThreadX — and treating it as a sentinel would hand the session to the most urgent sched task, which is the bug this function exists to prevent.