Skip to content

Commit 3474f1a

Browse files
committed
Add sched_switch_to_idle() helper in the scheduler
Previously, when all ready queues were empty, the scheduler would trigger a kernel panic. This condition should instead transition into the idle task rather than panic. The new sched_switch_to_idle() helper centralizes this logic, making the path to idle clearer and more readable.
1 parent ec07239 commit 3474f1a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ uint16_t sched_select_next_task(void)
520520
/* Check out bitmap */
521521
uint32_t bitmap = kcb->harts->ready_bitmap;
522522
if (unlikely(!bitmap))
523-
panic(ERR_NO_TASKS);
523+
return sched_switch_to_idle()->id;
524524

525525
/* Find top priority ready queue */
526526
int top_prio_level = 0;

0 commit comments

Comments
 (0)