Skip to content

Commit a14b7bf

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 b7c2a64 commit a14b7bf

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
@@ -499,6 +499,14 @@ static void sched_idle(void)
499499
mo_task_wfi();
500500
}
501501

502+
/* Switch to idle task and return idle task id */
503+
static inline tcb_t *sched_switch_to_idle(void)
504+
{
505+
kcb->task_current = &kcb->task_idle;
506+
tcb_t *idle = kcb->task_idle.data;
507+
idle->state = TASK_RUNNING;
508+
return idle;
509+
}
502510

503511
/* Efficient Round-Robin Task Selection with O(n) Complexity
504512
*

0 commit comments

Comments
 (0)