1. Home
  2. Explore
  3. Computer Science
  4. Operating System Components

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Operating System Components

Operating-System Structure: User Space, the Kernel, and Kernel Types

An operating system (OS) provides a way for applications and people to use a computer’s hardware. It also organizes the work that the computer performs. A useful way to understand this organization is to divide the OS into two broad areas: user space and kernel space.

The two areas have different responsibilities. User space is where applications and user-facing tools run. Kernel space contains the kernel, which manages important system operations and communicates directly with hardware. This separation lets people use a computer without needing to control its hardware themselves.

User Space: Where Applications and User Interfaces Run

User space is the area in which user applications and user-facing programs operate. It provides a convenient environment for people to use applications and for developers to run them. User-space programs do not directly control the hardware; when a task requires hardware access, they ask the kernel to perform it.

People commonly interact with user space through either a graphical user interface (GUI) or a command-line interface (CLI).

A GUI presents visual elements such as a desktop, icons, menus, and buttons. A person can, for example, create a folder by choosing a “new folder” option. A CLI instead accepts commands that a person types. The same folder-creation task can be performed in a Linux terminal with the mkdir command.

The two interfaces can offer different ways to request the same underlying operation. A GUI button is not a separate kind of file-management capability: it provides a convenient way to request an operation that can also be requested with a command. In the example, the folder-creation request is handled by the system’s file-management functionality.

A shell is a program that provides a command-line environment. It receives commands, such as a request to run a script, and arranges for them to be carried out. In Windows, PowerShell is a command-line environment; terminals are also used in systems such as macOS and Linux.

User space is where applications and user-facing tools run. It can request system operations, but the kernel is responsible for tasks that require direct hardware access.

A small example: running a script

Suppose a person runs a shell script that prints “Hello, world.” The command is entered through the CLI, which is part of the user-facing environment. The request requires processing, so the operating system arranges for the CPU to perform the necessary work. The result is then shown through the user-facing environment.

The example illustrates a general pattern: a user-space program requests work, the kernel coordinates the system-level operations needed to carry it out, and the outcome becomes available to the user.

Think About It

How can creating a folder through a graphical button and creating one with a command be two different user experiences for the same kind of operation?

The Kernel: The OS’s Core

The kernel is the core of the operating system. It has access to the hardware and manages operations that user-space programs cannot carry out directly. In this sense, the kernel acts as an intermediary: a program makes a request, and the kernel coordinates the work required from the hardware.

A simplified view of the relationship is:

User space → kernel → hardware

The kernel is responsible for several major areas of system management:

  • Process management
  • Memory management
  • File management
  • Input/output (I/O) management

These responsibilities are connected. A running process may need CPU time, memory, access to a file, or communication with a device. The kernel coordinates those needs.

Process management

A process is a running program. Process management includes creating and terminating processes, as well as deciding when processes should run.

When several processes need CPU time, the system must schedule their execution. Scheduling determines which process runs and when. A scheduling approach may consider priority and system utilization while aiming to avoid starvation, a situation in which a process waits indefinitely because other processes keep receiving the resources it needs.

The kernel also handles context switching: changing the CPU’s work from one process to another. This allows multiple processes to make progress over time. Process management also includes coordinating processes that need to work together, including synchronizing their activities and enabling communication.

Memory management

Programs need memory while they run. Memory management tracks how memory is allocated to processes and how it is released when it is no longer needed.

For example, if a process finishes or no longer needs a portion of memory, that space can become available for another process. The operating system must keep track of which areas are in use and which are free so that new work can be assigned space appropriately.

File and directory management

The kernel also supports managing files and directories. File management includes creating and deleting files, while directory management organizes them so that they can be located and managed.

A common organization is hierarchical: directories contain files and may also contain other directories. This forms a tree-like structure. A directory at the top is called the root directory; lower directories branch from it. For instance, the root may contain a directory named Lakshay, which contains another directory named OS and a file named lakshay.txt.

The hierarchy gives files an organized location. To find a file, a person or program can follow the path through the relevant directories, much as someone follows branches through a tree.

Input/output management

Input/output management covers communication with devices and the operations they perform. Examples include connecting a USB drive or a game controller. The kernel detects and manages devices so that the system can make them available to applications and users.

For example, after a pen drive is connected, the operating system can recognize that a device has been added and provide a way to access it through the user interface. The kernel handles device-related operations; user space can then present the device in a form a person can use.

Three I/O techniques introduced here are spooling, buffering, and caching:

  • Spooling places work in a holding area so that a device can process it at its own pace. A printer is a useful example: several print jobs can be submitted quickly and held in a queue while the printer completes them more slowly.
  • Buffering temporarily holds data associated with a job or process so it is available when needed. The material gives video playback as an example of using buffering.
  • Caching is identified as another I/O-related technique. Its detailed operation is not developed here.

These techniques help the operating system coordinate data and devices that may work at different speeds or at different times.

Think About It

If a printer receives several jobs faster than it can print them, why is it helpful for the system to hold the jobs rather than require each one to be printed immediately?

User Mode, Kernel Mode, and Interrupts

The OS distinguishes between user mode and kernel mode. User mode is the restricted mode in which ordinary user-space programs operate. Kernel mode allows the kernel to perform privileged system operations, including operations involving hardware.

This separation helps limit what applications can do directly. An application can request an operation, but the kernel handles the privileged work. When the request is complete, control can return to the application.

A request to create a directory illustrates the transition. A person enters a command such as mkdir in the CLI. The system interprets the command as a request to create a directory. Because creating and managing files is a kernel responsibility, the request is handled by the relevant file-management functionality. When the operation finishes, the system can return a result to the user-facing environment.

A change in execution mode can be triggered by an interrupt. An interrupt signals that the system needs to respond to an event or request. The material distinguishes between two broad kinds:

  • A software interrupt is generated by software to request or signal system work. It can be used in the transition between user-mode work and kernel-mode work.
  • A hardware interrupt is generated by hardware to notify the system of an event or problem. For example, a hardware component may signal that something requires the operating system’s attention.

The important idea is that user programs do not simply take over hardware operations. They make requests, and the operating system transfers control to the kernel when privileged work is required.

How Processes Communicate

Processes are generally treated as separate units of execution. They may have separate resources and may not be able to access each other’s data directly. Yet some tasks require processes to exchange information. Interprocess communication (IPC) is the set of methods used to support that exchange.

Two IPC methods introduced here are shared memory and message passing.

Shared memory

With shared memory, processes use a shared area of memory to exchange information. One process writes data into the shared area, and another process reads it. For example, one process might place the value 123 there for another process to retrieve.

This approach uses a common memory area as a meeting place for the data. Both processes can communicate through that area instead of keeping the information entirely separate.

Message passing

With message passing, processes exchange information through messages sent using an OS-provided mechanism. The operating system provides functions—often called system calls—that programs can use to request such services. A communication channel, described in the source as a pipe, can carry messages between processes.

The central difference is that shared memory lets processes exchange information through a common memory region, while message passing uses messages sent through an operating-system-supported channel. Both methods support communication, and different situations may use different methods.

Think About It

In shared memory, one process writes data where another can read it. In message passing, the processes exchange messages through a channel. What changes about where the information is placed and how it reaches the other process?

Three Kernel Designs

Kernel designs differ in how much functionality they keep inside the kernel and how much they place in user space. That design choice affects communication overhead, size, reliability, and performance.

Monolithic kernel

A monolithic kernel places the major operating-system functions inside the kernel. In the model described here, process, memory, file, and I/O management all reside in kernel space.

This arrangement can make communication among kernel components efficient because those components are located together. It can also support high performance. However, the kernel becomes larger and more tightly interconnected. If one component fails, the failure may affect other components, making the system less reliable.

Examples identified with this design include Linux, Unix, and MS-DOS.

Microkernel

A microkernel keeps core functions in the kernel and moves other functions into user space. In the arrangement described here, process management and memory management remain in the kernel, while file and I/O management are placed in user space.

This can make the kernel smaller. Separating some services from the kernel can also improve stability: a failure in a user-space service need not necessarily cause the kernel itself to fail.

The tradeoff is that work may require more transitions between user mode and kernel mode. For example, a task may need process management, memory allocation, I/O, and file management. If those services are split across the two spaces, the system may have to switch between them several times. Each switch has a cost, creating overhead and potentially reducing performance.

Examples given for microkernels include L4 Linux, Symbian OS, and MINIX.

Hybrid kernel

A hybrid kernel combines aspects of monolithic and microkernel designs. The arrangement described here keeps process, memory, and I/O management in the kernel while placing file management in user space.

The purpose of this combination is to balance the approaches. Keeping more functionality together in the kernel than in the microkernel example can reduce some of the repeated switching overhead, while separating part of the system can retain some modularity and stability benefits.

Examples identified with the hybrid approach include macOS and Windows NT, including later Windows versions such as Windows 7 and Windows 10.

DesignOrganization described hereMain tradeoff
MonolithicMajor functions are inside the kernelEfficient communication and high performance, but the kernel is larger and failures may have wider effects
MicrokernelCore functions stay in the kernel; other services are in user spaceSmaller and potentially more stable, but more mode switching can reduce performance
HybridFunctions are divided between kernel and user spaceCombines aspects of both designs to balance performance and modularity

The lesson also names nano-kernels and exo-kernels as additional kernel types, without explaining their structure in detail.

Think About It

Why might putting more services in user space improve separation, while also making some operations slower?

Comprehensive Review

An operating system separates user-facing activity from privileged system work. User space contains applications and interfaces such as GUIs and CLIs. A shell receives commands in a CLI, while the kernel carries out the system-level operations those commands require. The kernel manages processes, memory, files and directories, and I/O devices.

When a user-space program needs a privileged operation, the system can transition from user mode to kernel mode. Interrupts help signal that the system must respond to software requests or hardware events. When separate processes need to exchange information, IPC provides methods such as shared memory and message passing.

Kernel designs organize these responsibilities differently. A monolithic kernel keeps many functions together for efficient communication, but it can be large and tightly interconnected. A microkernel keeps a smaller set of core functions in the kernel, which can improve separation, but the added mode switching can create performance overhead. A hybrid kernel combines elements of the two approaches in an effort to balance those tradeoffs.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent