Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the status of the linux process

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "what is the state of the linux process?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what is the state of the linux process?"

There are five states: 1, executable state; 2, interruptible waiting state; 3, uninterruptible waiting state; 4, stop state; 5, aborted state. The state value of "executable state" is TASK_RUNNING, at which time the program has been linked to the running queue and is ready to run. Once the right to use the processor is obtained, it can enter the running state.

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

An instance of a special data structure defined by the operating system and controlled by the operating system is called a process. It connects the user code, has the independent memory space needed for the code to run, and runs using the processor time slice allocated to it under the schedule of the scheduler.

Five states of the Linux process

In a Linux system, after a process is created, there can be five states in the system. The current state of the process is recorded in the state member of the process control block.

Ready state and running state (executable state)

The value of the state flag state for the ready state is task _ RUNNING. At this point, the program has been hung into the running queue and is ready to run. Once you have obtained the right to use the processor, you can enter the running state.

When a process gets a processor and runs, the value of state remains the same as TASK_RUNNING, but Linux points a pointer to the currently running task, current, to it to indicate that it is a running process.

Interruptible waiting state

The value of the status flag state is task _ INTERRUPTIBL. At this point, the process is waiting because it did not get the resource it requested. Once the resource is available or there is a wake-up signal, the process immediately ends waiting and enters the ready state.

Uninterruptible waiting state

The value of the status flag state is task _ UNINTERRUPTIBL. At this point, the process is also in a state of waiting for resources. Once the resource is available, the process immediately enters the ready state. The difference between this wait state and interruptible wait state is that a process in TASK_UNINTERRUPTIBL state cannot be awakened by semaphores or interrupts, but can only be awakened when its requested resource is valid.

This state is applied in some scenarios in the kernel, such as when the process needs to read and write to the disk and is copying data to memory in DMA, if the hibernation of the process is interrupted (such as a forced exit signal), then there is likely to be a problem, so the process will be in an uninterruptible state.

Stop state

The value of the status flag state is task _ STOPPED. When the process receives a SIGSTOP signal, it changes from the running state to the stopped state, and when it receives a SIGCONT signal, it will resume the running state. This state is mainly used for program debugging, also known as "paused state" and "suspended state".

Abort state

The value of the status flag state is task _ DEAD. The process stops running for some reason, all the resources occupied by the process will be reclaimed, except for the task_struct structure (and a few resources), and the system no longer pays attention to it, so this state is also called "zombie state", and the process becomes a zombie process.

It transitions between five states throughout the life cycle of a process. The transition relationship between the five states of the Linux process is shown in the following figure:

The above is about the content of this article on "what is the status of the linux process?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 294

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report