Skip to content

Commit 0b002a8

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 9e21688 commit 0b002a8

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
@@ -535,9 +535,7 @@ uint16_t sched_select_next_task(void)
535535
return sched_switch_to_idle()->id;
536536

537537
/* Find top priority ready queue */
538-
int top_prio_level = 0;
539-
for (; !(bitmap & 1U); top_prio_level++, bitmap >>= 1)
540-
;
538+
uint8_t top_prio_level = find_highest_ready_priority(bitmap);
541539

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

0 commit comments

Comments
 (0)