Process state is the state field in the process descriptor.
A process descriptor is a task_struct-type data structure whose fields contain all of the information about a single process. A process, also referred to as a task, is an instance of a program in execution.
A data structure is a way of storing data in a computer so that it can be used efficiently. task_struct is a relatively large data structure (roughly 1.7 kilobytes on a 32-bit machine) that is designed to hold all the information that the kernel (i.e., the core of the operating system) has and needs about a process.
The state field in the process descriptor describes what is currently happening to a process. This field contains one of the following five flags (i.e., values):
TASK_RUNNING: The process is runnable, and it is either currently running or it is on a runqueue waiting to run. This is the only possible state for a process executing in user space (i.e., that portion of system memory in which user processes run); it can also apply to a process in kernel space (i.e., that portion of memory in which the kernel executes and provides its services) that is actively running. A runnable process is a process that is in the TASK_RUNNING process state.
A runqueue is the basic data structure in the scheduler, and it contains the list of runnable processes for the CPU (central processing unit), or for one CPU on a multiprocessor system. The scheduler, also called the process scheduler, is a part of the kernel that allocates the scare CPU time among the various runnable processes on the system.
TASK_INTERRUPTIBLE: The process is sleeping (i.e., blocked), waiting for some condition to exist or for some signal to arrive. When this condition occurs or the signal arrives, the kernel sets the process's state to TASK_RUNNING.
A signal is a very short message that can be sent to a process, or to a group of processes, that contains only a number identifying the signal. It permits interaction between user mode processes and allows the kernel to notify processes of system events. A signal can make a process aware that a specific event has occurred, and it can force a process to execute a signal handler function included in its code. Processes in user mode are forbidden to access those portions of memory that have been allocated to the kernel or to other programs.
TASK_UNINTERRUPTIBLE: This is identical to TASK_INTERRUPTIBLE except that the process will not awaken and become runnable if it receives a signal. It is used in situations in which the process must wait without interruption or when the event is expected to occur very quickly. This flag is used less frequently than TASK_INTERRUPTIBLE because of its lack of response to signals.
TASK_ZOMBIE: The process has terminated, but its parent process (i.e., the process that spawned it) has not yet issued a wait4() system call. The task's process descriptor must persist in case the parent desires to access it. If the parent process calls the wait4() system call, the process descriptor is deallocated.
A system call is a request made via a software interrupt by an active process for a service performed by the kernel. The wait4() system call tells the operating system to suspend execution of that process until another process has been completed. An interrupt is a signal to the kernel that an event has occurred, and this results in changes in the sequence of instructions that is executed by the CPU. A software interrupt, also referred to as an exception, is an interrupt that originates in software, usually by a program in user mode.
TASK_STOPPED: Process execution has stopped; the process is not running nor is it eligible to run. This state occurs if the process receives the SIGSTOP, SIGTSTP, SIGTTIN or SIGTTOU signal (whose default action is to stop the process to which they are sent) or if it receives any signal while it is being debugged.
Created July 20, 2005.