mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-26 00:52:50 +00:00
feat(kernel): Add RB-tree/kfifo/hashtable, wait queues, futex, tiny RCU, page cache and KTest harness
Expands the kernel-and-TTY core with the primitives the higher layers have
been missing, plus an in-kernel harness that proves they work.
Data structures (lib/):
- rbtree.c: Linux-compatible red-black tree with parent pointers, full
insert/erase rebalancing, in-order iteration and an invariant validator.
- kfifo.c: power-of-two byte ring with free-running indices, so the wrap
path costs one mask instead of a branch per byte.
- hashtable.c: separately-chained table with FNV-1a hashing, string or
u64 keys, and rehash-on-growth at a 3/4 load factor.
Kernel subsystems:
- kernel/wait.c: wait queues and one-shot completion barriers, backed by a
static sleeper pool so a blocking path never re-enters the allocator.
- kernel/futex.c: 32-bucket futex hash with value re-check, requeue, and an
fmutex_t sleeping mutex built on the uncontended-fastpath protocol.
- kernel/rcu.c: tiny RCU with reader nesting, deferred callbacks, kfree_rcu
and rcu_assign_pointer/rcu_dereference publish barriers.
- mm/page_cache.c: write-back block page cache, 4 KB pages indexed by
(device, page), CLOCK second-chance eviction and dirty write-back.
- kernel/ktest.c: KUnit-style harness with 6 built-in suites, 21 cases and
735 assertions covering every subsystem above (all passing under QEMU).
LazyBox userland:
- coreutils.c: sort, uniq, cut, tr, rev, tac, nl, seq, diff, xxd, du,
factor, sum and truncate, reading through the VFS and handling the
zero-length synthetic nodes that procfs and sysfs expose.
- ktest, rcuinfo, futexinfo, waitinfo and pagecache diagnostics applets.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L5yKJT4Wo2cV3rfPrwY5MP
This commit is contained in:
1 parent
492045b24d
commit
f9400f6ac4
22 files changed
+3631
-5
No files matched your search
@@ -25,7 +25,10 @@ static const char* shell_builtins[] = {
|
||||
"nslookup", "hdparm", "lspci", "speaker", "mouse", "virtinfo",
|
||||
"io_uring_test", "uname", "free", "uptime", "dmesg", "ps", "top",
|
||||
"sleep", "reboot", "poweroff", "clear", "help", "neofetch", "calc",
|
||||
"matrix", "history", "tty", "beep", "shutdown", NULL
|
||||
"matrix", "history", "tty", "beep", "shutdown",
|
||||
"ktest", "rcuinfo", "futexinfo", "waitinfo", "pagecache",
|
||||
"sort", "uniq", "cut", "tr", "rev", "tac", "nl", "seq", "diff",
|
||||
"xxd", "du", "factor", "sum", "truncate", NULL
|
||||
};
|
||||
|
||||
static void history_add(const char* cmd) {
|
||||
@@ -81,7 +84,17 @@ static void cmd_help(void) {
|
||||
printk(" " ANSI_GREEN "dmesg / ps / top" ANSI_RESET " - Kernel boot log & process manager\n");
|
||||
printk(" " ANSI_GREEN "calc [A] [op] [B]" ANSI_RESET " - Arithmetic calculator (+, -, *, /, %%)\n");
|
||||
printk(" " ANSI_GREEN "matrix" ANSI_RESET " - Digital rain screen animation\n");
|
||||
printk(" " ANSI_GREEN "reboot / shutdown" ANSI_RESET " - Power management\n");
|
||||
printk(" " ANSI_GREEN "reboot / shutdown" ANSI_RESET " - Power management\n\n");
|
||||
printk(ANSI_YELLOW " [Kernel Core Diagnostics]\n" ANSI_RESET);
|
||||
printk(" " ANSI_GREEN "ktest [suite]" ANSI_RESET " - Run in-kernel self-test suites (KUnit-style)\n");
|
||||
printk(" " ANSI_GREEN "rcuinfo / futexinfo" ANSI_RESET " - Tiny RCU grace periods & futex buckets\n");
|
||||
printk(" " ANSI_GREEN "waitinfo" ANSI_RESET " - Wait queue sleepers and wakeup counters\n");
|
||||
printk(" " ANSI_GREEN "pagecache [sync]" ANSI_RESET " - Block page cache residency & hit rate\n\n");
|
||||
printk(ANSI_YELLOW " [Text Processing Suite]\n" ANSI_RESET);
|
||||
printk(" " ANSI_GREEN "sort / uniq / nl" ANSI_RESET " - Sort, de-duplicate and number lines\n");
|
||||
printk(" " ANSI_GREEN "cut / tr / rev / tac" ANSI_RESET " - Column, character and order transforms\n");
|
||||
printk(" " ANSI_GREEN "diff / xxd / sum" ANSI_RESET " - Compare, hex-dump and checksum files\n");
|
||||
printk(" " ANSI_GREEN "seq / factor / du" ANSI_RESET " - Number sequences, factoring, disk usage\n");
|
||||
printk(ANSI_BRIGHT_BLACK "Tip: Use TAB for autocomplete, Up/Down for command history.\n" ANSI_RESET);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user