Skip to main content

Components of an Operating System

Components of OS

Components of OS

Operating Systems (OS) are fundamental to how computers operate, acting as an intermediary between hardware and user applications. They are divided into two main parts: User Space and Kernel Space. This guide will explore these components, their functions, and the different types of kernels used in modern OS designs.

User Space​

User space, or user mode, is a restricted execution environment where application programs run. It is isolated from direct access to hardware and critical system resources to protect the integrity of the OS and other running applications.

Most of the software we interact with daily, like Microsoft Word, operates in user space. This separation ensures that user applications cannot directly interfere with the hardware or the core functions of the operating system, providing a layer of security.

For example, if you write a document in Word and want to print it, the request to access the printer (hardware) is made through a system call. This system call acts as a gateway, switching the mode bit to 0 and passing control to the kernel, which has direct access to the hardware.

Kernel Space​

Interaction with hardware

Interaction with hardware

The kernel is the core component of the OS. It has direct access to the system’s hardware.

To illustrate, consider a simple C program that prints "Hello, World!" to the console:

helloworld.c
#include <stdio.h>

int main() {
printf("Hello, World!\n");
return 0;
}

When you run this program, it starts executing in user space. The printf function calls a write system call to request the kernel to interact with the console hardware. The kernel, using the terminal driver, sends data to the console's output buffer. Once the task is completed, control is returned to user space.

Key Functions of the Kernel​

Process Management​

  • Process Scheduling: The kernel decides which process runs at a given time, managing multiple processes efficiently to ensure fair resource distribution and CPU utilization.

  • Context Switching: To support multitasking, the kernel saves the state of a running process and loads the state of the next process to execute.

  • Process Creation and Termination: It handles starting new processes and safely terminating them, including cleanup of resources and updating the process control block (PCB).

  • Inter-Process Communication (IPC): Facilitates data exchange between processes using mechanisms like signals, pipes, shared memory, and message queues.

Memory Management​

  • Memory Allocation and Deallocation: Dynamically allocates memory to processes as needed, managing available memory efficiently.

  • Virtual Memory Management: Extends the physical memory using disk space, allowing more processes to run simultaneously by implementing paging and swapping.

  • Address Space Management: Ensures each process has its own protected memory space, preventing interference from other processes.

File System Management​

  • File Operations: Provides system calls to create, read, write, and delete files.

  • Directory Management: Manages the file system’s directory structure, organizing files in a hierarchical format.

  • File System Mounting: Allows different file systems to be integrated into the OS, providing a unified interface to access different storage devices.

  • Access Control: Enforces permissions to restrict access to files and directories based on user credentials.

Device Management​

  • Device Drivers: Acts as a bridge between the OS and hardware devices, allowing applications to use hardware without needing to know the specifics.

  • I/O Operations: Provides a standardized way to perform input and output operations across various devices.

  • Buffering and Caching: Improves I/O performance by temporarily storing data in memory before writing it to disk or sending it to a device.

Security and Protection​

  • User Authentication: Validates users to ensure that only authorized individuals can access system resources.

  • Access Control: Manages which users or processes can access specific resources, enforcing security policies.

  • Isolation: Ensures that processes do not interfere with each other’s execution or data, maintaining system stability.

Networking​

  • Network Protocols: Supports various communication protocols (e.g., TCP/IP, UDP) to enable network operations.

  • Network Communication: Manages data exchange over network interfaces, facilitating communication between different systems.

Interrupt Handling​

  • Interrupt Management: Handles hardware and software interrupts, allowing the system to respond quickly to critical events.

  • Exception Handling: Deals with errors and exceptions that occur during process execution, ensuring system stability and reliability.

Types of Kernels​

Micro and Monolithic Kernel

Monolithic and Micro Kernel

Monolithic Kernel​

  • Larger Kernel Space: All core OS functions, like process management and memory management, are handled within the kernel space.

  • Faster Performance: Because all components are within the same address space, communication between them is quicker.

  • Complex Management: The large codebase makes it difficult to manage and add new functionalities.

  • System Crash Risk: A failure in one component can cause the entire system to crash.

Microkernel​

  • Smaller Kernel Space: Only essential functions are kept in the kernel space; other services run in user space.

  • Slower Performance: Communication between user space and kernel space adds overhead.

  • Easier Management: With less code in the kernel, it's easier to maintain and extend.

  • Greater Stability: Failure in a user-space component does not bring down the entire system, offering better fault isolation.