Trace the full lifecycle of a Linux kernel - process
The kernel powers the Internet, the Cloud, servers training large language models on NVIDIA and AMD GPUs, Android devices, and IoT platforms, yet its rapid evolution makes systematic study difficult. Methodical Introduction to the Linux Kernel - Process: Based on the Kernel Versions 6. 0-6. 6 for x86 Architecture guides readers from the user interface through the deepest kernel layers, covering versions up to 6. 6, explaining how processes are created, populated, scheduled, context-switched, and executed.
The book traces the manifestation of a single new process from zero when no pre-existing process exists, detailing every key event and epoch in that progression. It examines the relationship between newly created processes and existing ones, clarifying mutual impacts. Readers gain the process management knowledge needed to customize the kernel and design secure, robust middleware and applications.
Readers will also find:
- An overview marking the key events and epochs in the complete process lifecycle from creation through execution
- Detailed analysis of kernel data structures that are populated when a new process is built from the ground up
- Coverage of scheduling mechanisms and context-switching procedures that govern how processes share processor time on modern hardware
- Guidance on making informed decisions about kernel customization to meet specific embedded system or application requirements
Written for graduate and senior undergraduate students in electrical engineering and computer science, this book also serves Android developers, IoT developers, embedded systems programmers, GPU programmers building large language models, and device driver writers seeking deep knowledge of Linux kernel process management.
Inhaltsverzeichnis
About the Author xi
Preface xiii
Declaration of AI-Assisted Technologies xv
Acknowledgments xvii
A Historical Perspective xxi
Special Contributions xxiii 1 Introduction 1
1. 1 Overview 1
1. 2 Life Cycle of a Process 3
1. 3 Internal Representation of a Process 6
1. 4 Creating Processes 8
1. 5 Synchronization Between P0, P1, and P2 for Creating Processes 12
1. 6 Duplicating Structures for Creating Processes - copy_process() 13
1. 7 Inserting Process into Runqueue - wake_up_new_task() 15
1. 8 Context Switch - schedule() 24
1. 9 Limits of Processes 26
1. 10 Organization of the Book 26 2 Creating Processes 31
2. 1 Overview 31
2. 2 Internal Representation of Processes 34
2. 3 Hardcode P0 - Creating P0init_task, Swapper Thread 37
2. 4 Direct Creation - Creating P1 kernel_init and P2 kthreadd 40
2. 5 Creating Early Kernel Threads and Hotplug Threads 49
2. 6 Synchronization for Creating Early Kernel Threads 77
2. 7 Summary 79 3 Kernel Clone: Part 1 - copy_process() 81
3. 1 Overview of Calls for Creating Processes 81
3. 2 kernel_clone() via kernel_thread() 85
3. 3 kernel_clone() via user_mode_thread() 86
3. 4 kernel_clone() via System Calls 92
3. 5 kernel_clone() 94
3. 6 copy_process() - kernel_clone(): Part 1 95
3. 7 Summary 116 4 Kernel Clone: Part 2 - wake_up_new_task() 119
4. 1 Overview 120
4. 2 Background on runqueues 121
4. 3 Overview of wake_up_new_task() 127
4. 4 Updating runqueue Clock - update_rq_clock() 129
4. 5 Inserting New Tasks to runqueue - activate_task()->enqueue_task() 136
4. 6 Summary 172 5 Per-Entity Load Tracking 175
5. 1 Overview 176
5. 2 Measuring Contributions to Loads 178
5. 3 Computing Individual Load Sums ___update_load_sum() 182
5. 4 Preparation for Computing Individual Load Averages 187
5. 5 Computing Individual Load Averages ___update_load_avg() 193
5. 6 Interrupts - A Short Introduction for scheduler_tick() 194
5. 7 Summary 201 6 Task Groups 203
6. 1 Overview - Hierarchy of Task Groups and Tasks 203
6. 2 Determining Load Sum and Average for Individual Tasks 208
6. 3 Tracking Load Sum and Load Average for Groups 214
6. 4 Updating cfs Groups 229
6. 5 Task Groups in Action Using cgroup 233
6. 6 Summary 244 7 Global Loads 247
7. 1 Overview 248
7. 2 Periods for Updating Global Loads 248
7. 3 Computing Global Loads 252
7. 4 Exponential Decaying of Loads Over Time 257
7. 5 Effects of Period 260
7. 6 No HZ Global Load 262
7. 7 Summary 268 8 Schedule 269
8. 1 Overview 270
8. 2 Preemption 276
8. 3 schedule() 278
8. 4 Putting Previous Task Back to RB Tree 288
8. 5 Context Switch 292
8. 6 Summary 314 Further Reading 315
Index 317
Subject Index 329