Fundamentals 26 min read

Understanding Linux Processes, Kernel Threads, and System Calls

This article provides a comprehensive overview of Linux processes, including their creation, states, kernel and user threads, process management commands, and the role of system calls and security models in enabling efficient multitasking and resource control within the operating system.

Deepin Linux
Deepin Linux
Deepin Linux
Understanding Linux Processes, Kernel Threads, and System Calls

1. Overview

Linux processes are executing programs that improve CPU utilization and system responsiveness by allowing concurrent execution. A process is an abstraction provided by the operating system, combining a program with its execution context, and is the cornerstone of modern multitasking.

Processes occupy separate memory spaces, maintain their own program counters, and can be paused or resumed, requiring the kernel to remember their execution positions. Process creation occurs during system initialization, user requests, or by specific programs, while termination can happen naturally, by self‑termination, external kill, or abnormal exit.

2. Kernel Space

Macrokernel (e.g., Linux, Windows) compiles all core code into a single binary running in one address space, offering high performance but tighter coupling and maintenance complexity.

Microkernel (e.g., RT‑Thread, FreeRTOS) isolates core services into separate modules that communicate via messages, providing better stability and real‑time characteristics at the cost of some performance.

Linux follows a macrokernel design, integrating process scheduling, memory management, device drivers, file systems, and networking within the same kernel address space.

3. Linux Process Principles

A Linux process consists of a program segment, data segment, and a process control block (PCB). The kernel refers to processes as "tasks" and divides virtual address space into user and kernel portions; all processes share the kernel space while each has its own user space.

Process states include RUNNING, READY, BLOCKED, INTERRUPTIBLE SLEEP, UNINTERRUPTIBLE SLEEP, STOPPED, and ZOMBIE. The ps command can display these states using various syntax styles (UNIX, BSD, GNU).

Linux distinguishes two special forms: kernel threads (no user address space, often called daemon processes) and user threads (share a user address space and belong to a thread group). Kernel threads perform tasks such as memory page synchronization, swapping, delayed actions, and filesystem journaling.

4. Process Creation and Parent‑Child Relationships

The init process (PID 1) is created by the kernel at boot and serves as the root of the process tree, spawning subsequent user‑space processes.

Parent processes create children using fork() , optionally vfork() , or clone() . The child inherits the parent's memory via copy‑on‑write, sharing pages until a write occurs, at which point a private copy is made.

clone() offers fine‑grained control over which resources are shared, allowing creation of threads, sibling processes, or isolated processes.

5. Process Management Commands

ps : Lists processes with details such as PID, command, CPU and memory usage; supports UNIX, BSD, and GNU option styles.

top : Provides a dynamic, real‑time view of CPU, memory, and I/O usage, with interactive commands to filter by user, CPU, or memory consumption.

pgrep : Searches for processes by name pattern, optionally displaying PIDs and command lines.

6. System Calls

System calls are categorized into process control (e.g., fork , exit ), file management ( open , read , write ), device management, information maintenance ( getpid , time ), inter‑process communication, memory management ( brk , sbrk ), and networking ( socket , bind , connect ).

Modern CPUs enforce a security model (ring levels) that isolates user programs from kernel resources; system calls act as a controlled gateway, invoked via interrupts that switch the CPU to a privileged mode.

Standard C libraries (e.g., glibc) wrap system calls with convenient functions, abstracting the low‑level interface while preserving portability.

Tools such as strace , ftrace , and truss can trace system‑call activity for debugging or auditing purposes.

7. Relationship Between Process Mechanics and System Calls

Process creation, management, and scheduling all rely on system calls: fork , clone , and exec create new tasks; the kernel allocates a task_struct , copies resources, assigns a PID, and enqueues the task for execution.

Process control blocks store registers, program counters, state flags, priority, and resource handles, all of which are manipulated via system‑call interfaces.

Scheduling policies and priority adjustments are also exposed through system calls, allowing user space to influence CPU allocation.

kernelProcess ManagementLinuxOperating SystemProcessessystem calls
Deepin Linux
Written by

Deepin Linux

Research areas: Windows & Linux platforms, C/C++ backend development, embedded systems and Linux kernel, etc.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.