Operating System in 1,000 Lines – Intro
A new online book shows how to build a tiny, non‑Unix‑like operating system for RISC‑V in about 1,000 lines of C, sparking interest as an approachable way to learn core OS concepts like paging, context switching, user mode, and simple file I/O. Commenters explore how easily it could be adapted to real RISC‑V hardware, ported to RV64 or other languages such as Rust or Zig, and compared with teaching kernels like xv6 and MINIX. There is also practical advice on tooling (QEMU, GDB, virtio, record‑and‑replay) and packaging the material as an ebook, alongside broader reflections on experimenting with alternative OS designs instead of yet another Unix clone.
Hardware targets & RISC‑V details
- Several comments discuss whether the 32-bit RISC‑V OS can run on real hardware.
- Current mainstream RISC‑V SoCs with MMUs are mostly 64-bit; 32-bit RISC‑V with MMU is uncommon outside FPGA/embedded contexts.
- Porting from RV32 to RV64 (or vice versa) is seen as straightforward: main change is page-table layout (sv32 two-level vs sv39/sv48 multi-level).
- Allwinner D1 and Raspberry Pi / Pico boards are suggested as potential targets after some porting.
QEMU, virtio, and debugging
- Virtio is highlighted as a useful abstraction for virtual devices; it’s not QEMU‑only and is also used by other hypervisors.
- Some prefer QEMU for convenience, others mention using KVM directly for a leaner setup.
- Strong recommendations to wire up GDB early via QEMU’s built‑in GDB server.
- Additional QEMU features praised: record/replay, monitor commands for MMU/virtual memory debugging, and detailed logging flags. Reverse debugging is noted as currently unreliable.
- Multiarch GDB builds reduce the need for per‑architecture clients.
Alternative guides, languages, and OS designs
- Other educational OS resources are mentioned: a Rust OS tutorial, MIT’s RISC‑V xv6 course, JOS/x86 materials, and a Nim‑based kernel.
- One line of discussion argues there are already many hobby Unix‑like C kernels and calls for more experimentation: new languages (Rust, Zig, Hare, Ada, Nim, etc.) and non‑Unix designs (e.g., Plan 9–style).
- Others respond that writing “yet another Unix‑like in C” is still a valid and concrete learning goal, and that unusual designs only appear when someone is motivated to build them.
Feedback on the 1,000‑line OS book itself
- Many express enthusiasm: concise, approachable, good for undergrads and weekend projects.
- Typos and phrasing issues in the English text are noted; the author confirms partial machine translation and invites PRs.
- Readers request an ebook version; others show how to generate an EPUB from the Markdown and share a preliminary build.
- The OS is intentionally not Unix‑like and is presented as a conceptual “toy” that readers can adapt to other architectures or languages.