Skip to content

Commit 9518c6f

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 d9b619d commit 9518c6f

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
@@ -477,6 +477,14 @@ static void sched_idle(void)
477477
mo_task_wfi();
478478
}
479479

480+
/* Switch to idle task and return idle task id */
481+
static inline tcb_t *sched_switch_to_idle(void)
482+
{
483+
kcb->task_current = kcb->harts->task_idle;
484+
tcb_t *idle = kcb->harts->task_idle->data;
485+
idle->state = TASK_RUNNING;
486+
return idle;
487+
}
480488

481489
/* Efficient Round-Robin Task Selection (Cursor-Based, O(1) Complexity)
482490
*

0 commit comments

Comments
 (0)