Operating System Architecture

Overview of 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

The Monolithic Kernel

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

User Applications
System Call Interface
Monolithic KernelProcess ManagementMemory ManagementFile ManagementDevice ManagementNetwork ManagementOther Services
Hardware Abstraction Layer

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:

Linux Kernel
Process Scheduler
Memory Manager
Virtual File System
Network Subsystem
Device Drivers
System Call Interface

2. The Windows NT Kernel

Characteristics:

  • A hybrid architecture
  • Inspired by the microkernel design
  • A hardware abstraction layer
  • An object manager

Architecture:

Windows NT
Executive
Kernel
Hardware Abstraction Layer (HAL)
Device Drivers

Strengths and Weaknesses

Advantages

  1. High performance

    • No inter-process communication overhead
    • Direct function calls
    • Low latency
  2. Simplicity

    • The architecture is simple
    • Easy to understand
    • High development efficiency
  3. High efficiency

    • Efficient memory access
    • Small system call overhead
    • High resource utilization

Disadvantages

  1. Reliability problems

    • A bug in one module can crash the whole system
    • Faults are hard to isolate
    • Debugging is difficult
  2. Poor maintainability

    • High coupling between modules
    • A change has a wide blast radius
    • High code complexity
  3. Limited extensibility

    • New features are hard to add
    • Limited hardware support
    • Difficult to upgrade

The Microkernel

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

User Applications
Server ProcessesProcess ServerMemory ServerFile ServerDevice ServerNetwork ServerOther Servers
MicrokernelProcess ManagementMemory ManagementInter-Process CommunicationInterrupt HandlingDevice ManagementOther Core Services
Hardware Abstraction Layer

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:

QNX Microkernel
Process Manager
Device Manager
Network Manager
File System Manager
Other Service Processes

2. MINIX 3

Characteristics:

  • A teaching operating system
  • A highly reliable design
  • A modular architecture
  • An open source project

Architecture:

MINIX 3 Microkernel
Process Manager
Memory Manager
File System Server
Device Drivers
Network Server

Strengths and Weaknesses

Advantages

  1. High reliability

    • Service isolation
    • A failure does not take down the whole system
    • Easy recovery
  2. Extensibility

    • Easy to add new services
    • Supports dynamic loading
    • Modular design
  3. Maintainability

    • Independent modules
    • Easy to debug
    • Clear code

Disadvantages

  1. Performance overhead

    • Inter-process communication overhead
    • Frequent context switches
    • Higher memory usage
  2. Complexity

    • The message passing mechanism is complex
    • Debugging is difficult
    • High development cost
  3. Compatibility

    • Poor compatibility with existing software
    • Difficult driver development
    • An incomplete ecosystem

The Layered Architecture

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

Layer N: User Interface
Layer N-1: User Programs
Layer N-2: System Calls
Layer N-3: File Management
Layer N-4: Process Management
Layer N-5: Memory Management
Layer N-6: Device Management
Layer 0: Hardware

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:

Layer 5: User Programs
Layer 4: Operator Interface
Layer 3: Input/Output Management
Layer 2: Inter-Process Communication
Layer 1: Memory Management
Layer 0: Processor Allocation

2. MULTICS

Characteristics:

  • A time-sharing operating system
  • A layered design
  • Security mechanisms
  • Influenced the design of UNIX

Strengths and Weaknesses

Advantages

  1. Clear structure

    • The layer relationships are explicit
    • Easy to understand
    • Highly modular
  2. Maintainability

    • Each layer is independent
    • Easy to modify
    • Convenient debugging
  3. Testability

    • Each layer can be tested on its own
    • The interfaces are explicit
    • Verification is easy

Disadvantages

  1. Performance overhead

    • The cost of calls across layers
    • The cost of translating between interfaces
    • Lower efficiency
  2. Poor flexibility

    • The layers are fixed
    • Calls across layers are difficult
    • Hard to extend
  3. Complex implementation

    • Dividing the system into layers is hard
    • Interface design is complex
    • High development cost

The Modular Architecture

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

User Applications
System Call Interface
Kernel ModulesModule AModule BModule CModule DModule EModule F
Module Interface Layer
Hardware Abstraction Layer

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

  1. Flexibility

    • Modules can be developed independently
    • Dynamic loading is supported
    • Easy to customize
  2. Extensibility

    • New features are easy to add
    • A plugin mechanism is supported
    • Modules can be reused
  3. Maintainability

    • Independent modules
    • Easy to debug
    • Clear code

Disadvantages

  1. Complexity

    • The dependencies between modules are complex
    • Interface design is difficult
    • Debugging is complex
  2. Performance overhead

    • The cost of calls between modules
    • The cost of dynamic loading
    • Higher memory usage
  3. Reliability

    • Dependencies between modules can cause problems
    • Risk of incompatible interfaces
    • Complex testing

The Hybrid Architecture

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:

Windows NT
ExecutiveObject ManagerProcess ManagerMemory ManagerSecurity Reference MonitorI/O Manager
Kernel
Hardware Abstraction Layer (HAL)
Device Drivers

2. macOS

Characteristics:

  • Built on the Mach microkernel
  • A BSD compatibility layer
  • A hybrid architecture
  • High performance

Architecture:

macOS
Application Layer
Framework Layer
Core Services Layer
Kernel EnvironmentMach MicrokernelBSD Compatibility LayerI/O Kit
Hardware Layer

Strengths and Weaknesses

Advantages

  1. Flexibility

    • Combines the advantages of several architectures
    • Adapts to different requirements
    • Balances performance against reliability
  2. Compatibility

    • Supports existing software
    • Backward compatible
    • A mature ecosystem
  3. Extensibility

    • Supports new features
    • A modular design
    • Easy to upgrade

Disadvantages

  1. Complexity

    • The architecture is complex
    • Development is difficult
    • Debugging is complex
  2. Performance overhead

    • Calls traverse several layers
    • Interface translation
    • Higher memory usage
  3. Difficult maintenance

    • Complex code
    • Complex dependencies
    • Difficult testing

Considerations for Choosing an Architecture

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

Glossary

TermAbbreviationExplanation
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 CommunicationIPCThe mechanism through which processes communicate
System Call InterfaceSCIThe system call interface provided by the kernel
Device Driver-A program that controls a hardware device
File SystemFSThe subsystem that manages files
Network Protocol Stack-The implementation of the network protocols
Virtual File SystemVFSA unified interface to file systems
Loadable Kernel ModuleLKMA 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

Found an issue with this content?

Tell us what could be improved.