This is a creation in Article, where the information may have evolved or changed. # 1. Define # #所有代码都是在进程中执行的, we usually refer to the execution of a program as a process. Conversely, processes are used to describe the process of executing a program. As a result, programs and processes become a pair of interdependent concepts that describe the static and dynamic characteristics of a program, respectively. In addition, the process is a basic unit of resource allocation for the operating system. # 2. Derivation # #父进程 Subprocess # 3. Process identity pid# #进程的优先级和状态, virtual addresses, and various access rights, and so on, these details are saved in the process descriptor. Where the PID saved in the process descriptor is the unique identity of the process in the operating system. PID is a non-negative integer and sequential number, PID can be reused, when the process ID has reached the maximum, the kernel will find the idle process ID from scratch and use whichever is first found as the ID of the new process. In addition, the descriptor also contains the ID of the parent process of the current process (often referred to as the Ppid) go inside using the API provided by the OS in the standard library to view the PID and ppid:pid of the current process: =os. Getpid () Ppid: =os. The Getppid () PID is useful for programs other than the kernel. The kernel can efficiently convert the PID to the corresponding process descriptor. We can use the shell command (kill) to terminate a PID-corresponding process. You can also use a similar method to send a signal to a process. # 4. Process status # #每个进程在不同的时刻会有不同的状态, there are 6 possible states: operational status, interruptible sleep status, non-interruptible sleep status, suspended state or tracking status, zombie status, exit status. # # Operational Status: # #TASK_RUNNING, referred to as R process in this state, then he will be, immediately or on the CPU running. The timing of the run is indeterminate, which will be dispatched by the Scheduler # # interruptible sleep State: # #TASK_INTERRUPTIBLE, referred to as s when the process waits for an event to occur, it is in that state. Such a process will be placed in the waiting queue for the world. When an event occurs, one or more processes in the wait queue are awakened. # # Non-disruptive sleep status: # #TASK_UNINTTERRUPTIBLE, referred to as d the process in this state does not respond to any signal. More specifically, the signal sent to the process will not be passed until the process is transferred from this state. A process is typically waiting for a particular event in that state. such as the completion of waiting for synchronous I/O operations (disk I/O, etc.). I am able to interpret I/O as the processing of input and output information. # Pause State or Trace status: # #TASK_STOPPED或TASK_TRACED, referred to as t when sending a pause signal to the process, the process goes into that state unless the process is in a non-interruptible state of sleep. Sending a sigcont signal to a process that is currently paused causes the process to turn to a running state. A process that is in a tracked state pauses and waits for the process that tracks it to operate on him. The tracking state is very similar to the paused state. However, sending a sigcont signal to a process that is paused does not cause him to be restored. It can recover only if the debug process makes the appropriate system call or exits. # # Zombie Status: # #TASK_DEAD_EXIT_ZOMBIE The process that is in this state for the short name Z is going to end. Most of the resources that the process occupies are also reclaimed. However, some of the information has not been deleted, such as exit codes and some statistical information. This information is kept in mind that the parent process of the process may require them. Because the process principal is now deleted and only a shell is left, the state is called a zombie state. # # Exit Status: # #TASK_DEAD-exit_dead, abbreviated as x during process exit, it is possible that even the exit code and statistics are not required to be retained. This can be caused by explicitly letting the process's parent process ignore the SIGCHLD signal, or it may be that the process has been detached. Separation means that the parent and child processes run independently. The detached subroutine will no longer use and execute instructions in the code snippet shared with the parent process, but instead load a completely new program. In these cases, the process does not go into zombie state when exiting, but instead goes directly to the exit state. A process that is in an exiting state is immediately closed down cleanly. The resources he occupies will be automatically reclaimed by the system. # # Process Conversion: # #简单的来说, the status of the process is divided into two operational and non-operational states, due to the suspended state and tracking status is different, so it can be divided into 7 states! [1525933037.jpg] (https://static.studygolang.com/180510/e854ca4c148ba5e4b2098b57469930f5.jpg) 339 reads
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