0

I read this post about SIGKILL and was confused about the following statements:

only some system calls are interruptible, so the kernel internally marks the process as being in a special "dying" state until the system calls or I/O operations are resolved

...

Once any in-process kernel routines are resolved, the process state is changed from "dying" to "dead" and the kernel begins cleaning it up

But I can't find any confirmation on this in kernel sources. The task states are defined in linux/sched.h:

#define TASK_RUNNING            0x0000
#define TASK_INTERRUPTIBLE      0x0001
#define TASK_UNINTERRUPTIBLE    0x0002
#define __TASK_STOPPED          0x0004
#define __TASK_TRACED           0x0008
/* Used in tsk->exit_state: */
#define EXIT_DEAD               0x0010
#define EXIT_ZOMBIE             0x0020
#define EXIT_TRACE              (EXIT_ZOMBIE | EXIT_DEAD)
/* Used in tsk->state again: */
#define TASK_PARKED             0x0040
#define TASK_DEAD               0x0080
#define TASK_WAKEKILL           0x0100
#define TASK_WAKING             0x0200
#define TASK_NOLOAD             0x0400
#define TASK_NEW                0x0800
#define TASK_STATE_MAX          0x1000

And there are no any "dying" state neither in linux/sched.h nor in other scheduler files. Can someone clarify which exactly task state is used to mark task as "dying" while non-interruptible syscall?

NK-cell
  • 1,145
  • 6
  • 19

1 Answers1

0

From the answer to this SO question it would seem that "dying" state would correspond to the "uninterruptible sleep" state:

As noted in comments to the OP, a process status (STAT) of D indicates that the process is in an "uninterruptible sleep" state. In real-world terms, this generally means that it's waiting on I/O and can't/won't do anything - including dying - until that I/O operation completes.

Out of the states in linux/sched.h it would seem that TASK_UNINTERRUPTIBLE is the one corresponding to the uninterruptible sleep state. From the "Understanding Linux Process States" (Yogesh Babar):

An Uninterruptible sleep state is one that won't handle a signal right away. It will wake only as a result of awaited-upon resource becoming available or after a time-out occurs during that wait (if the time-out is specified when the process is put to sleep). The Uninterruptible state is mostly used by device drivers waiting for disk or network I/O. When the process is sleeping uninterruptibly, signals accumulated during the sleep are noticed when the process returns from the system call or trap. In Linux systems. the command ps -l uses the letter D in the state field (S) to indicate that the process is in an Uninterruptible sleep state. In that case, the process state flag is set as follows:

p->state = TASK_UNINTERRUPTABLE

Community
  • 1
  • 1
gstukelj
  • 2,291
  • 1
  • 7
  • 20