Abstract:This topic describes process resources and status. process resources are composed of two parts: kernel space process resources and user space process resources. process status, ready/running status, waiting status (can be interrupted), waiting status (cannot be interrupted), stopping status and freezing status.
1. process Resource process is the basic unit of resource management in Linux. Each process has its own operating space. in order to better manage the resources accessed by Linux, the system introduces the concept of process control (PCB), the PCB structure.
Process resources are composed of two parts: kernel space process resources and user space process resources.
Kernel space process resources: PCB-related information. including process control block itself, open file table items, current directory, current terminal information, thread basic information, accessible memory address, PID, ppid, uid, EUID, etc, that is to say, the kernel can access all resources of the process through PCB. these resources can only be accessed through system calls. after a process exits, resources are reclaimed by another process.
User space process resources: memory space mapped by the mm_struct member. the essence is the code segment, data segment, heap, stack, and memory space of the shared database of the process. these resource processes can directly access. actively released when the process exits. during the process, you can use the file/proc/{pid}/maps to Create accessible address spaces.
2. process status one of the three illusion of life: QQ, storm audio and video, browsers, etc. can run together, is the process running in parallel. neither. for a single CPU system, only one process can be in the running state at a certain time, occupying the right to use the CPU. All other processes are in another State, waiting for system resources, each process continuously switches between certain States based on the scheduling algorithm. however, due to the high CPU processing efficiency, users cannot feel the changes.
In the linux2.6 kernel, user-level processes have the following statuses: Ready/running, waiting (can be interrupted), waiting (cannot be interrupted), stop, and dead.
Task_running: running or in the ready state: the ready state means that the process has applied for all resources other than the CPU. It is called: everything is ready, and it is not enough. note: In general operating system textbooks, processes that are being executed on the CPU are defined as running, while processes that are executable but not yet scheduled are defined as ready, these two statuses are in the task_running state in Linux.
Task_interruptible: In the waiting team, wake up when the resource is valid (such as waiting for keyboard input, socket connection, signal, etc.), but can be interrupted to wake up. generally, most processes in the process list are in the task_interruptible state. after all, the emperor has only one (single CPU), and The hougong jiali is several thousand; if not most processes are sleeping, how can the CPU respond.
Task_uninterruptible: In the waiting team, wake up when the resources are valid (such as waiting for keyboard input, socket connection, signal, etc.), but cannot be interrupted to wake up.
Task_zombie: The process resource user space is released, but the process PCB in the kernel is not released, waiting for the parent process to be recycled.
Task_stopped: the process is paused by an external program. (If the sigstop signal is received, the process enters the task_stopped status.) The process continues to run when it is allowed again (the process receives the sigcont signal and enters the task_running status ), therefore, a process in this status can be awakened.
The status switching relationship between user-level processes is shown in figure 2.
Figure 2 user Process status Switching
Author: my personal abilities are limited, just for reference. If the reader finds any errors in this article, please submit them.
--
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Do not build a high station in the sand float, calm down and slowly accumulate -----------------------------------------Certificate ----------------------------------------------------------------------------------------------------------------------------------------------------------
Process Resource and Process status task_running task_interruptible task_uninterruptible