This is an old version, saved 5 Dec 2026, 01:58 by TechWritereditor. See the current version.

Kernel (operating system)

The kernel is the core code of an Operating system: the lowest layer of software, which supplies the basic services that every other program depends on.[1] It acts as the main go-between for a computer's hardware and the processes running on it, deciding how the machine's resources are shared out.[2]

Contents
  1. What it does
  2. Kernel mode and user mode
  3. System calls
  4. Designs
  5. Loadable modules and drivers
  6. Notable kernels
  7. See also
  8. References

What it does

The kernel has several standing duties. It keeps track of which parts of memory are in use and what they hold, decides which processes may use the central processing unit (CPU), when and for how long, and passes messages between programs and hardware through device drivers.[2] Course notes from the University of Alaska Fairbanks add interrupt handling and the implementation of system calls to this list for a typical kernel.[1]

Because a running program cannot be relied on to hand back the processor of its own accord, the kernel sets up a hardware timer when the machine starts. Each time the timer fires, control returns to the kernel, which can then pause the current process, save its state and switch to another one.[5]

Kernel mode and user mode

Processors offer at least two privilege levels. In kernel mode (also called supervisor mode) code can use every feature of the processor, while user mode is limited to certain memory areas and operations.[1] The kernel runs in kernel mode; ordinary applications run in user mode and cannot drive hardware directly.[1][5] Instructions reserved for kernel mode include setting up memory address mapping, changing the processor's mode, halting or resetting the processor, and carrying out input and output.[3]

On Microsoft Windows, each user-mode application gets its own private virtual address space (Virtual memory), so one program cannot alter another's data and a crashing application does not bring down the rest of the system. All kernel-mode code, by contrast, shares a single address space, so a faulty kernel-mode driver can corrupt operating-system data, and if it crashes, the whole system crashes with it.[4]

System calls

Programs ask the kernel for services through system calls, such as opening files, creating processes or allocating memory.[5][2] A small library routine places the call's number and arguments in processor registers and executes a special "trap" instruction. This jumps into the kernel and raises the privilege level; once the work is done, a return-from-trap instruction lowers it again and resumes the program.[3][5] The kernel records where its handlers live in a trap table that it sets up while starting.[5] Princeton lecture notes put the number of system calls at about 45 in Sixth Edition Unix and about 250 in Linux, a figure they describe as fewer than most systems.[3]

Designs

  • Monolithic kernels keep almost all non-application code inside the kernel at high privilege, built as one large program. Sharing one space gives good performance, but makes the system harder to maintain and less robust. Linux, BSD Unix and Windows have been given as examples.[1][3]
  • Layered designs split the system into levels, each hiding its details from the one above. Princeton's notes cite MS-DOS as a four-layer example.[3]
  • Microkernels keep the kernel very small, usually handling only memory, scheduling and communication between processes. Other services, including device drivers, run as ordinary processes that the kernel contacts by message. This improves flexibility and isolates faults, but frequent crossings between modes have historically cost performance.[1][3]
  • Hybrid kernels draw the boundary between kernel and user code somewhere between these two extremes. The kernels of the various Windows systems and Apple's XNU are often placed in this group, though sources do not all classify them the same way.[1][3]

Loadable modules and drivers

Many kernels can be extended while running. In Red Hat Enterprise Linux, only a minimal resident kernel is loaded at start-up, and extra features, often device drivers, are loaded as modules when needed; tools such as lsmod, modprobe and rmmod list, load and remove them.[6] Apple's kernel offers a similar mechanism called kernel extensions (KEXTs), which load code into kernel space without recompiling the kernel and are used for device drivers.[7] Windows lets many drivers run in kernel mode, though some can run in user mode.[4]

Notable kernels

  • Mach was a research project at Carnegie Mellon University, begun in 1985, and is a well-known microkernel. Parts of it later went into commercial operating systems, and further work passed to the Open Software Foundation.[8][1]
  • Linux was begun in early 1991 by Linus Torvalds, a student in Helsinki, who announced it in August 1991 to users of the Minix system, calling it "just a hobby". It switched to the GNU General Public Licence in early 1992 and is now also the basis of Android.[9][1]
  • XNU, the kernel of macOS (formerly OS X) and Darwin, is derived from Mach.[1] Apple describes it as combining Mach, which handles CPU use, memory, scheduling and messaging, with a BSD layer, largely drawn from FreeBSD, that supplies file systems, networking and the Unix security model, plus the I/O Kit driver framework.[7]

See also

References

  1. ^ CS 321 Spring 2013: Lecture Notes for Monday, January 28, 2013 (OS structure). University of Alaska Fairbanks. 2013-01-28. cs.uaf.edu
  2. ^ What is the Linux kernel?. Red Hat. redhat.com
  3. ^ COS 318: Operating Systems — OS Structures and System Calls. Princeton University. cs.princeton.edu
  4. ^ User mode and kernel mode. Microsoft Learn. learn.microsoft.com
  5. ^ Mechanism: Limited Direct Execution (OSTEP educator slides). University of Wisconsin–Madison. pages.cs.wisc.edu
  6. ^ Kernel Modules (Red Hat Enterprise Linux 4 System Administration Guide). Red Hat. docs.redhat.com
  7. ^ Kernel Architecture Overview (Kernel Programming Guide). Apple Developer. developer.apple.com
  8. ^ Mach Project Overview. Carnegie Mellon University. cs.cmu.edu
  9. ^ Linux at 25: Why It Flourished While Others Fizzled. IEEE Spectrum. 2016. spectrum.ieee.org