User:Lionel/What kind of kernel should I make?

From OSDev Wiki
Jump to navigation Jump to search

This page is under construction! This page or section is a work in progress and may thus be incomplete. Its content may be changed in the near future.

This is a personal choice. Some kernels may have advantages that others don't, but they also have disadvantages. You can start out with an already made kernel, and develop from there. Or you can create your own completely different kind of kernel that is 100% yours. It's your choice. There is no wrong way to develop a kernel, unless, of course it causes too many problems. But if you want to know what common parts make a kernel "sane" then keep on reading.

Common Parts

A kernel needs to have some basic parts, even if they are stubs that call something else. Feel free to add anything that you think most kernels need.

Interrupt handling

Main article: Interrupts

This is a must, because any kernel needs to handle requests and notifications for the hardware. If the CPU doesn't support some type of signaling system, your best bet is polling.

Input/Output (I/O)

Main article: I/O Ports

You need I/O to communicate, how else do you control the HDD, tell the user what your doing or get input from the user?

Surprisingly, on some systems, you can communicate via memory spaces. For example: 0xB8000 is a memory space where you write characters while in 80x25 text mode..

Common Types of Kernels

Note: These are sorted by difficulty.

Megalithic

Difficulty level
Difficulty 1.png
Beginner
Main article: Megalithic Kernel

A Megalithic kernel is probably the easiest because everything is in the kernel binary, which means that there is no task switching. There is also no user mode. This is probably the kind of kernel you should make if you are developing on a embedded system.

Monolithic

Difficulty level
Difficulty 1.png
Beginner
Main article: Monolithic Kernel

Similar to a megalithic kernel; a Monolithic kernel is basically a big unchanging binary, and if there is any change, the kernel needs to be replaced again. It however has a user space. This design is fast, but can be unstable if not written correctly, as any bug can break the kernel easily. It would work well on a embedded system, but modern Monolithic Kernels, such as Linux, run on PC's as well. This is the second easiest, and is the one most people start out on, as components can be changed to create different types. Linux is a prime example of this, but most kernels will fall into this category.

Micro

Difficulty level
Difficulty 2.png
Medium
Main article: Microkernel

A Microkernel tries to export all functionality into user-space. It is generally very stable; if a server or daemon crashes, it can be restarted by the kernel or init/watchdog. The main thing you want to be fast here is the Inter-Process Communication, as processes will need to be switched between quickly. This isn't the fastest, but probably is best when stability is required. This type of kernel is recommended for servers.

Hybrid

Difficulty level
Difficulty 2.png
Medium
Main article: Hybrid Kernel

Its two best friends, Monolithic and Micro have rubbed off on it and it acts like both. It is alone sometimes, but is happy to share with user-space. This system works quite well, as you don't have to change between modes for any privileged instruction, while code that doesn't need kernel privileges won't bring it down. However, discerning needs to be done, making it more difficult. Windows NT (XP+) and XNU(OSX) use this design.

Alien

Difficulty level
Difficulty 4.png
Master
Main article: @*%*(@&%(@#

This is the essentially the "default" case in a switch function. An alien kernel is no different than any other one. It's just a funny name. An alien kernel is a kernel that has no "mold" to fit in. Something completely different.