Skip to content

Commit 96d1b23

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 bb5401d commit 96d1b23

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
@@ -524,7 +524,7 @@ uint16_t sched_select_next_task(void)
524524
/* Check out bitmap */
525525
uint32_t bitmap = kcb->ready_bitmap;
526526
if (unlikely(!bitmap))
527-
panic(ERR_NO_TASKS);
527+
return sched_switch_to_idle()->id;
528528

529529
/* Find top priority ready queue */
530530
int top_prio_level = 0;

0 commit comments

Comments
 (0)