Skip to content

Commit 37e6946

Browse files
committed
Use De Brujin-based top priority helper in scheduler
Replace the iterative bitmap scanning with the De Bruijn multiply+LUT method via the new helper. This change makes top-priority selection constant-time and deterministic.
1 parent 22f7ded commit 37e6946

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

kernel/task.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,7 @@ uint16_t sched_select_next_task(void)
527527
return sched_switch_to_idle()->id;
528528

529529
/* Find top priority ready queue */
530-
int top_prio_level = 0;
531-
for (; !(bitmap & 1U); top_prio_level++, bitmap >>= 1)
532-
;
530+
uint8_t top_prio_level = find_highest_ready_priority(bitmap);
533531

534532
list_node_t **cursor = &kcb->rr_cursors[top_prio_level];
535533
list_t *rq = kcb->ready_queues[top_prio_level];

0 commit comments

Comments
 (0)