Process Management of Linux kernel series-general Linux technology-Linux programming and kernel information. The following is a detailed description. Process concept: running a program is called a process. The process uses task_struct to indicate its own information. Pid, various linked lists, statuses, Kernel stack SP, address space allocation, file descriptors, and other resource allocation conditions, time slices, process statistics, etc.
Kernel state and user State: in protection mode, the process running state is divided into user State and kernel state. The address space of a process is 4 GB (32 bitsOS), and the highest 1 GB is the kernel data ing shared by each process. User-State processes can only access user address space data (less than 3 GB), and kernel-State processes can access all address spaces. The process uses the segment page to manage virtual memory. The base address (0) of the corresponding kernel segment in GDT is different from the base address (3G) of the user segment. Determine whether the process is a kernel-state or user-state process based on the value of the segment descriptor (CS, DS. A user-state process can only access the address space of the process and use the user-state stack. A kernel-state process can access the kernel stack (on the same physical page as task_struct) and user-state stack.
Switching Process status: switching from user State to kernel state is called switching. The cause is system calls and interruptions. When the system calls user interruption, the page table switches to the new process page table, CS/SP switches to the Kernel Status segment selection character, IP switches to the target address of the system call, and switches through the iRet command.
Process switching: Based on the scheduling algorithm, if the time slice of the process is used up when the process is returned from an interruption or system call, a process switching will occur. The newly selected process occupies the CPU, CS, mm, and SS stacks are replaced with the new process environment. It should be noted that the processes running in the kernel state cannot be switched out, and the time for switching to the city is only when the current process is switched from the kernel state to the user State (such as interruption and system call)
Signal: the signal information is stored in task_struct. The sending signal (kill) updates the task_struct of the target process, but only when the user State is returned from the kernel state, to check and process the process's signal queue.
Process relationship: processes such as parent-child relationship and Process status are added to various linked lists. Process 0 is the init process and the parent process of all orphan processes.
Inter-process communication: Signal-directly modify task_struct; file ing-linear address ing on the same physical page; pipe: pipe file system, which enters the kernel through the file system API; System V shares memory, signal lamp, message queue: kernel data structure
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:
info-contact@alibabacloud.com
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