Daily Dev Tracker

A minimal and sleek daily developer productivity tracker.


Project maintained by devil-1964 Hosted on GitHub Pages — Theme by mattgraham

Linux Architecture

Overview

Linux follows a layered architecture model where each layer provides specific services to the layer above it and uses services from the layer below.

Linux System Architecture Diagram

┌─────────────────────────────────────────────────────────────┐
│                    USER APPLICATIONS                        │
│  (Web Browsers, Text Editors, Games, Office Applications)  │
├─────────────────────────────────────────────────────────────┤
│                   SYSTEM LIBRARIES                         │
│              (glibc, pthread, OpenSSL)                     │
├─────────────────────────────────────────────────────────────┤
│                      SYSTEM CALLS                          │
│            (Interface between User & Kernel Space)         │
├─────────────────────────────────────────────────────────────┤
│                    LINUX KERNEL                            │
│  ┌─────────────┬─────────────┬─────────────┬─────────────┐  │
│  │   Process   │   Memory    │    File     │   Device    │  │
│  │ Management  │ Management  │  System     │  Drivers    │  │
│  └─────────────┴─────────────┴─────────────┴─────────────┘  │
├─────────────────────────────────────────────────────────────┤
│                      HARDWARE                              │
│     (CPU, RAM, Storage, Network, Input/Output Devices)     │
└─────────────────────────────────────────────────────────────┘

Detailed Layer Analysis

1. Hardware Layer

Components:

Key Points:

2. Linux Kernel Layer

The kernel is the core of the operating system that manages system resources.

Kernel Components:

Process Management:

Memory Management:

File System Management:

Device Drivers:

3. System Call Interface

Bridge between user space and kernel space.

Common System Calls:

System Call Mechanism:

User Application
      ↓
System Call Interface
      ↓
Kernel Mode Switch
      ↓
Kernel Function Execution
      ↓
Return to User Mode

4. System Libraries Layer

Provides high-level programming interfaces.

Key Libraries:

5. User Applications Layer

Applications that end users interact with.

Categories:

Kernel Architecture Types

Monolithic Kernel (Linux)

┌─────────────────────────────────────┐
│           USER SPACE                │
├─────────────────────────────────────┤
│                                     │
│  ┌─────┬─────┬─────┬─────┬─────┐    │
│  │ FS  │ Net │ Mem │Proc │Dev  │    │ KERNEL
│  │     │     │ Mgmt│Mgmt │Drv  │    │ SPACE
│  └─────┴─────┴─────┴─────┴─────┘    │
│                                     │
├─────────────────────────────────────┤
│             HARDWARE                │
└─────────────────────────────────────┘

Advantages:

Disadvantages:

User Space vs Kernel Space

User Space

Kernel Space

Memory Layout

┌─────────────────────────────────────┐ ← 0xFFFFFFFF (4GB)
│           KERNEL SPACE              │
│  ┌─────────────────────────────┐    │
│  │    Kernel Code & Data       │    │
│  ├─────────────────────────────┤    │
│  │      Device Drivers         │    │
│  ├─────────────────────────────┤    │
│  │    Kernel Stack/Heap        │    │
│  └─────────────────────────────┘    │
├─────────────────────────────────────┤ ← 0xC0000000 (3GB)
│           USER SPACE                │
│  ┌─────────────────────────────┐    │
│  │         Stack               │    │ ← High Addresses
│  │         ↓                   │    │
│  │                             │    │
│  │         ↑                   │    │
│  │         Heap                │    │
│  ├─────────────────────────────┤    │
│  │    Uninitialized Data       │    │
│  │         (BSS)               │    │
│  ├─────────────────────────────┤    │
│  │    Initialized Data         │    │
│  ├─────────────────────────────┤    │
│  │      Program Code           │    │ ← Low Addresses
│  │        (Text)               │    │
│  └─────────────────────────────┘    │
└─────────────────────────────────────┘ ← 0x00000000

Key Concepts

1. Kernel Modules

2. Interrupts

3. Context Switching

Process of saving current process state and loading another process:

Process A Running → Save State → Load Process B State → Process B Running

4. Virtual Memory

Linux Distribution Architecture

┌─────────────────────────────────────┐
│        Desktop Environment          │
│     (GNOME, KDE, XFCE, etc.)       │
├─────────────────────────────────────┤
│         Display Server              │
│        (X11, Wayland)               │
├─────────────────────────────────────┤
│         Init System                 │
│    (systemd, SysV, OpenRC)         │
├─────────────────────────────────────┤
│        System Libraries             │
│         (glibc, etc.)               │
├─────────────────────────────────────┤
│         Linux Kernel                │
├─────────────────────────────────────┤
│           Hardware                  │
└─────────────────────────────────────┘