Skip to content

Commit 0b17e13

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 c432f0c commit 0b17e13

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
@@ -330,6 +330,11 @@ void panic(int32_t ecode)
330330
hal_panic();
331331
}
332332

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

0 commit comments

Comments
 (0)