A Unix-like kernel for RISC-V

Written from scratch in C and RV64 assembly — page tables, preemptive scheduling, a custom filesystem, and VirtIO drivers. Below it is booting under QEMU and running real games in user mode.

rv64 Sv39 paging preemptive multitasking KTFS VirtIO ELF loader fork / exec / wait

What you're looking at

These are real recordings of the kernel running, not mockups. Each one boots from nothing, brings up the subsystems, mounts a filesystem off an emulated disk, loads an ELF binary into a fresh address space, and drops into user mode. The games are unmodified 1970s–80s BSD and Infocom programs compiled for RISC-V; the kernel underneath them is the project.

Subsystems

Memory Sv39 three-level page tables, per-process address spaces, kernel/user separation
Scheduling Preemptive multitasking with timer-driven context switching
Traps Exception and interrupt handling, PLIC-backed external interrupts
Filesystem KTFS, a custom on-disk filesystem, with a write-back block cache
Syscalls fork, exec, wait, and I/O across the user/kernel boundary
Devices VirtIO block and RNG, 16550 UART, RTC, ramdisk, behind a common device abstraction
Loader ELF loader that maps user binaries into fresh address spaces

Run it yourself

Everything above reproduces on any machine with Docker — no RISC-V toolchain needed:

  git clone https://github.com/jkcol/operating-systems-kernel
cd operating-systems-kernel && ./demo/demo.sh

The demo build targets a stock qemu-system-riscv64, which provides a single UART. The kernel was written against a course-patched QEMU that had several, so the demo entry point shares one UART between the kernel console and the user program. Everything else is the unmodified kernel.