Skip to content

Commit 589b0e7

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 05ebd38 commit 589b0e7

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
@@ -540,9 +540,7 @@ uint16_t sched_select_next_task(void)
540540
return sched_switch_to_idle()->id;
541541

542542
/* Find top priority ready queue */
543-
int top_prio_level = 0;
544-
for (; !(bitmap & 1U); top_prio_level++, bitmap >>= 1)
545-
;
543+
uint8_t top_prio_level = find_highest_ready_priority(bitmap);
546544

547545
list_node_t **cursor = &kcb->harts->rr_cursors[top_prio_level];
548546
list_t *rq = kcb->harts->ready_queues[top_prio_level];

0 commit comments

Comments
 (0)