Writing an operating system kernel from scratch – RISC-V/OpenSBI/Zig
17 hours ago
- #Operating-Systems
- #Zig
- #RISC-V
- Implementation of a minimal time-sharing OS kernel on RISC-V using Zig.
- Target audience includes students and enthusiasts of low-level system software.
- Utilizes modern tooling and RISC-V architecture for educational purposes.
- Kernel features include static thread definition, user mode threads, and time slicing.
- Threads are implemented as never-ending functions with their own stacks.
- Uses OpenSBI for console printing and timer hardware management.
- Demonstrates context switching via timer interrupts and system calls.
- Kernel and user space code are bundled into a single binary for simplicity.
- Includes basic I/O drivers for console output via SBI or direct UART MMIO.
- Example user threads print messages with thread IDs in a loop.
- Debug mode available for detailed interrupt and scheduling logs.
- Deployed on QEMU virtual machine with OpenSBI firmware.