Back to series
· 16 min read

Linux vs. Windows: How Do OS Designs Differ?


I. Linux and Windows: Why Compare Them?

An operating system is the management layer between computer hardware and applications.

Whether it is Linux or Windows, both must accomplish the following core tasks:

  • Process management: creating, scheduling, and terminating processes.
  • Memory management: allocating memory and managing virtual address spaces.
  • File management: organizing files, directories, and storage devices.
  • Device management: controlling hardware through drivers.
  • Network management: providing network communication capabilities.
  • Security management: controlling user identities, permissions, and resource access.
  • System calls: providing applications with an interface to access the kernel.

Both solve the same problems, but their design philosophies, implementation approaches, and ecosystems are not entirely the same.

1. The Basic Positioning of Linux and Windows

Linux

Open source, modular, and customizable; widely used in servers, cloud computing, embedded devices, and supercomputers.

Windows

A commercial desktop operating system that emphasizes graphical interaction, application compatibility, hardware support, and the enterprise ecosystem.

One concept needs to be made clear here:

Strictly speaking, Linux is an operating system kernel. What we commonly call the Linux operating system usually refers to a complete distribution formed by combining the Linux kernel with GNU tools, system libraries, software packages, and other user-space components, such as Ubuntu, Debian, Fedora, and Arch Linux.

Windows, by contrast, is a complete operating system product family provided by Microsoft, built on the Windows NT kernel architecture at its foundation.

2. What the Two Have in Common

Both Linux and Windows possess the basic capabilities of a modern general-purpose operating system.

Feature Linux Windows
Multitasking Supported Supported
Multi-user management Supported Supported
Virtual memory Supported Supported
Multithreading Supported Supported
File systems ext4, XFS, Btrfs, etc. NTFS, ReFS, FAT, etc.
Network protocol stack TCP/IP, etc. TCP/IP, etc.
Device drivers Supported Supported
Graphical interface GNOME, KDE, etc. Windows Shell
Command line Bash, Zsh, etc. PowerShell, CMD

It is not that one can do something and the other cannot; rather, they differ in implementation approach, default configuration, and usage ecosystem.

II. Kernel Architecture: The Core Difference Between Linux and Windows

The kernel is the most central part of an operating system.

It is responsible for managing critical resources such as the CPU, memory, processes, devices, interrupts, and system calls.

Both Linux and Windows use mature kernel architectures, but they are organized differently.

1. Linux: Monolithic Kernel Architecture

Linux is generally classified as a monolithic kernel.

The core idea of a monolithic kernel is to run a large amount of core operating system functionality within the same kernel address space.

Typical functions include:

  • Process scheduling.
  • Memory management.
  • Virtual file system.
  • Network protocol stack.
  • Device drivers.
  • Interrupt handling.
  • System call handling.

Linux's kernel module mechanism allows some functionality to be loaded and unloaded at runtime.

For example, kernel modules can be viewed using module management tools:

lsmod

Load a module:

sudo modprobe <module_name>

Unload a module:

sudo modprobe -r <module_name>

Modularity does not mean that Linux is a microkernel. Once loaded, modules typically still run in kernel mode and can access the kernel's internal resources.

Schematic of the Linux monolithic kernel structure:

flowchart TB
    A["User Application"] --> B["System Call Interface"]
    B --> C["Linux Kernel Space"]

    subgraph K["Linux Monolithic Kernel"]
        C --> D["Process Scheduling"]
        C --> E["Memory Management"]
        C --> F["Virtual File System"]
        C --> G["Network Protocol Stack"]
        C --> H["Device Drivers"]
        C --> I["Interrupt Handling"]

        D <--> E
        E <--> F
        F <--> H
        G <--> H
        I <--> H
    end

    H --> J["Hardware Devices"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style E fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style F fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style G fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style H fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style I fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style J fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style K fill:#F6FAF7,stroke:#DCE9E0,color:#334155

Advantages of the monolithic kernel:

  • Components within the kernel can collaborate directly.
  • Function call overhead in kernel mode is relatively low.
  • Functions such as networking, file systems, and drivers can be tightly integrated.
  • It has extensive hardware support and a mature module mechanism.

Potential issues:

  • The kernel codebase is large.
  • A serious error in a kernel module can affect the entire system.
  • Internal kernel dependencies are complex.
  • Kernel development and debugging are relatively difficult.

2. Windows: Windows NT Hybrid Kernel Architecture

Windows NT is often described as using a hybrid kernel architecture.

It combines some design ideas from monolithic kernels and microkernels.

The Windows NT kernel architecture includes several important components:

Component Primary Responsibility
HAL Hardware Abstraction Layer
Kernel Handles interrupts, exceptions, thread scheduling, and low-level synchronization
Executive Provides services such as process, memory, I/O, object, and security management
Device Drivers Controls hardware devices
User Mode Subsystems Provides user-mode system services and an application runtime environment

Among these, Windows Executive is not a separate collection of microkernel servers, but rather a set of core management components running in kernel mode.

Windows NT architecture diagram:

flowchart TB
    A["User Application"] --> B["Windows API"]
    B --> C["System Service Interface"]
    C --> D["Windows Kernel Space"]

    subgraph W["Windows NT Kernel Architecture"]
        D --> E["Executive"]
        D --> F["Kernel"]
        D --> G["HAL"]
        E --> H["Process and Thread Management"]
        E --> I["Memory Management"]
        E --> J["I/O Manager"]
        E --> K["Object Manager"]
        E --> L["Security Reference Monitor"]
        J --> M["Device Drivers"]
        F --> N["Scheduling and Interrupt Handling"]
    end

    M --> O["Hardware Devices"]
    G --> O

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style E fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style F fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style G fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style H fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style I fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style J fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style K fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style L fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style M fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style N fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style O fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style W fill:#F6FAF7,stroke:#DCE9E0,color:#334155

The main characteristics of the Windows NT architecture:

  • It isolates some hardware platform differences through the HAL.
  • It organizes core operating system services through the Executive.
  • It uses the Object Manager to uniformly manage a large number of kernel objects.
  • It uniformly organizes device I/O requests through the I/O Manager.
  • It supports multiple kernel-mode and user-mode subsystems.

3. What is the difference between a monolithic kernel and a hybrid kernel?

Comparison Dimension Linux Windows NT
Common Architecture Classification Monolithic kernel Hybrid kernel
Kernel Organization A large number of core functions are integrated into kernel space Components such as the Kernel and the Executive work together
Driver Execution Location A large number of drivers run in kernel mode A large number of drivers run in kernel mode, and user-mode drivers are also supported
Module Mechanism Supports loadable kernel modules Supports driver loading and unloading
Hardware Abstraction Implemented through architecture-specific code and kernel subsystems The HAL provides hardware abstraction
Extension Approach Kernel modules, kernel configuration Drivers, system components, and system services

Note:

Monolithic kernels and hybrid kernels are not a simple ranking of performance levels.

Actual performance also depends on scheduling policies, memory management, driver implementation, hardware capabilities, and system configuration.

III. System Calls: How Do Applications Enter the Kernel?

Applications cannot access kernel data structures and hardware resources at will.

They must request the kernel to perform privileged operations through the interfaces provided by the operating system.

This entry point is the system call.

1. Linux System Calls

Linux uses system calls to provide kernel services to user programs.

Common system calls include:

System call Purpose
read() Read data from a file or device
write() Write data
openat() Open a file
close() Close a file descriptor
fork() Create a process
execve() Execute a new program
mmap() Create a memory mapping
socket() Create a network socket

For example:

#include <unistd.h>
#include <stdio.h>

int main(void)
{
    const char message[] = "Hello Linux\n";

    ssize_t n = write(
        STDOUT_FILENO,
        message,
        sizeof(message) - 1
    );

    if (n < 0) {
        perror("write");
        return 1;
    }

    return 0;
}

Here, write() ultimately requests that the kernel write data to standard output through the system call mechanism.

On the Linux x86-64 platform, the common system call entry instruction is syscall.

System call arguments are passed through agreed-upon registers, and the kernel dispatches the corresponding handler based on the system call number.

2. Windows System Calls

Windows applications usually do not call low-level system calls directly.

A more common call chain is:

  • The application calls a Windows API.
  • The API call enters the corresponding system library.
  • The user-mode system library enters the system call entry point as needed.
  • The kernel performs the corresponding service.
  • The result is returned to user mode.

For example:

#include <windows.h>
#include <stdio.h>

int main(void)
{
    HANDLE file = CreateFileA(
        "demo.txt",
        GENERIC_WRITE,
        0,
        NULL,
        CREATE_ALWAYS,
        FILE_ATTRIBUTE_NORMAL,
        NULL
    );

    if (file == INVALID_HANDLE_VALUE) {
        printf("CreateFile failed: %lu\n", GetLastError());
        return 1;
    }

    const char data[] = "Hello Windows\n";
    DWORD written = 0;

    if (!WriteFile(
        file,
        data,
        sizeof(data) - 1,
        &written,
        NULL
    )) {
        printf("WriteFile failed: %lu\n", GetLastError());
        CloseHandle(file);
        return 1;
    }

    CloseHandle(file);
    return 0;
}

This uses the Windows API rather than calling kernel system services directly.

Windows low-level system service interfaces are internal implementation details and are not suitable as stable public interfaces for ordinary applications to rely on long term.

3. Linux and Windows System Call Paths

flowchart TD
    A["Linux application"] --> B["C standard library or system libraries"]
    B --> C["Linux system call entry"]
    C --> D["Linux kernel services"]
    D --> E["Return to application"]

    F["Windows application"] --> G["Windows API"]
    G --> H["System libraries and user-mode runtime"]
    H --> I["System service call entry"]
    I --> J["Windows kernel services"]
    J --> K["Return to application"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style E fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style F fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style G fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style H fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style I fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style J fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style K fill:#F1F3F5,stroke:#C8CDD3,color:#475569

4. How Are System Call Interfaces Different?

Comparison Dimension Linux Windows
Common application interfaces POSIX API, glibc, etc. Windows API, Win32 API
Low-level entry Linux system calls Windows system service entry
Interface stability System call ABI has stability requirements, but not all internal interfaces are part of the public ABI Windows API is the primary application compatibility interface
Error handling Usually through return values and errno Usually through return values and mechanisms such as GetLastError()
Cross-platform portability POSIX interfaces have strong portability Windows API is primarily oriented toward Windows

An important conclusion:

The API called by an application is not necessarily a system call.

For example, Linux's printf() is a C standard library function; it may reduce the number of actual write() system calls through buffering mechanisms.

Windows's CreateFile() is a Windows API, and internally it may involve system libraries and kernel system services.

IV. Processes and Threads: How Do They Manage Concurrency?

Processes and threads are the basic objects through which an operating system manages task execution.

Both Linux and Windows support multiprocess, multithreaded, and multicore parallel execution, but their internal data structures and scheduling implementations differ.

1. Processes and Threads in Linux

The Linux kernel uses a unified task abstraction to manage execution entities.

One of the core data structures is:

struct task_struct;

Each task is described by a corresponding kernel data structure.

In Linux, the difference between processes and threads is mainly reflected in how resources are shared.

For example:

  • Creates a new process with an independent address space via fork().
  • Creates tasks that can share some resources via clone().
  • Thread libraries usually implement threads based on the task creation capabilities provided by the Linux kernel.

The Linux kernel does not simply regard a thread as another completely independent scheduling entity within a process.

2. Processes and Threads in Windows

There are two important objects in Windows NT:

  • EPROCESS: describes process-related information.
  • ETHREAD: describes thread-related information.

A process mainly manages:

  • Virtual address space.
  • Handle table.
  • Security access token.
  • Process-level resources.
  • Loaded modules.

A thread mainly manages:

  • Execution context.
  • User stack and kernel stack.
  • Thread scheduling state.
  • Thread-local storage.
  • Thread priority.

Windows primarily uses threads as the execution units for CPU scheduling.

3. Process and Thread Comparison

Comparison dimension Linux Windows
Process description Kernel structures such as task_struct EPROCESS
Thread description Kernel structures such as task_struct ETHREAD
Scheduling entity Kernel task Kernel thread
Creating a process fork(), clone(), etc. CreateProcess()
Creating a thread pthread, clone(), etc. CreateThread(), etc.
Address space sharing Implemented through resource-sharing flags Threads in the same process share the process address space
Thread synchronization futex, Mutex, Semaphore, etc. Critical sections, Mutex, Semaphore, Event, etc.

4. Process Creation Flow

Illustration of Linux process creation:

flowchart TD
    A["Parent process calls fork"] --> B["Kernel creates a new task"]
    B --> C["Set up process descriptor structure"]
    C --> D["Create or share necessary resources"]
    D --> E["Establish parent-child relationship"]
    E --> F["Return to parent and child processes"]
    F --> G["Child process continues execution"]
    G --> H{"Call exec?"}
    H -->|Yes| I["Load new program image"]
    H -->|No| J["Continue executing original program code"]
    I --> K["Execute new program"]
    J --> L["Execute subsequent tasks"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style E fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style F fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style G fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style H fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style I fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style J fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style K fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style L fill:#F1F3F5,stroke:#C8CDD3,color:#475569

Windows typically creates processes through the CreateProcess() interface.

Kernel and user-mode components must coordinate the process object, thread object, address space, image loading, and initial execution environment.

The two creation mechanisms differ, but the end goal is the same: to establish a program instance that the operating system can schedule and execute.

5. CPU Scheduling: How Do Linux and Windows Allocate the Processor?

CPU scheduling is responsible for deciding which thread uses the processor and when.

Both Linux and Windows support preemptive multitasking, but their scheduling policies and priority models differ.

1. The Linux Scheduler

For a long time, Linux normal-task scheduling has been built largely on CFS, the Completely Fair Scheduler.

The core idea of CFS is to distribute CPU time as fairly as possible.

It uses mechanisms such as virtual runtime to measure the CPU resources a task receives, and preferentially schedules tasks that are relatively short on CPU time.

Linux also supports different scheduling policies:

Scheduling policy Applies to
SCHED_OTHER Normal tasks
SCHED_FIFO Real-time tasks
SCHED_RR Round-robin real-time tasks
SCHED_BATCH Batch tasks
SCHED_IDLE Low-priority idle tasks
SCHED_DEADLINE Deadline-based real-time scheduling

Note that newer Linux kernels are gradually adopting mechanisms such as EEVDF to improve fair scheduling. Therefore, normal-task scheduling in all modern Linux versions cannot simply be described as a verbatim implementation of the traditional CFS.

2. The Windows Scheduler

Windows uses priority-based preemptive thread scheduling.

Windows threads have different priorities.

The scheduler typically gives preference to the highest-priority thread that is currently runnable.

When a higher-priority thread becomes runnable, it may preempt a lower-priority thread that is currently running.

Windows thread priorities are divided into multiple levels, which combine with the process priority class to form a thread's base priority.

Common priority classes include:

  • Idle.
  • Below Normal.
  • Normal.
  • Above Normal.
  • High.
  • Realtime.

The actual priority is also affected by the thread's relative priority and the system's dynamic adjustment mechanisms.

3. Linux vs. Windows Scheduling Comparison

Aspect Linux Windows
Normal task scheduling Fair scheduling mechanism Priority-based preemptive scheduling
Real-time scheduling Supports real-time policies Supports real-time priority classes
Scheduling entity Kernel tasks Kernel threads
Priority model nice, scheduling policy, and real-time priority Process priority class and thread relative priority
Multicore scheduling Supports CPU affinity and load balancing Supports processor affinity and load distribution
Scheduling extensibility Supports scheduling classes and kernel scheduling mechanism extensions Centrally managed by the Windows scheduler

4. Scheduling Flow

flowchart TD
    A["Thread enters runnable state"] --> B["Join the runnable queue"]
    B --> C["Scheduler evaluates candidate threads"]
    C --> D["Select the thread to run"]
    D --> E["Execute thread"]
    E --> F{"Does a scheduling event occur?"}
    F -->|No| E
    F -->|Yes| G["Save current thread context"]
    G --> H["Update thread state"]
    H --> I["Reselect the running thread"]
    I --> E

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style E fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style F fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style G fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style H fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style I fill:#E9E2F8,stroke:#B7A5D8,color:#514078

6. Memory Management: How Is Virtual Memory Different?

Modern operating systems typically use virtual memory mechanisms to provide each process with an independent virtual address space.

Both Linux and Windows use mechanisms such as paging, page tables, TLBs, and page faults.

However, they differ in specific management policies, memory reclamation, and system interfaces.

1. Basic Principles of Virtual Memory

Applications access virtual addresses.

The MMU in the CPU is responsible for translating virtual addresses to physical addresses according to the page tables.

If a valid mapping has not yet been established for the virtual page being accessed, the processor may trigger a page fault, and the operating system determines whether to allocate a physical page, load the page from storage, or report an illegal access.

flowchart TD
    A["Application accesses virtual address"] --> B["MMU queries TLB"]
    B --> C{"TLB hit?"}
    C -->|Yes| D["Obtain physical address"]
    C -->|No| E["Query page table"]
    E --> F{"Is page table mapping valid?"}
    F -->|Yes| G["Update TLB"]
    G --> D
    F -->|No| H["Trigger page fault"]
    H --> I["OS checks whether access is valid"]
    I --> J{"Is access valid?"}
    J -->|No| K["Report access error"]
    J -->|Yes| L["Allocate physical page or page in page"]
    L --> M["Update page table"]
    M --> N["Re-execute access instruction"]
    N --> B

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style D fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style E fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style F fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style G fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style H fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style I fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style J fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style K fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style L fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style M fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style N fill:#E9E2F8,stroke:#B7A5D8,color:#514078

2. Linux Memory Management

Linux memory management involves:

  • Virtual address space.
  • Physical page management.
  • Page table management.
  • Page cache.
  • Anonymous memory.
  • Memory reclaim.
  • Swap space.
  • Memory mapping.
  • NUMA memory allocation.

Linux can observe memory conditions through /proc and system tools.

free -h

View memory usage:

cat /proc/meminfo

View process memory mappings:

cat /proc/<pid>/maps

View process memory summary:

cat /proc/<pid>/status

Linux uses page cache to improve file read/write performance and reclaims some reclaimable memory under memory pressure.

3. Windows Memory Management

Windows memory management is handled by the Memory Manager.

Main capabilities include:

  • Virtual address space management.
  • Working set management.
  • Page-in and page-out.
  • Memory-mapped files.
  • Page protection.
  • Memory compression.
  • Physical memory allocation.

Windows uses working sets to describe the subset of pages currently resident in physical memory for a process.

When system memory pressure increases, the operating system may adjust a process's working set and move some pages out of physical memory.

4. Comparison of Linux and Windows Memory Management

Comparison dimension Linux Windows
Memory management core Memory Management subsystem Memory Manager
Virtual memory Supported Supported
Page management Page table and physical page management Page table and physical page management
File cache Page Cache Cache Manager and Memory Manager coordination
Memory reclaim LRU-related mechanisms, proactive and direct reclaim, etc. Working set management, page reclaim, etc.
Swap mechanism Swap partition or Swap file Pagefile
Memory monitoring /proc/meminfo, free, vmstat Task Manager, Resource Monitor, Performance Monitor

5. Difference Between Swap and Pagefile

Linux typically uses a Swap partition or a Swap file.

Windows typically uses Pagefile, i.e., the paging file.

Both can provide backing storage space for virtual memory management.

However, their implementations, management policies, and configuration interfaces are not the same.

Comparison dimension Linux Swap Windows Pagefile
Form Partition or file Paging file
Primary purpose Provide swap space for anonymous memory Support mechanisms such as memory commit and page-out
Configuration method swapon, swapoff, configuration files System virtual memory settings
Viewing method swapon --show System Performance Monitor, etc.

Note that Swap and Pagefile are not simply tools for expanding physical memory.

When a system continuously relies on disk swapping to handle active memory data, performance may drop noticeably.

7. File Systems: How Do Linux and Windows Organize Files?

A file system is responsible for managing files, directories, metadata, and data blocks on a disk.

Both Linux and Windows support multiple file systems, but there are clear differences in their default file systems and management methods.

1. Linux File Systems

Linux uses a unified directory tree structure.

All file systems are usually mounted under the same root directory /.

Common directories include:

Directory Primary purpose
/ Root directory
/bin Basic user commands, usually merged with /usr/bin on modern systems
/etc System configuration files
/home Home directories for regular users
/root Home directory for the root user
/var Logs, caches, and variable data
/usr A large number of user-space programs and resources
/dev Device files
/proc Process and kernel information interface
/sys Device model and kernel object information

Common Linux file systems:

  • ext4: A general-purpose journaling file system.
  • XFS: Suitable for large-capacity and high-concurrency storage scenarios.
  • Btrfs: Supports features such as copy-on-write, snapshots, and checksums.
  • ZFS: Commonly used in specific Linux distributions and storage environments; it is a separate ecosystem.

Linux provides a unified file access abstraction through VFS, the Virtual File System.

2. Windows File Systems

Common Windows file systems include:

  • NTFS: Widely used in Windows desktop and server environments.
  • FAT32: Highly compatible, but has limitations such as file size.
  • exFAT: Suitable for flash memory and removable storage devices.
  • ReFS: Targeted at specific Windows storage scenarios, emphasizing data integrity and scalability.

Windows usually uses drive letters to organize volumes, for example:

C:\
D:\
E:\

Each drive letter usually corresponds to a mounted volume.

Windows also supports mounting to directories; it is not limited to drive letters.

3. Comparison of Linux and Windows File Systems

Comparison dimension Linux Windows
Common default file system ext4, depending on the distribution NTFS
Directory organization Unified root directory tree Drive letters and mount points
File name case sensitivity Common file systems are case-sensitive NTFS is usually case-insensitive by default, but supports related settings
Permission model User, group, others, and ACLs Security descriptors and ACLs
Metadata structure Common ext4 uses inodes NTFS uses structures such as MFT
Mounting method mount Volume mounting, drive letters, and directory mounting
Device representation Commonly through /dev Through mechanisms such as device objects and volumes

4. File Access Process

The file access interfaces in Linux and Windows are different, but both need to go through components such as user mode, kernel mode, the file system, and storage drivers.

flowchart TD
    A["Application requests to read a file"] --> B["Operating system file API"]
    B --> C["Kernel file management component"]
    C --> D["File system parses the path"]
    D --> E{"Is the data in the cache?"}
    E -->|Yes| F["Retrieve data from cache"]
    E -->|No| G["Submit storage I/O request"]
    G --> H["Storage device driver"]
    H --> I["Device controller reads data"]
    I --> J["Data enters memory cache"]
    J --> F
    F --> K["Provide data to the application"]

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style E fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style F fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style G fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style H fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style I fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style J fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style K fill:#FFF1D6,stroke:#E7C77E,color:#76551C

8. Device Management: How Do Linux and Windows Control Hardware?

An operating system needs to manage the CPU, disks, network cards, graphics cards, USB devices, and other hardware.

Both rely on device drivers, but their driver models are different.

1. Linux Device Driver Model

Linux manages hardware through a unified device model.

Key concepts include:

  • Bus: bus.
  • Device: device.
  • Driver: driver.
  • Class: device class.
  • Subsystem: device subsystem.

For example, a USB device is discovered through the USB bus, and the driver binds according to device identifiers and matching rules.

Linux also provides a sysfs interface for exposing device model information.

View devices:

ls /sys/bus/

View PCI devices:

lspci

View USB devices:

lsusb

2. Windows Driver Model

Windows adopts the Windows Driver Model, abbreviated as WDM, and has developed multiple driver frameworks on top of it.

Common frameworks include:

  • WDM: Windows Driver Model.
  • KMDF: Kernel-Mode Driver Framework.
  • UMDF: User-Mode Driver Framework.

Windows driver development usually needs to follow the specifications of the corresponding device class and driver framework.

Device Manager can be used to view hardware devices and their driver status.

3. Driver Model Comparison

Comparison dimension Linux Windows
Driver runtime environment Mainly kernel mode; user-mode solutions are also supported Both kernel mode and user mode are supported
Driver framework Kernel subsystems and device model WDM, KMDF, UMDF, etc.
Driver loading Module mechanism, device matching Driver package installation and device matching
Device management sysfs, udev, etc. PnP manager, device installation system
Hardware support Depends on kernel and distribution driver integration Depends on vendor drivers and system driver libraries

4. Plug and Play Mechanism

Modern operating systems support Plug and Play (PnP).

When a device is connected, the operating system needs to identify the device, match a driver, and allocate the relevant resources.

flowchart TD
    A["Hardware device access"] --> B["Bus detection device"]
    B --> C["Operating system identification device"]
    C --> D["Obtain device identifier"]
    D --> E["Find matching driver"]
    E --> F{"Compatible driver found?"}
    F -->|No| G["Report driver missing or incompatible"]
    F -->|Yes| H["Load driver"]
    H --> I["Initialize device"]
    I --> J{"Device initialization successful?"}
    J -->|No| K["Log error and release resources"]
    J -->|Yes| L["Register device interface"]
    L --> M["Application uses device"]
    G --> N["Wait for driver installation or update"]
    K --> N

    style A fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style B fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style C fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style D fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style E fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style F fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style G fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style H fill:#E0F0FE,stroke:#93BCE8,color:#1E4976
    style I fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style J fill:#FFF1D6,stroke:#E7C77E,color:#76551C
    style K fill:#F1F3F5,stroke:#C8CDD3,color:#475569
    style L fill:#E9E2F8,stroke:#B7A5D8,color:#514078
    style M fill:#DCEFE5,stroke:#8EBFA5,color:#24563F
    style N fill:#FFF1D6,stroke:#E7C77E,color:#76551C

9. User Permissions and Security Model

An operating system not only needs to manage resources but also restrict the operations that users and programs can perform.

Both Linux and Windows have comprehensive permission control systems, but their implementations differ.

1. Linux User and Permission Model

Linux uses users and user groups to manage resource access.

Each file usually has:

  • Owner.
  • Owning user group.
  • Permissions for other users.

Permissions mainly include:

Permission Meaning for files Meaning for directories
r Read file View directory contents
w Modify file Modify directory entries
x Execute file Enter the directory or access objects in the directory

View file permissions:

ls -l

Modify permissions:

chmod 755 script.sh

Modify owner:

sudo chown user:group file.txt

Linux also supports security mechanisms such as ACL, Capabilities, SELinux, and AppArmor.

2. Windows Permission Model

Windows uses access tokens, security descriptors, and access control lists to manage permissions.

Key concepts include:

  • SID: Security Identifier.
  • Access Token: Access token.
  • Security Descriptor: Security descriptor.
  • DACL: Discretionary Access Control List.
  • SACL: System Access Control List.