Status of processes in linux

Source: Internet
Author: User
The status of processes in the linux system-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1. Process status description:

# Define TASK_RUNNING 0

# Define TASK_INTERRUPTIBLE 1

# Define TASK_UNINTERRUPTIBLE 2

# Define TASK_STOPPED 4

# Define TASK_TRACED 8

/* In tsk-> exit_state */

# Define EXIT_ZOMBIE 16

# Define EXIT_DEAD 32

/* In tsk-> state again */

# Define TASK_NONINTERACTIVE 64

# Define TASK_DEAD 128

Ii. Status Details:

1. TASK_RUNNING (running status ):

Indicates that the process is being executed by the CPU or is ready for scheduling by the scheduler at any time. If the process is not executed by the CPU at this time, it is in the ready state. When a process runs in the kernel code, we say it is in the kernel state. When a process is executing the user's own code, we say it is in the user State. When system resources are available, the process is awakened and enters the ready state, that is, the ready state. These statuses indicate the same method in the kernel and are called the TASK_RUNNING status. When a process is created, it is in the TASK_RUNNING state.

2. TASK_INTERRUPTIBLE ):

The process is in the waiting status and will not be scheduled for execution. Wait until the waiting resources are available (or wait for a condition to be true) or the system generates an interruption or the process receives a signal, the process is awakened and enters the ready state (TASK_RUNNING ).

3. TASK_UNINTERRUPTIBLE ):

The only difference between TASK_INTERRUPTINLE and TASK_INTERRUPTINLE is that a signal in this status cannot be awakened. This status is rarely used, but in some special cases (the process must wait until an event cannot be interrupted, the status of sending hard disk I/O requests and waiting for the completion of I/O, waiting for the input status of the TTY terminal, etc.). This status is very useful. For example, when a process opens a device file, its corresponding device driver starts to detect the corresponding hardware device. Before the probe is completed, the device driver cannot be interrupted. Otherwise, the hardware device is in an unpredictable state. It is usually used when the process needs to wait for or wait for events that are not disturbed quickly.

4. TASK_STOPPED (paused ):

When a process receives SIGSTOP, SIGTSTP, SIGTTIN, and SIGTTOU signals, it enters the TASK_STOPPED status. You can send a SIGCONT signal to it to convert the process to a running state. 5. TASK_TRACED (tracking status ):

The execution of the process has been suspended by the debugger program. When a process is monitored by another process (for example, when a debugger executes the ptrace () System Call to monitor a Test Program), any signal can place the process in the TASK_TRACED state.

6. TASK_NONINTERACTIVE (non-interactive sleep state ):

Speaking of task states, there is now a TASK_NONINTERACTIVE flag which is used to mark non-interactive sleeps. it shoshould be set alongside TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE in cases where the fact that a process is sleeping does not provide any information on whether it is interactive or not. its initial use is for processes waiting on pipe buffers; the idea is to keep batch tasks using pipes (such as kernel compiles) from looking more interactive than they are. (Toward)

This status is a process state introduced in 2.6.14. It is used to describe that a process is in a non-interactive sleep state. This status must be combined with the TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE status. It is used when a process is sleep and no information is provided whether it can interact or not. It was initially used when the process waited for the MPs queue buffer to prevent pipeline processes (such as kernel compilation) from gaining more or more interaction.

7. TASK_DEAD (dead state ):

Task_struct-> state = EXIT_DEAD is a special case. This new state is introduced to avoid confusion. EXIT_DEAD can only be used for the-> exit_state field. When a process exits (calls do_exit (), the state field is placed in the TASK_DEAD state.

8. EXIT_ZOMBIE (zombie process ):

The status is the value of the task_struct-> exit_state field, indicating that the process execution is terminated, but the server process has not released wait4 () or waitpid () the system calls to return information about dead processes. Before calling a wait () system, the kernel cannot discard the data contained in the dead process descriptor, because the parent process may need it to exit the process.

9. EXIT_DEAD (dead undo state ):

This status is also the value of the task_struct-> exit field, indicating the final state of the process. Because the parent process has just issued a wait4 () or waitpid () system call, the process is deleted by the system. To prevent other execution threads from executing wait () system calls in the same process, change the Process status from the dead state (EXIT_ZOMBIE) to the undo state (EXIT_DEAD ).

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.