Operating System Architecture
Why Architecture Matters
The architecture of an operating system determines the performance, reliability, maintainability, and extensibility of the system. Choosing the right architecture is essential to the design and implementation of an operating system.
Architecture Design Goals
- Performance: use hardware resources efficiently
- Reliability: keep the system running stably
- Maintainability: make the code easy to understand and modify
- Extensibility: support new features and new hardware
- Security: protect the system from attacks
Basic Concept
The monolithic kernel is the most traditional operating system architecture. Every operating system function is implemented inside the kernel, and all of it runs in a single address space.
Architectural Characteristics
1. Overall Structure
2. Key Features
- Unified address space: all kernel code runs in the same address space
- Direct communication: kernel modules call each other’s functions directly
- Efficient execution: no context switch overhead
- Tight coupling: the dependencies between modules are complex
Typical Implementations
1. The Linux Kernel
Characteristics:
- Modular design
- Kernel modules can be loaded dynamically
- Support for many hardware platforms
- Driven by an open source community
Architecture:
2. The Windows NT Kernel
Characteristics:
- A hybrid architecture
- Inspired by the microkernel design
- A hardware abstraction layer
- An object manager
Architecture:
Strengths and Weaknesses
Advantages
-
High performance
- No inter-process communication overhead
- Direct function calls
- Low latency
-
Simplicity
- The architecture is simple
- Easy to understand
- High development efficiency
-
High efficiency
- Efficient memory access
- Small system call overhead
- High resource utilization
Disadvantages
-
Reliability problems
- A bug in one module can crash the whole system
- Faults are hard to isolate
- Debugging is difficult
-
Poor maintainability
- High coupling between modules
- A change has a wide blast radius
- High code complexity
-
Limited extensibility
- New features are hard to add
- Limited hardware support
- Difficult to upgrade
Basic Concept
The microkernel architecture spreads operating system functionality across several independent server processes. The kernel itself provides only the most basic services.
Architectural Characteristics
1. Overall Structure
2. Key Features
- Minimal kernel: the kernel contains only the most basic functionality
- Server processes: operating system services run in user mode
- Message passing: processes communicate through messages
- Modular design: services are independent and easy to replace
Typical Implementations
1. QNX
Characteristics:
- A real-time operating system
- High reliability
- A microkernel architecture
- Widely used in embedded systems
Architecture:
2. MINIX 3
Characteristics:
- A teaching operating system
- A highly reliable design
- A modular architecture
- An open source project
Architecture:
Strengths and Weaknesses
Advantages
-
High reliability
- Service isolation
- A failure does not take down the whole system
- Easy recovery
-
Extensibility
- Easy to add new services
- Supports dynamic loading
- Modular design
-
Maintainability
- Independent modules
- Easy to debug
- Clear code
Disadvantages
-
Performance overhead
- Inter-process communication overhead
- Frequent context switches
- Higher memory usage
-
Complexity
- The message passing mechanism is complex
- Debugging is difficult
- High development cost
-
Compatibility
- Poor compatibility with existing software
- Difficult driver development
- An incomplete ecosystem
Basic Concept
The layered architecture organizes operating system functionality into layers. Each layer uses only the services the layer below provides, and offers services to the layer above.
Architectural Characteristics
1. The Layer Decomposition
2. Key Features
- Layered dependencies: each layer depends only on the layer below
- Service abstraction: upper layers use lower-layer services through interfaces
- Modularity: the responsibilities of each layer are independent
- Testability: each layer can be tested on its own
Typical Implementations
1. The THE Operating System
Characteristics:
- The first layered operating system
- A six-layer structure
- A teaching system
- A lasting influence
Layer structure:
2. MULTICS
Characteristics:
- A time-sharing operating system
- A layered design
- Security mechanisms
- Influenced the design of UNIX
Strengths and Weaknesses
Advantages
-
Clear structure
- The layer relationships are explicit
- Easy to understand
- Highly modular
-
Maintainability
- Each layer is independent
- Easy to modify
- Convenient debugging
-
Testability
- Each layer can be tested on its own
- The interfaces are explicit
- Verification is easy
Disadvantages
-
Performance overhead
- The cost of calls across layers
- The cost of translating between interfaces
- Lower efficiency
-
Poor flexibility
- The layers are fixed
- Calls across layers are difficult
- Hard to extend
-
Complex implementation
- Dividing the system into layers is hard
- Interface design is complex
- High development cost
Basic Concept
The modular architecture organizes operating system functionality into independent modules. Modules communicate with each other through standard interfaces.
Architectural Characteristics
1. Module Organization
2. Key Features
- Module independence: each module has an independent responsibility
- Standard interfaces: modules communicate through standard interfaces
- Dynamic loading: modules can be loaded and unloaded at runtime
- Extensibility: new modules are easy to add
Typical Implementations
1. Solaris
Characteristics:
- A modular kernel
- Dynamic loading
- High reliability
- Enterprise-grade features
Module types:
- Scheduler modules
- Memory management modules
- File system modules
- Network modules
- Device driver modules
2. NetBSD
Characteristics:
- Highly portable
- A modular design
- An open source system
- Support for many platforms
Strengths and Weaknesses
Advantages
-
Flexibility
- Modules can be developed independently
- Dynamic loading is supported
- Easy to customize
-
Extensibility
- New features are easy to add
- A plugin mechanism is supported
- Modules can be reused
-
Maintainability
- Independent modules
- Easy to debug
- Clear code
Disadvantages
-
Complexity
- The dependencies between modules are complex
- Interface design is difficult
- Debugging is complex
-
Performance overhead
- The cost of calls between modules
- The cost of dynamic loading
- Higher memory usage
-
Reliability
- Dependencies between modules can cause problems
- Risk of incompatible interfaces
- Complex testing
Basic Concept
The hybrid architecture combines the advantages of several architectures, picking the right architectural pattern for the requirements at hand.
Typical Implementations
1. Windows NT
Characteristics:
- Microkernel ideas
- A monolithic implementation
- A modular design
- A hardware abstraction layer
Architecture:
2. macOS
Characteristics:
- Built on the Mach microkernel
- A BSD compatibility layer
- A hybrid architecture
- High performance
Architecture:
Strengths and Weaknesses
Advantages
-
Flexibility
- Combines the advantages of several architectures
- Adapts to different requirements
- Balances performance against reliability
-
Compatibility
- Supports existing software
- Backward compatible
- A mature ecosystem
-
Extensibility
- Supports new features
- A modular design
- Easy to upgrade
Disadvantages
-
Complexity
- The architecture is complex
- Development is difficult
- Debugging is complex
-
Performance overhead
- Calls traverse several layers
- Interface translation
- Higher memory usage
-
Difficult maintenance
- Complex code
- Complex dependencies
- Difficult testing
1. Application Scenario
Real-time systems:
- Choose a microkernel or a hybrid architecture
- Prioritize reliability and response time
- Examples: QNX, VxWorks
General-purpose systems:
- Choose a monolithic or a hybrid architecture
- Prioritize performance and compatibility
- Examples: Linux, Windows
Embedded systems:
- Choose a microkernel or a modular architecture
- Prioritize reliability and resource efficiency
- Examples: FreeRTOS, uC/OS
2. Performance Requirements
High performance:
- Choose a monolithic architecture
- Reduce system call overhead
- Optimize memory access
High reliability:
- Choose a microkernel architecture
- Isolate services
- Add fault recovery mechanisms
Balanced performance:
- Choose a hybrid architecture
- Combine the advantages of several designs
- Tune the trade-offs to the requirements
3. Development Cost
Low cost:
- Choose a monolithic architecture
- Simple development
- Easy debugging
High investment:
- Choose a microkernel architecture
- Complex development
- Long-term payoff
Moderate investment:
- Choose a modular architecture
- Balance cost against payoff
- Incremental development
1. Virtualization Support
Characteristics:
- Hardware virtualization
- Operating system virtualization
- Application virtualization
Impact:
- The architecture has to support virtualization
- Performance optimization
- Stronger security
2. Multicore Support
Characteristics:
- Multiprocessor architectures
- Parallel processing
- Load balancing
Impact:
- Scheduling algorithms have to be optimized
- Memory management has to improve
- Stronger synchronization mechanisms
3. Stronger Security
Characteristics:
- Security isolation
- Permission control
- Attack protection
Impact:
- The advantages of the microkernel architecture
- A security module design
- Trusted computing
4. Cloud-Native Support
Characteristics:
- Containerization
- Microservices
- Elastic scaling
Impact:
- Lightweight kernels
- Fast startup
- Resource isolation
| Term | Abbreviation | Explanation |
|---|---|---|
| Monolithic Structure | - | All functionality in a single address space |
| Layered Structure | - | An operating system structure organized into layers |
| Microkernel Structure | - | A structure that minimizes kernel functionality |
| Modular Structure | - | A structure whose modules can be loaded dynamically |
| Hybrid Structure | - | A structure that combines several architectures |
| Exokernel | - | A kernel architecture that minimizes abstraction |
| Client-Server | - | The service model used by microkernels |
| Inter-Process Communication | IPC | The mechanism through which processes communicate |
| System Call Interface | SCI | The system call interface provided by the kernel |
| Device Driver | - | A program that controls a hardware device |
| File System | FS | The subsystem that manages files |
| Network Protocol Stack | - | The implementation of the network protocols |
| Virtual File System | VFS | A unified interface to file systems |
| Loadable Kernel Module | LKM | A kernel module that can be loaded dynamically |
| Kernel Thread | - | A thread created by the kernel |
| User Thread | - | A thread created in user space |
| Interrupt Handler | - | The program that handles an interrupt |
| Exception Handler | - | The program that handles an exception |
| System Call Handler | - | The program that handles a system call |
| Context Switch | - | Switching the execution environment of a process |
