The art of Linux kernel design: Graphic Design and Implementation of Linux operating system architecture

Source: Internet
Author: User

The art of Linux kernel design: Graphic Design and Implementation of Linux operating system architecture

The art of Linux kernel design: graphic design and implementation principles of Linux operating system architecture. The ability to control and deeply understand the operating system kernel reaches the world's top level, is a classic book that truly guides you through Linux kernel design ideas.
Based on the real source code, 349 kernel run-time diagrams, and detailed text descriptions, the Linux kernel is described in an extremely intuitive and thorough manner in a ground-breaking manner, readers can read this book to propose their own design ideas.

Basic Information

Author:New Design Team

Series Name:Original huazhan boutique

Press: Machinery Industry Press


Mounting time:

Published on: February 1, July 2011


The art of Linux kernel design: graphic design and implementation principles of Linux operating system architecture


There are countless books on the Linux kernel, but this book is unique. It represents the world's top level of Linux kernel research results. It was first proposed and explained in the world.
Describes the core guiding ideology of operating system design-the master-slave mechanism, which is a valuable asset of all operating system researchers. This book may also represent the top level of similar books, which is truly able to guide us more easily
An easy and thorough understanding of the Linux kernel's classics may also be the only book that can guide us in designing and developing an operating system with proprietary intellectual property rights. Its publication may become
A milestone in the field of Linux kernel research.
The art of Linux kernel design: graphic design and implementation principles of Linux operating system architecture is characterized by its writing and content organization methods, which are completely different from those of similar books. It deeply analyzes
After the advantages and disadvantages of the traditional methods, we have created a new way from the perspective of cognitive science. Taking the real operating process of the operating system as the main line, combined with the real kernel source code, 349 precise kernel operations
The line sequence diagram and eye-catching text instructions systematically and completely analyze the entire process from powering on the operating system to fully preparing the system, deeply reveals the design intent and
The implementation principle perfectly reproduced the design philosophy of the operating system designer. Reading this book is like thinking with the operating system designers. We will find the exquisite design of the Linux Kernel During the reading process,
You will find that all of them are "hidden xuanjicang", even a very short line of code.
The art of Linux kernel design: graphic Linux operating system architecture design and implementation principle strives for perfection in all details. To ensure the accuracy of knowledge
All have been rigorously verified. In order to let us truly understand the principles of the Linux kernel, it breaks through the tradition and focuses on the actual running process of Linux. In order to truly make it easy to understand and innovate
A 349-frame-DPI time sequence diagram is carefully drawn using the graphic method. The structure and status of the runtime diagram are exactly consistent with the actual running status of the operating system. In order to improve the reading body
This book uses two-color printing, so that we can more clearly observe the details of each picture.


The art of Linux kernel design: Illustration of Linux operating system architecture design and implementation principles

Book Introduction


Chapter 1 process from power-on to execution of main function 1

1.1 start bios and prepare the interrupt vector table and interrupt service program in real mode 1

1.1.1 BIOS startup Principle 2

1.1.2 BIOS loads the interrupt vector table and interrupt service program in memory 3

1.2 load the operating system kernel program and prepare for the protection mode 4

1.2.1 load the first part of Code-bootsect 5

1.2.2 load Part 2 code-setup7

1.2.3 load Part 3 code-System Module 12

1.3 started to change to the 32-Bit mode, preparing for calling the main function 16

1.3.1 disconnect and move the system to the memory address starting position 0x0000016

1.3.2 set the Interrupt Descriptor Table and Global Descriptor Table 18

1.3.3 enable A20 for 32-bit addressing 20

1.3.4 prepare for executing head. s in Protected Mode 21

1.3.5 head. s started to run 24

1.4 Chapter 41

Chapter 4 from main to idle speed 42

2.1 preparations before the disconnection 43

. 2.1.1 copy the root device number and hard disk parameter table 44

2.1.2 physical memory planning pattern 45

2.1.3 Virtual Disk settings and initialization 46

2.1.4 memory management structure mem_map initialization 47

2.1.5 Exception Handling interrupt service program mounting 48

2.1.6 initialize the block device request item structure 50

2.1.7 connection of the interrupt service program of peripherals related to the establishment of the Human-Computer Interaction Interface 52

2.1.8 boot Start Time Setting 55

2.1.9 start to activate the process 056

2.1.10 process-related transaction initialization settings 57

2.1.11 clock interruption settings 59

2.1.12 mount the system call service program 59

2.1.13 initialize the buffer management structure 61

2.1.14 initialize hard disk 63

2.1.15 initialize a floppy disk 65

2.1.16 disconnection 66

2.2 basic actions created by a process 67

2.2.1 The operating system creates process 1 for process 0 prepare 67

2.2.2 apply for an idle location for process 1 in the process slot and obtain process number 71

2.2.3 before copying process information, pressure some data to stack 73

2.2.4 initial process 1 Management Structure 74

2.2.5 process 0: the clock is interrupted when process 1 is created

2.2.6 return 78 from clock interruption

2.2.7 adjust process 1 Management Structure 79

2.2.8 set the linear address space and physical page of process 1 81

2.2.9 continue to adjust process 1 Management Structure 84

2.2.10 how does the operating system differentiate processes 0 and 187?

2.2.11 process 0 prepare to switch to process 189

2.2.12 the system switches to process 1 and executes 90

2.3 load the root file system 92

2.3.1 process 1: How to start execution 96

2.3.2 process 1 execution started 98

2.3.3 process 1 starts to operate hard disk 99 in the form of data blocks

2.3.4 mount the buffer block and request item 101

2.3.5 mount the request item with the hard disk processing function 104

2.3.6 preparations before hard disk reading 105

2.3.7 issue read Instruction 106 to the hard disk

2.3.8 process 1 suspended due to pending disk reading operation 107

2.3.9 switch the system to process 0 and execute 109

2.3.10 process 0 execution 110

2.3.11 hard disk Interruption During process 0 execution 111

2.3.12 after the hard disk interrupt service program responds, process 0 continues to execute 113

2.3.13 re-respond to hard drive interruption and wake up process 1114

2.3.14 after the disk reading operation is complete, process 1 continues to execute 116

2.3.15 process 1 continue setting hard disk management structure 117

2.3.16 process 1 gets the ultra block of the floppy disk and prepares 118 for loading the root file system

2.3.17 process 1 back up super block data 119

2.3.18 process 1: copy the root file system from a floppy disk to the Virtual Disk 120

2.3.19 process 1 starts loading the root file system 122

2.3.20 process 1 prepare to load root file system super block 123

2.3.21 process 1 load the root file system superblock 124

2.3.22 process 1 Continue loading the root file system 126

2.3.23 process 1 prepare to read the root directory I node 127

2.3.24 process 1 load the root directory I node 128

2.3.25 process 1 end the process of loading the root file system 129

2.4 open terminal device files and copy file handles 131

2.4.1 process 1 is mounted to the kernel file table to prepare for opening the file 133

2.4.2 determine the start point of the open operation 135

2.4.3 obtain the I node 136 of the branch I node-dev directory file

2.4.4 make sure that the dev directory file I node is a branch I node 137

2.4.5 continue to return to branch I node 138

2.4.6 search for the I node 138 of the tty0 File

2.4.7 return the I node of the tty0 device file to sys_open System Call 139

2.4.8 analyze tty0 file I node 140

2.4.9 set the file management structure and return it to the user process 141

2.4.10 process 1 copy the tty0 file handle 142

2.4.11 process 1 continue copying tty0 file handle 144

2.5 Process Creation 2145

2.5.1 process 1 prepare to create process 2145

2.5.2 copy process 2 management structure and make adjustments 146

2.5.3 set the page Directory of process 2 and copy the page table 146 of process 2

2.5.4 adjust the document-related content in process 2 management structure 146

2.5.5 process 1: clock interruption occurs during execution 148

2.5.6 process 1 returns from clock interruption and is ready to switch to process 2150

2.6 process 1 wait for process 2 to exit 150

2.6.1 process 1 find its own sub-process 151

2.6.2 process the status of process 2 151

2.6.3 switch to process 2 and execute 153

2.7 shell program loading 154

2.7.1 process 2 starts to execute 156

2.7.2 prepare for opening the/etc/rc file 156

2.7.3 process 2 open the "/etc/rc" configuration file 157

2.7.4 prepare for loading shell files through the pressure stack 158

2.7.5 prepare for parameter and environment variable settings 159

2.7.6 obtain the I node 160 of the shell file.

2.7.7 prepare for loading parameters and environment variables 161

2.7.8 check shell files based on the I node 162

2.7.9 check shell file header 163

2.7.10 back up and analyze the file header 163

2.7.11 Further Analysis of Shell files 165

2.7.12 copy parameters and environment variables 166

2.7.13 adjust the management structure of process 2 167

2.7.14 continue to adjust process 2 management structure 168

2.7.15 release process 2 inherited page 169

2.7.16 detection coprocessor 170

2.7.17 adjust the linear space address of the shell program 171

2.7.18 prepare parameters and environment variables for the shell program 172

2.7.19 continue to adjust process 2 management structure 173

2.7.20 adjust the EIP to point it to the shell program entry address 173

2.7.21 page disconnection caused by Shell execution 175

2.7.22 detection of shell program loading before page disconnection 175

2.7.23 apply for the content to be loaded 177

2.7.24 load the shell program to the New Page 177

2.7.25 adjust the page content 178 Based on the shell program

2.7.26 map the linear address space to the physical page of the program 179

2.8 system idle speed 180

2.8.1 the shell process is preparing to create the update process 180

2.8.2 process 2 start to execute/etc/rc file 181

2.8.3 prepare to load update process 181

2.8.4 roles of the update process 182

2.8.5 the shell program detects the "/etc/rc" file 183

2.8.6 Shell Process exited 184

2.8.7 Shell Process exited after-care handling 185

2.8.8 process 1 clear the Shell Process Management Structure 187

2.8.9 rebuilding shell190

2.8.10 why the shell process will not exit 192 again

2.9 conclusion 194

Chapter 4 file system installation 3rd

3.1 obtain the hard drive device number 196

3.1.1 The user sends a command to install the hard disk file system 196

3.1.2 starting from the analysis path, find the mount point 197 of the hd1 device.

3.1.3 Based on the root directory I node, obtain the dev directory file I node 197

3.1.4 find the directory item 198 representing the hd1 device file from the dev directory file

3.1.5 obtain the I node number of the hd1 Device File 199

3.1.6 release the dev directory file 200

3.1.7 obtain the I node 200 of the hd1 Device File

3.1.8 obtain the device Number of hd1 device 200

3.1.9 I node 201 for releasing hd1 Device Files

3.2 obtain the mount point 202 on the Virtual Disk

3.3 obtain the super block 202 of the hd1 Device File

3.3.1 prepare to read the file of the hd1 device. The super block is 203.

3.3.2 locate the storage location 203 for the super block of the hd1 Device File

3.3.3 initialize the idle super block and lock the block by 203

3.3.4 obtain the super block 204 of the hd1 device file from the hard disk

3.3.5 loading Logical Block bitmap and I-node bitmap 205

3.4 mount the hd1 device file to the I node of the MNT directory file 206

3.5 conclusion 207

Chapter 4 File Operations 4th

4.1 open file 211

4.1.1 soft interruptions caused by the user program calling the Open Library Function 212

4.1.2 establish the relationship between user processes and the file management table 213

4.1.3 I node 214 of the helloc.txt file obtained from the hard disk

4.1.4 mount the helloc.txt file with the file management table 226

4.2 read files 227

4.2.1 prepare for reading files according to user requirements 228

4.2.2 determine the position of the data block to be read 230

4.2.3 read the specified data block from the hard disk to the high-speed buffer block 233

4.2.4 copy data to user-specified memory 234

4.3 create a file 237

4.3.1 search path "/mnt/user/hello.txt" 238

4.3.2 create an I node 240 FOR THE hello.txt File

4.3.3 create directory item 242 for the hello.txt File

4.3.4 complete the new hello.txt operation and return it to the user process 245

4.4 write files 246

4.4.1 preparations before file writing 248

4.4.2 determine the write location of the hello.txt file: 249

4.4.3 Data Write Request Buffer block 252

4.4.4 copy the specified written data from the user data zone to the buffer block 253

4.4.5 method of synchronizing data to hard disk 1255

4.4.6 writing files to the hard disk 2257

4.5 Modify file 260

4.5.1 relocate the current operation pointer of the file 261

4.5.2 File Modification 261

4.6 close file 263

4.6.1 the current process and the file management table "decoupling" 264

4.6.2 reduce the number of references corresponding to hello.txt in the file management table by 1265

4.6.3 "decoupling" between the hello.txt file and the file management table 266

4.7 delete a file 268

4.7.1 Delete the hello.txt file 268 from the system kernel.

4.7.2 Delete the data corresponding to the hello.txt file on the hard disk and the I node 270

4.7.3 process the user directory of the hello.txt file 275

4.8 Summary of this chapter 275

Chapter 4 User process and memory management 5th

5.1 Creation of user processes 277

5.1.1 prepare condition 277 for the creation process str1

5.1.2 locate the bucket 279 for the str1 Process Management Structure

5.1.3 copy the str1 process management structure 281

5.1.4 determine the position of the str1 process in Linear Space 282

5.1.5 copy the str1 process page table and set its corresponding page Directory item 283

5.1.6 adjust the file-related structure in the str1 process 285

5.1.7 establish the association between str1 process and gdt in the Global Descriptor Table 286

5.1.8 set the str1 process to ready 287

5.2 prepare for loading user process str1 288

5.2.1 prepare for the str1 process to load the corresponding program 288

5.2.2 read the I node of the str1 executable file and collect statistics on parameters and environment variables 289

5.2.3 read the str1 Executable File Header 290

5.2.4 Analysis of str1 executable program file header 291

5.2.5 copy str1 executable program parameters and environment variables 292

5.2.6 adjust the I node 292 corresponding to executable programs in the str1 Process Management Structure

5.2.7 continue to adjust str1 Process Management Structure-file and signal-related fields 293

5.2.8 release the page 294 of the str1 Process

5.2.9 reset str1 program code segment and Data Segment 295

5.2.10 create an environment variable and parameter reference table 296

5.2.11 continue to adjust str1 process management structure according to str1 executable program 297

5.2.12 set the stack pointer and EIP value of str1 executable program to 297

5.3 handling of page disconnection 298

5.3.1 page disconnection occurs and the OS responds 298

5.3.2 apply for a memory page 299 for the str1 Program

5.3.3 load the str1 program to the newly allocated page 300

5.3.4 check whether the remaining page space needs to be cleared by 0300

5.3.5 the physical memory address occupied by the str1 program corresponds to the linear address space of the str1 process by 301

5.3.6 continuously loading all content of str1 program through page missing interruption 301

5.3.7 str1 program requires stack pressure of 302

5.3.8 The first time the str1 program calls the foo program to press the stack 302

5.3.9 the str1 program presses the stack for the second time, resulting in 302 Page-missing interruptions.

5.3.10 handling of page-missing interruptions caused by the second press stack of the str1 program 302

5.3.11 str1 program continues to be executed, and stacks are repeatedly pressed, resulting in page-missing interruptions of 303

5.3.12 clear stack 303 after the str1 program runs successfully

5.4 str1 user process exit 305

5.4.1 the str1 process is about to exit 305

5.4.2 release str1 program accounts for 305 of the page

5.4.3 release str1 program file-related content and send a 306 signal to the parent process

5.4.4 Execute Process Scheduling 307 after the str1 program exits

More than 5.5 user processes run 308 simultaneously

5.5.1 create str1, str2, and str3 process 308 in sequence

5.5.2 execution of str1 process pressure stack 309

5.5.3 The clock is interrupted during str1 operation and switched to str2 for execution 309

5.5.4 switch to str3 when the clock is interrupted during str2 execution to execute 310

5.5.5 distribution of the primary memory after three programs are executed for a period of time: 311

5.6 process scheduling and switching 311

5.6.1 str1 has just been created by Shell and is in ready state 311

5.6.2 the shell process suspends itself and is ready to switch to str1 to execute 311.

5.6.3 prepare to switch to the str1 process for execution 312

5.6.4 clock interruption 314 during str1 execution

5.6.5 decrease in clock interruption str1 running time slice 315

5.6.6 str1 is suspended after execution for a period of time, and the shell process creates str2 process 315

5.6.7 clock interruption occurs during str2 running 316

5.6.8 the system switches to str1 and executes the program 317

5.7 kernel paging 318

5.7.1 prepare for setting the page Directory table and page table of the kernel-Clear the occupied space by 0318

5.7.2 set the content of the page Directory and page table corresponding to the kernel 319

5.7.3 set the Global Descriptor Table gdt320 corresponding to the kernel

5.8 page write protection 321

5.8.1 process a and process B sharing page 321

5.8.2 process a is about to perform the stack pressure operation 322

5.8.3 process a's pressure stack action triggers write protection 322

5.8.4 point the page table of process a to page 323 of the newly applied page

5.8.5 copy the original page content to the new application page 324 of process

5.8.6 process B Preparation operation sharing page 325

5.8.7 assume that process B executes the stack pressure operation first. 325

5.9 conclusion 326

Chapter 2 multiple processes operate on one file simultaneously 6th

6.1 three processes operate on the same file 327

6.1.1. The hello.txt file is opened in Step A. 328

6.1.2 A reads the hello.txt file and is suspended by the system due to hard drive interruption 328

6.1.3 open the hello.txt file 330 in the B process.

6.1.4 The system worker is node 332 of the I that received the hello.txt file in the process B.

6.1.5 The system finds the I node 333 that has been loaded in the hello.txt File

6.1.6 The System reads the hello.txt file 334 from the hard drive for the process B.

6.1.7 the system finds the buffer block being operated and suspends process B 335

6.1.8 the system switches to process 0 again to execute 337

6.1.9 run the C-SDK and open the hello.txt file 337.

6.1.10 Process C is also suspended by the system due to waiting for the buffer block to unlock 338

6.1.11 wake up the process c339 after the buffer block is unlocked

6.1.12 the system sets process B to ready state 340

6.1.13 the system writes specified data to buffer block 341

6.1.14 after the write is complete, process C continues to execute 341

6.1.15 Process C is ready to switch to process b342

6.1.16 Process C switches to process B for execution, and process B wakes up process a342

6.1.17 process B is continuously executed until the time slice is reduced to 0 and then switched to process a for execution 343.

6.1.18 process A, B, and C exit, and the data written is synchronized by the update process by 344.

6.2 Data synchronization between the buffer zone and peripherals 344

6.2.1 The system constantly writes 346 data to the buffer zone for process

6.2.2 if the execution continues, the buffer block data needs to be synchronized by 346.

6.2.3 synchronize data in the buffer to the hard disk 347

6.2.4 process a is suspended by the system due to waiting for idle request items 349

6.2.5 process B starts to execute 350

6.2.6 process B is also suspended 351

6.2.7 Process C is executed and then suspended 352

6.2.8 process a and process C are awakened 352

6.2.9 process B switches to process a for execution 354

6.3 conclusion 356

Chapter 2 IPC question 7th

7.1 MPs 358

7.1.1 apply for idle items for MPs queue files in the file management table. 360

7.1.2 create conditions for establishing connections between MPs queue files and processes 360

7.1.3 create an MPS queue file I node 361

7.1.4 connect the pipeline file I node to the file management table 362

7.1.5 return the MPs queue file handle to user process 363

7.1.6 the read pipeline process starts to operate pipeline files 363

7.1.7 the write pipeline process writes data to the pipeline 364

7.1.8 the write pipeline process continues to write data to the pipeline 366

7.1.9 the MPs queue writing process has filled up the MPs queue space by 366.

7.1.10 write pipeline process suspended 366

7.1.11 the read pipeline process reads data from the pipeline 367

7.1.12 the read pipeline process continues to execute and reads 369 data from the pipeline.

7.1.13 clock interruption during execution of the read pipeline process 369

7.1.14 the clock is interrupted again during the execution of the read pipeline process by 370.

7.1.15 the read pipeline process switches to the write pipeline process and runs 371

7.1.16 the write pipeline process is suspended and switched to the read pipeline process for execution 371

7.1.17 the read pipeline process continues until the data in the pipeline is read 372

7.1.18 after reading is complete, the read process is suspended and the write process continues to execute 373

7.2 signal mechanism 374

7.2.1 processig process starts to execute 376

7.2.2 The processig process enters the stoppedwait status 377

7.2.3 The sendsig process starts execution and sends a 379 signal to the processig Process

7.2.4 The system detects the signal received by the current process and prepares to process it 381

7.2.5 system detection signal processing function pointer mounting normal 382

7.2.6 adjust the kernel stack structure of the processig process to execute the signal processing function 383 first.

7.2.7 signal impact on process execution status 386

7.3 conclusion 393

Chapter 1 guiding ideology of operating system design 8th

8.1 run the simplest program and check what the operating system does for the program running 395

8.2 operating system design guiding ideology-master-slave mechanism 398

8.2.1 process and Process Creation Mechanism in the master slave mechanism 399

8.2.2 master-slave mechanism of the operating system in memory management 400

8.2.3 master-slave mechanism embodied in the file system 401

8.3 three key technologies for implementing the master-slave mechanism 402

8.3.1 protection and paging 402

8.3.2 privileged level 405

8.3.3 interruption 405

8.4 decisive factor for establishing the primary slaves-lead 407

8.5 relationship between software and hardware: Host and process, peripherals and files 408

8.5.1 non-user process-process 0, process 1, Shell Process 408

8.5.2 file and data storage 409

8.6 parent-child process sharing page 414

8.7 global interruption of the operating system and local interruption of the process-signal 414

8.8 conclusion 415

Conclusion 415

Introduction to the new design team 416

Appendix build Linux 0.11 system environment 421

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.