Project 26: Operating System Kernel Capstone

Project 26: Operating System Kernel Capstone

Build a minimal x86-64 kernel that boots in QEMU, enables paging, handles interrupts, and runs simple user processes.

Quick Reference

Attribute Value
Difficulty Master+
Time Estimate 3-6 months
Language C + x86-64 Assembly (Alternatives: Rust)
Prerequisites Deep comfort with debugging, memory, processes, and toolchains
Key Topics Boot, GDT/IDT, paging, interrupts, syscalls, scheduling, basic FS
Reference Books CS:APP + Operating Systems: Three Easy Pieces

1. Learning Objectives

By completing this project, you will:

  1. Boot a kernel and build a repeatable โ€œrun under emulator + debugโ€ workflow
  2. Implement physical and virtual memory management (including page faults)
  3. Handle interrupts and context-switch between tasks
  4. Design a minimal syscall boundary and run user-mode code safely

2. Project Specification

2.1 Minimal Feature Set

  • Boot to 64-bit long mode and print to console/serial
  • Basic physical frame allocator
  • 4-level paging with a kernel mapping and per-process address spaces
  • Timer + keyboard interrupts
  • Preemptive scheduler (round-robin is fine)
  • Syscalls: write, exit, fork (optional), exec (optional)
  • Simple file system (start read-only)

3. Milestone Plan

  1. Hello, kernel (serial output; reproducible QEMU run)
  2. Long mode (GDT, paging enabled, basic memory map)
  3. IDT + interrupts (timer tick + keyboard IRQ)
  4. Physical memory manager (free lists / bitmap)
  5. Virtual memory (per-process page tables + page faults)
  6. User mode (ring transition + syscall entry/exit)
  7. Scheduler (timer-driven preemption)
  8. FS + shell (minimal commands)

4. Testing Strategy

  • Run everything in QEMU with a GDB stub and scripted tests.
  • Add โ€œboot smoke testsโ€ that assert specific serial output.
  • Use fault injection: invalid syscalls, page faults, out-of-memory conditions.

5. Extensions

  • Write a small libc for your user space.
  • Add networking (virtio-net) and a tiny TCP stack.
  • Add a real file system (FAT-like or a tiny custom one).

6. References

  • Operating Systems: Three Easy Pieces (free online)
  • OSDev Wiki
  • MIT xv6 (for inspiration, not copy/paste)