Skip to content

Commit a0c40a0

Browse files
committed
Add De Bruijn LUT for future O(1) priority selection
Prepare for O(1) bitmap index lookup by adding a 32-entry De Bruijn sequence table. The table will be used in later commits to replace iterative bit scanning. No functional change in this patch.
1 parent e31e079 commit a0c40a0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/task.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ void panic(int32_t ecode)
337337
hal_panic();
338338
}
339339

340+
/* RISC-V optimized priority finding using De Bruijn sequence */
341+
static const uint8_t debruijn_lut[32] = {
342+
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
343+
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
344+
340345
/* Weak aliases for context switching functions. */
341346
void dispatch(void);
342347
void yield(void);

0 commit comments

Comments
 (0)