2019-2020-1 20199302 "Linux kernel principle and Analysis" in the seventh week of work

The sixth chapter describes the process of creation and processes

Description (a) process

1, the OS management three functions: (1) Management Process (Process) (2) Memory Management (virtual memory) (3) file system (files)
described in 2, the process: the process control block the PCB
3, the Linux kernel , struct task_struct describe the process in which the state variables for the process status, stack is the stack. Structural relations: the state of the process, the process of two-way linked list management, describing console tty, file system fs, the process open file descriptors: description signal and other signals between files, memory management description mm, the process of communication.
4, the main difference between the process and the state of Linux operating system process state that in principle, Linux kernel ready state and run state have
been called TASK_RUNNING, divided into two in the process of blocking state, one is TASK_INTERUPTIBLE, can the signal and wake_up () wake up, the other is TASK_UNINTERUPTIBLE only be wake_up () wake. i

identifier 5, the PID of the process, the process descriptor identifying the process with pid and tgid.
6, doubly linked list struct list_head tasks for managing process data structure.

Creating (b) process

1, init_task first process is a process (process number 0) is described structure variable, which is initialized by the hardcoded fixed manner, while other processes are initialized by means of initialization copying do_fork the parent process.
2, memory management-related code.
mm and are active_mm and process address space, memory management related data structure pointer, comprising a plurality of data segments, the code segment, a stack segment.
3, the process between father and son, brother relationship
struct task_struct data structure recorded in the parent process real_parent the current process, parent, child process of recording the current process is doubly linked list of struct list_head children, brothers recorded the current process is doubly linked list of struct list_head sibling. Between the father and his sons complex chain relationships are associated through a pointer or two-way linked list.
4, some of the data structure associated CPU state information stored process context
struct data structure of thread_struct save some state information in the context of a process related to the CPU. The most important is the sp and ip, in x86-32 bit system, sp ESP register is used to save the state of the process context, ip EIP machine registers to save state of the process context.
5, the process of creation and analysis process
of the creating process is probably the current process descriptor and other related resources copy process, produce a child process, the child process needed to replicate the process descriptor to make some changes, and then create good child process into the run queue (corresponding to the operating system ready queue).

(C) analysis of process creation process


MenuOS to add a breakpoint, respectively, in sys_clone do_fork dup_task_struct copy_process``copy_thread at the


input fork found parked at sys_clone at the command line, indicating that the system call function is sys_clone continue to be parked in the do_fork

Guess you like

Origin www.cnblogs.com/eosmomo/p/11784233.html