Operating System Development

147 readers
1 users here now

founded 4 years ago
MODERATORS
1
5
Operating system in 1,000 lines (for RISC-V) (operating-system-in-1000-lines.vercel.app)
submitted 3 weeks ago by [email protected] to c/[email protected]
 
 

cross-posted from: https://lemmy.ml/post/24616184

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.

2
 
 

For newly created operating systems, one of the main problems is writing drivers for a variety of devices, and that's why I have this question.

Do you think it's possible to create a transitional layer to run Linux drivers(or from some other os) for your own kernel without porting each one, or is it pointless because it would require recreating almost the entire Linux kernel?

3
4