- cross-posted to:
- osdev
operating-system-in-1000-lines.vercel.app
- cross-posted to:
- osdev
You might get intimidated when you hear OS or kernel development, the basic functions of an OS (especially the kernel) are surprisingly simple. Even Linux, which is often cited as a huge open-source software, was only 8,413 lines in version 0.01. Today’s Linux kernel is overwhelmingly large, but it started with a tiny codebase, just like your hobby project.
We’ll implement basic context switching, paging, user mode, a command-line shell, a disk device driver, and file read/write operations in C. Sounds like a lot, however, it’s only 1,000 lines of code!
[…]
In this book, I chose RISC-V as the target CPU because:
- The specification is simple and suitable for beginners.
- It’s a trending ISA (Instruction Set Architecture) in recent years, along with x86 and Arm.
- The design decisions are well-documented throughout the spec and they are fun to read.
We will write an OS for 32-bit RISC-V. Of course you can write for 64-bit RISC-V with only a few changes. However, the wider bit width makes it slightly more complex, and the longer addresses can be tedious to read.