Skip to content

Commit c432f0c

Browse files
committed
Add sched_switch_to_idle() helper
When all ready queues are empty, the scheduler should switch to idle mode and wait for incoming interrupts. This commit introduces a dedicated helper to handle that transition, centralizing the logic and improving readbility of the scheduler path to idle.
1 parent 86e7990 commit c432f0c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/task.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,14 @@ static void sched_idle(void)
469469
mo_task_wfi();
470470
}
471471

472+
/* Switch to idle task and return idle task id */
473+
static inline tcb_t *sched_switch_to_idle(void)
474+
{
475+
kcb->task_current = &kcb->task_idle;
476+
tcb_t *idle = kcb->task_idle.data;
477+
idle->state = TASK_RUNNING;
478+
return idle;
479+
}
472480

473481
/* Efficient Round-Robin Task Selection with O(n) Complexity
474482
*

0 commit comments

Comments
 (0)