System Calls and OS Structures
Understand the interface between applications and the OS via system calls, and explore the different architectural designs of modern operating systems.
Learning Goals
- Define system calls and explain their role as the interface to OS services.
- Categorize system calls into five major types: Process Control, File Management, Device Management, Information Maintenance, and Communications.
- Compare and contrast different OS structures, including Monolithic, Layered, and Microkernel architectures.
What are System Calls?
System calls provide the interface between a running program and the operating system. They are the primary way a user-level program requests a service from the OS kernel.
How System Calls Work
When a program needs a service (like reading a file or creating a process), it executes a specific instruction that triggers a trap to the kernel. This switches the CPU from user mode to kernel mode.
Types of System Calls:
- Process Control:
end,abort,load,execute,create process,terminate process. - File Management:
create file,delete file,open,close,read,write. - Device Management:
request device,release device,read,write,get/set device attributes. - Information Maintenance:
get time or date,get/set system data. - Communications:
create/delete communication connection,send/receive messages.
Operating System Structures
The design and implementation of operating systems vary significantly. Over the years, several architectural approaches have been developed.
1. Simple / Monolithic Structure
In a monolithic system, the entire OS runs as a single, large program in kernel mode. All services are bundled together.
- Example: Early versions of MS-DOS and original UNIX.
- Pros: High performance due to low overhead in communication.
- Cons: Difficult to debug, maintain, and extend. A crash in any service can bring down the entire system.
2. Layered Approach
The OS is broken down into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0) is the hardware; the highest (layer N) is the user interface.
- Rule: A layer can only use functions and services of lower-level layers.
- Pros: Simplicity of debugging and system verification.
- Cons: Performance can be slow due to the overhead of passing through multiple layers.
3. Microkernel Structure
This method structures the OS by removing all non-essential components from the kernel and implementing them as system and user-level programs.
- Kernel Role: Provides minimal services like communication (IPC), memory management, and CPU scheduling.
- Example: Mach (used in macOS), QNX.
- Pros: High reliability and security. If a service (like a file server) fails, the rest of the OS remains unaffected.
- Cons: Performance overhead due to increased system-function communication (message passing).
4. Modules (Hybrid Approach)
Most modern operating systems (like Linux and Windows) use a hybrid approach. They use a monolithic kernel but have Loadable Kernel Modules (LKMs) that can be added or removed while the system is running.
Knowledge Check
What happens when a system call is executed?