Kernel Design

A kernel is a privileged program that implements OS functionality. There are many types of kernels:

1. Monolithic Kernels

Kernel is a single executable binary with its own address space. Syscalls can be carried out simply by putting parameters on the stack and executing a special instruction which diverts control to the kernel. This is the most popular kernel design.

Advantages:

Disadvantages:

2. Microkernels

Kernel is a minimal set of funcionality in user-level servers. Kernel does direct device IO, manipulates memory page tables and allocate memory, interact with interrupt controller to support process scheduling, and provides a communication mechanism between processes called inter-process communication (IPC).

A server is a user-level process that provides a service to other processes. Servers can be added or removed without affecting the kernel. Servers can be restarted without affecting the kernel.

Advantages:

Disadvantages:

3. Hybrid Kernels

Kernel combines features of both monolithic and microkernels. This is often just a design philosophy and not a strict classification.

Advantages:

Disadvantages:

4. Case Study: Linux

UNIX was invented at the same time as the C programming language. UNIX is a simple OS with a standardised API called POSIX. The linux kernel is a derivative of UNIX. It features a monolithic kernel design.

Linux uses syscalls implemented by putting arguments in registers and then calling into the kernel that executes the kernel code. Linux supports a rich set of programs through the GNU project (e.g. bash, compilers, editors, desktop environments, utility programs, etc.).

Interrupt handlers are the primary way to interact with devices. An interrupt handler is typically written in assembly as it is close to the hardware and needs to be efficiently implemented.

Linux supports static in-kernel components and dynamically loadable modules.

5. Case Study: Windows

The windows kernel is called Windows NT. Subsequent versions of Windows are all based on this kernel. NTOS provides syscalls, but the kernel is built around the concept of user-mode dynamic libraries (DLLs). These libraries may be loaded dynamically, allowing large parts of the kernel to implement OS services in a modular fashion. NTOS is loaded from ntoskrnl.exe. It consists of two layers:

Hardware Abstraction Layer (HAL) abstracts out DMA operations, BIOS config and CPU types. Device drivers are loaded into kernel memory. They are dynamically linked against NTOS and HAL layers.

NT is structured like a microkernel, but puts many services in the kernel for performance reasons. It is a hybrid kernel.

In user-mode, the windows kernel can give you many types of API: Win32, POSIX, .NET, etc.

Most of the components run in the same kernel address space which allows for a more efficient implementation.

Back to Home