Build an Operating System from Scratch
It has been over a month ago since I started my internship at Software Quality Solutions. The first thing I got to work on was researching which architecture and language would suit the project I was assigned to best. This research laid the foundation of a decision I would make a couple weeks later.
During my research I had found five common software architectures that were used often in different applications. They were:
- Layered Architecture
- Event-Driven Architecture
- Microkernel Architecture
- Microservices Architecture
- Space-Based Architecture
Each architecture had its pros, cons, and specific usage. I got particularly interested in the microkernel architecture. The way this architecture separated all its components was fascinating for me.
I will try to explain how it works with the help of the image below. But first, let me explain what a kernel is. The kernel is the interpreter between the software and the hardware. For instance, to read this article your browser (software) needs to ask your WiFi (hardware) to go to this website. The browser’s request goes to the kernel first, because it speaks the language of the software and the hardware. Then, it asks the WiFi to go to the website. When it reports back with the website, the kernel translates the data and sends it to the browser so you can read this article.
This is an overly simplified explanation of a kernel but it should give you a small insight on what it does.
In this figure, there are many blocks that may contain words or abbreviations you have never heard of before. Don’t worry, you don’t have to understand everything to understand the principle of the architectures. (I don’t even understand all of this yet!) As you can see, the kernel on the left side has many blue blocks between the two red lines. These blocks are executed in kernel mode. This means that only the kernel can execute them. As the user, you can ask the kernel to do something for us just like you might have asked your dad when you were young to pick something from the top shelf in the toy store. Eventually, you get your toy when dad’s grabbed it. The same works for the kernel. You ask it something and it gives you back what you need. Having all the blue blocks in kernel mode means that everything is controlled by the kernel. That’s why it’s called a monolithic kernel.
The kernel on the right, however, contains only one blue block within the two red lines. It only handles basic communication between components (separate blocks of software), virtual memory (I don’t know what this does, sorry), and scheduling (this has something to do with processes … ). Compared to the monolithic kernel, this kernel only contains the pieces of software that are needed to communicate and to handle processes. All the other software blocks are put in user mode. Hence the name microkernel.
When you’re building software, you might have been told that you need to separate components as much as you can. This is exactly what the microkernel does. It only contains the absolute necessary components to make the software work. The extra features are added like plug-ins.
So, what does the microkernel have to do with all this? Well, let me explain. I have gotten so hyped up, it was intense! You can ask my friend Valentin about it, I couldn’t stop being a huge bouncing ball of microkernel enthusiasm. At one point, on my commute home, I just decided that I was going to build my own operating system. I’d done some research into the subject with the microkernel architecture in mind. It appeared that for an operating system the microkernel was not a good choice. It would slow the whole system down by at least 40 times compared to the current monolithic Linux kernel. Thus, I decided to create my own operating system from scratch. This means writing my own kernel, writing my own everything.
I’ve given myself quite the challenge. How long will this take? I don’t know! Ten years? Fifteen years? Maybe even more! One thing I do know for sure: I’ll be learning a whole lot about computers in the upcoming few years, most of which I’ll be documenting on this blog! Or, at least, I’ll try to.
Can confirm. Bouncy indeed!