Skip to main content
Engineering LibreTexts

06-A.1: Examine the Linux Kernel

  • Page ID
    32665
  • Module Objectives

    The learning objectives for this module are as follows:

    • Identify and describe the purpose of the subsystems of the Linux kernel
    • Recognize the proper use of the commands for kernel module management
    • Explain the commands used for kernel module configuration
    • Describe where to find kernel information
    • Inspect dmesg output for troubleshooting and error resolution

    The Kernel

    The main purpose of a computer is to run a predefined sequence of instructions, known as a program. A program under execution is often referred to as a process. Now, most special purpose computers are meant to run a single process, but in a sophisticated system such as a general purpose computer, they are intended to run many processes simultaneously. Any kind of process requires hardware resources such as Memory, Processor time, Storage space, etc.

    In a general purpose computer running many processes simultaneously, we need a middle layer to manage the distribution of the hardware resources of the computer efficiently and fairly among all the various processes running on the computer. This middle layer is referred to as the kernel. Basically the kernel virtualizes the common hardware resources of the computer to provide each process with its own virtual resources. This makes the process seem as if it is the sole process running on the machine. The kernel is also responsible for preventing and mitigating conflicts between different processes.

    Kernel Space vs User Space

    Memory is divided into 2 spaces, known as kernel space and user space, sometimes referred to as kernel and user mode.The kernel executes in the memory area referred to as kernel space, where it executes the various services that it provides. Whereas user space is that portion of memory where everything that doesn't operate in kernel mode runs.

    Software running in user space has access to a certain portion of the memory that is allocated at the time the process is created. The kernel has access to all of memory. If a process starts up running in user space, it can access a small portion of kernel space via a set of system calls. The kernel developers provided these system calls that can be used by software developers to allow user space applications to access things like open/closing/reading/writing a file.

    System memory was divided in this manner to ensure that user processes could not access kernel space. This promotes stability and system security.

    Kernel Types

    A monolithic kernel, like other kernels, manages system resources between application and hardware, but user services (NOT user space - see below) and kernel services are implemented under same address space. It increases the size of the kernel, thus increasing the size of the operating system as well. This kernel provides CPU scheduling, memory management, file management and other operating system functions through system calls. As both services are implemented under same address space, this makes operating system execution faster.

    In a microkernel the user services and kernel services are implemented in different address space. The user services are kept in user address space, and kernel services are kept under kernel address space; thus also reducing the size of kernel and the size of operating system as well.

    Monolithic kernel all the services are implemented in the same memory space. Microkernel separates certain services and runs some of them in user space and some of them in kernel space
    Figure \(\PageIndex{1}\): Kernel Services. ("Structure of monolithic and microkernel-based operating systems, respectively" by Multiple contributors, Wikipedia is licensed under CC BY-SA 3.0)

    Kernel services and user services

    Notice in the image on the left, the monolithic kernel has all of the services inside the kernel itself. In the micro kernel some of those services, referred to as user services, have been taken out of the kernel, thereby shrinking the size of the kernel. These user services now reside in the user space memory.

    Device Drivers

    The term device driver refers to a specific type of software application which controls a specific hardware device. The device driver enables different hardware devices, printers, disk drives, and network interfaces to communicate with the computer’s operating system.

    Device drivers basically act as an interface between Linux and the hardware devices. This allows application software to access the hardware device easily and without having to interface directly with the hardware.

    Adapted from:
    "The Linux Kernel" by Arna Maity, Geeks for Geeks is licensed under CC BY-SA 4.0
    "Monolithic Kernel and key differences from Microkernel" by akash1295, Geeks for Geeks is licensed under CC BY-SA 4.0
    "Microkernel" by Multiple ContributorsWikipedia is licensed under CC BY-SA 3.0
    "Device Driver and It’s Purpose" by Satyabrata_Jena, Geeks for Geeks is licensed under CC BY-SA 4.0

    • Was this article helpful?