The state field in the process descriptor describes the current state of the process, which consists of a group of signs, each of which describes a possible state of the process, these States are mutually exclusive, that is, at the same time, only one status can be set.
I. Running status: task_running. The process either runs on the CPU or is ready to run.
2. interrupted waiting status: task_interruptible. The process is suspended until it receives a message and wakes up the process.
3. Non-disruptive Wait Status: task_uninterruptible. When the waiting condition is true, the status of the current process cannot be changed.
4. paused status: task_stopped. When a paused process receives a paused signal, it enters the paused status.
5. Tracking status: task_traced. The process is executed by the debuggerProgramPaused. When a process is monitored by another process, any signal can set this process to the tracking status.
Two other States can be stored in the state field of the Process descriptor or in the exit_state field. The names of the two processes show that only when the process is terminated, only in these two statuses
6. Dead state: exit_zombie. The execution of the process is terminated. However, the parent process has not released the wait4 () and waitpid () system calls to return information about the dead process. Previously, the kernel cannot discard data contained in the dead process descriptor, and the parent process may need it
7. Zombie revocation status: exit_dead, final state. The parent process has released wait4 () and waitpid () system calls, so the system is deleted by the system, in order to prevent other execution threads from executing wait () system calls on the same process, the state of the process is changed from dead state to dead state.
The value of the state field is usually set by a simple value assignment statement:
P-> state = task_running;
The kernel also uses the set_task_state and set_current_state () macros, which respectively set the status of the specified process and the status of the current process. O macro