Nepedia
Back to Discover
Advanced Reader
💻

Kernel (operating system)

technology Maturity 11-13 Next article →

A kernel is the central program at the core of a computer's operating system.

Kernel Layout
Kernel Layout

It maintains complete control over every part of the system. The kernel is always resident in the computer's memory. It acts as a bridge between hardware and software components. Its primary purpose is to facilitate interactions between these different layers. The kernel also prevents and mitigates conflicts between various running processes. Without this central component, a computer could not function effectively.

The kernel manages resources through a specific set of mechanisms. It controls hardware resources like input/output (I/O), memory, and cryptography. It uses device drivers to communicate with hardware components. A device driver is a program that encapsulates and controls a hardware device. It provides an API, or application programming interface, to the operating system. The driver translates abstract function calls from the OS into specific instructions for the hardware. This allows the kernel to manage diverse devices like printers, disk drives, and network adapters.

There are several distinct ways to design a kernel architecture. Monolithic kernels run entirely within a single address space. In this design, the CPU executes in supervisor mode to increase speed.

kernel-simple
kernel-simple

Microkernels take a different approach to design. They run most services in user space, similar to how user processes function. This design focuses on resilience and modularity. A notable example of a microkernel is MINIX 3.

Kernel-microkernel
Kernel-microkernel

Some systems, such as the Linux kernel, are both monolithic and modular. They can insert or remove loadable kernel modules while the system is running.

Kernel-hybrid
Kernel-hybrid

Memory management is a critical task performed within the kernel. The kernel has full access to the system's random-access memory (RAM). It uses virtual addressing to manage how processes access this memory. This is often achieved through techniques called paging or segmentation. Virtual addressing allows the kernel to make a physical address appear as a different virtual address. This creates a layer of indirection that benefits the entire system. Every program can behave as if it is the only one running. This prevents applications from accidentally crashing one another.

To ensure stability, the kernel divides memory into two disjoint areas. One area is reserved for the kernel, known as kernel space. The other area is for applications, known as user space.

Kernel Layout
Kernel Layout

The processor does not permit applications to address kernel memory. This protection prevents malfunctioning applications from affecting the entire operating system. If a program needs data not currently in the RAM, the kernel uses demand paging. The CPU signals the kernel when this happens. The kernel then moves inactive memory blocks to the hard drive to make room for the requested data.

Processes must interact with the kernel through a mechanism called a system call. A system call is how a process requests a service it lacks permission to run. These calls provide the interface between a process and the operating system. When a process makes a system call, it uses a machine-code instruction. This instruction causes the processor to change modes, such as from supervisor mode to protected mode. Most operating systems provide a library, like Glibc or the Windows API, to handle these low-level details. Common system calls include commands like open, read, write, and close.

Kernels also manage the distribution of processing power and communication. The kernel decides which running programs are allocated to the CPU or multiple processors. It also manages inter-process communication (IPC). IPC allows different processes to access facilities provided by other processes. The kernel handles context switching between processes or threads to maintain order. By managing these complex interactions, the kernel ensures that all hardware and software components work together efficiently.

Unix history-simple
Unix history-simple
609 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (5)
File:Kernel Layout.svg
Kernel Layout.svg
File:kernel-simple.svg
kernel-simple.svg
File:Kernel-microkernel.svg
Kernel-microkernel.svg
File:Kernel-hybrid.svg
Kernel-hybrid.svg
File:Unix history-simple.svg
Unix history-simple.svg
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.