Article Title: TASK_KILLABLE: New Process status in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Linux? Kernel 2.6.25 introduces a new process state named TASK_KILLABLE, which is used to set the process to sleep. It can replace the valid but possibly unterminated TASK_UNINTERRUPTIBLE process state, and the TASK_INTERRUPTIBLE Process status that is easy to wake up but more secure. In 2002, the OpenAFS file system driver encountered a problem when it waited for the event to be interrupted after blocking all signals, and TASK_KILLABLE was launched as a result. This new sleep state allows TASK_UNINTERRUPTIBLE to respond to critical signals. In this article, the author will introduce the content in this regard, and discuss the changes related to the Linux kernel and the new APIs brought about by these changes in combination with the examples in 2.6.26 and earlier versions 2.6.18.
Like a file, the process is any UNIX? Basic elements of the operating system. A process is a dynamic entity that executes executable file commands. In addition to executing commands, processes sometimes manage open files, processor context, address space, and program-related data. The Linux kernel stores complete information about the process in the process descriptor. Its structure is defined as struct task_struct. You can view fields of struct task_struct in the Linux kernel source File include/linux/sched. h.
Process status
A process may experience a series of mutex States during its lifecycle. The kernel stores the status information of the process in the state field of struct task_struct.Figure 1 shows the transition between process states.
Let's take a look at the status of various processes:
● TASK_RUNNING: The process is currently running or waiting for scheduling in the running queue.
● TASK_INTERRUPTIBLE: the process is sleeping and waiting for some events. Processes can be interrupted by signals. After a signal is received or an explicit wake-up call is triggered, the process changes to the TASK_RUNNING status.
● TASK_UNINTERRUPTIBLE: The Process status is similar to TASK_INTERRUPTIBLE, but it does not process signals. It is not appropriate to interrupt a process in this State because it may be completing some important tasks. When the event it is waiting for occurs, the process will be explicitly awakened by the wake-up call.
● TASK_STOPPED: the process has been aborted and is not running and cannot be run. When receiving signals such as SIGSTOP and SIGTSTP, the process enters this state. After receiving the SIGCONT signal, the process becomes operational again.
● TASK_TRACED: The process enters this state when it is being monitored by other processes, such as the program being debugged.
● EXIT_ZOMBIE: the process has been terminated. It is waiting for its parent process to collect statistics about it.
● EXIT_DEAD: the final State (as its name ). When a process is deleted from the system, it enters this state because its parent process has collected all statistics through the wait4 () or waitpid () call.
● For more information about Process status transition, see the UNIX operating system design in the references section.
As mentioned above, the Process status TASK_UNINTERRUPTIBLE and TASK_INTERRUPTIBLE are both sleep. Now let's take a look at how the kernel sets the process to sleep.
[1] [2] [3] [4] Next page