"Linux" Linux process status

Source: Internet
Author: User

There are 5 states of processes on Linux:
1. Running (running or waiting in the running queue)
2. Interrupt (dormant, blocked, waiting for a condition to form or receive a signal)
3. Non-interruptible (receive signal does not wake up and not run, process must wait until interrupt occurs)
4. Zombie (The process has been terminated, but the process descriptor exists until the parent process calls WAIT4 () after the system call is released)
5. Stop (process received Sigstop, SIGSTP, Sigtin, Sigtou signal after stop running run)

PS Tool identifies 5 status codes for the process:
D non-interruptible uninterruptible sleep (usually IO)
R run runnable (on run queue)
S Interrupt Sleeping
T stop traced or stopped
Z Zombie a defunct ("zombie") process

R: Executable state

Only processes in that state are likely to run on the CPU. At the same time, multiple processes may be in the executable state, and the TASK_STRUCT structure (Process Control block) of those processes is placed in the corresponding CPU's executable queue (a process can only appear in the executable queue of one CPU). The task of the Process scheduler is to select a process from each CPU's executable queue to run on that CPU separately.

Many operating system textbooks define a process that is executing on the CPU as a running state, while a process that is executable but not yet scheduled to execute is defined as a ready state, both of which are unified to the Task_running state under Linux.

S: An interruptible sleep state

A process in this state is suspended because it waits for a certain event to occur (such as waiting for a socket connection, waiting for a semaphore). The TASK_STRUCT structure of these processes is placed in the waiting queue for the corresponding event. When these events occur (triggered by an external interrupt or triggered by another process), one or more processes in the corresponding wait queue will be awakened.

With the PS command we will see that, in general, most of the processes in the process list are in the Task_interruptible state (unless the machine is under a high load). After all, the CPU is so one or two, the process is almost dozens of hundred, if not most of the process is in sleep, the CPU how to respond to come over.

D: Non-disruptive sleep status

Like the task_interruptible state, the process is asleep, but the process is non-disruptive at the moment. Non-interruptible means that the CPU does not respond to interrupts from external hardware, but rather that the process does not respond to asynchronous signals. In most cases, the process should always be able to respond to an asynchronous signal when it is in a sleep state. However, the uninterruptible sleep state process does not accept any external signals, so it is not possible to kill these processes in the D state with kill, either "kill", "Kill-9″ or" Kill-15″, in which case An alternative approach is to reboot.

The process that is in the uninterruptible sleep state is usually waiting for IO, such as disk IO, network IO, other peripheral io, if the process is waiting for the IO to not respond for a long time, then it is seen by PS, and it means that there is probably an IO problem, It may be that the peripheral itself has failed, or it may be that the remote file system being mounted is inaccessible.

Z: Exit status, Process becomes zombie process

In the state of the Linux process, the zombie process is a very special one, it is the process that has ended, but it is not removed from the process table. Too much will cause the entries in the process table to be full, causing the system to crash, rather than consuming other system resources.

It has given up almost all memory space, no executable code, no scheduling, just a location in the list of processes, a record of the process's exit status and other processes to collect, in addition, the zombie process no longer occupies any memory space.

The process is in the Task_dead state during the exit process. In this exit process, all the resources that the process occupies will be recycled, in addition to the TASK_STRUCT structure (and a few resources). So the process is only task_struct such an empty shell, so called zombies

"Linux" Linux process status

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.