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:
- Boot a kernel and build a repeatable โrun under emulator + debugโ workflow
- Implement physical and virtual memory management (including page faults)
- Handle interrupts and context-switch between tasks
- 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
- Hello, kernel (serial output; reproducible QEMU run)
- Long mode (GDT, paging enabled, basic memory map)
- IDT + interrupts (timer tick + keyboard IRQ)
- Physical memory manager (free lists / bitmap)
- Virtual memory (per-process page tables + page faults)
- User mode (ring transition + syscall entry/exit)
- Scheduler (timer-driven preemption)
- 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)