In a
multitasking computer system,
processes
A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic.
Things called a process include:
Business and management
*Business process, activities that produce a specific se ...
may occupy a variety of
states. These distinct states may not be recognized as such by the
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine lea ...
. However, they are a useful abstraction for the understanding of processes.
Primary process states
The following typical process states are possible on computer systems of all kinds. In most of these states, processes are "stored" on
main memory
Computer data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processing unit (CPU) of a comput ...
.
Created
When a process is first created, it occupies the "created" or "new" state. In this state, the process awaits admission to the "ready" state. Admission will be approved or delayed by a long-term, or admission,
scheduler. Typically in most
desktop computer
A desktop computer (often abbreviated desktop) is a personal computer designed for regular use at a single location on or near a desk due to its size and power requirements. The most common configuration has a case that houses the power supply ...
systems, this admission will be approved automatically. However, for
real-time operating system
A real-time operating system (RTOS) is an operating system (OS) for real-time applications that processes data and events that have critically defined time constraints. An RTOS is distinct from a time-sharing operating system, such as Unix, which ...
s this admission may be delayed. In a realtime system, admitting too many processes to the "ready" state may lead to oversaturation and
overcontention of the system's resources, leading to an inability to meet process deadlines.
Ready
A "ready" or "waiting" process has been loaded into
main memory
Computer data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processing unit (CPU) of a comput ...
and is awaiting execution on a
CPU
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, an ...
(to be context switched onto the CPU by the dispatcher, or short-term scheduler). There may be many "ready" processes at any one point of the system's execution—for example, in a one-processor system, only one process can be executing at any one time, and all other "concurrently executing" processes will be waiting for execution.
A ''ready queue'' or
run queue is used in
computer scheduling. Modern computers are capable of running many different programs or processes at the same time. However, the CPU is only capable of handling one process at a time. Processes that are ready for the CPU are kept in a
queue __NOTOC__
Queue () may refer to:
* Queue area, or queue, a line or area where people wait for goods or services
Arts, entertainment, and media
*''ACM Queue'', a computer magazine
* ''The Queue'' (Sorokin novel), a 1983 novel by Russian author ...
for "ready" processes. Other processes that are waiting for an event to occur, such as loading information from a hard drive or waiting on an internet connection, are not in the ready queue.
Running
A process moves into the running state when it is chosen for execution. The process's instructions are executed by one of the CPUs (or cores) of the system. There is at most one running process per
CPU
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, an ...
or core. A process can run in either of the two modes, namely ''kernel mode'' or ''user mode''.
Kernel mode
* Processes in kernel mode can access both: kernel and user addresses.
* Kernel mode allows unrestricted access to hardware including execution of ''privileged'' instructions.
* Various instructions (such as
I/O instructions and halt instructions) are ''privileged'' and can be executed only in kernel mode.
* A
system call
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
from a user program leads to a switch to kernel mode.
User mode
* Processes in user mode can access their own instructions and data but not kernel instructions and data (or those of other processes).
* When the computer system is executing on behalf of a user application, the system is in user mode. However, when a user application requests a service from the
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
(via a
system call
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
), the system must transition from user to kernel mode to fulfill the request.
* User mode avoids various catastrophic failures:
** There is an isolated
virtual address space
In computing, a virtual address space (VAS) or address space is the set of ranges of virtual addresses that an operating system makes available to a process. The range of virtual addresses usually starts at a low address and can extend to the hig ...
for each process in user mode.
** User mode ensures isolated execution of each process so that it does not affect other processes as such.
** No direct access to any hardware device is allowed.
Blocked
A process transitions to a
blocked state when it cannot carry on without an external change in state or event occurring. For example, a process may block on a call to an I/O device such as a printer, if the printer is not available. Processes also commonly block when they require user input, or require access to a
critical section
In concurrent programming, concurrent accesses to shared resources can lead to unexpected or erroneous behavior, so parts of the program where the shared resource is accessed need to be protected in ways that avoid the concurrent access. One way ...
which must be executed atomically. Such critical sections are protected using a synchronization object such as a semaphore or mutex.
Terminated
A process may be
terminated, either from the "running" state by completing its execution or by explicitly being killed. In either of these cases, the process moves to the "terminated" state. The underlying program is no longer executing, but the process remains in the
process table as a ''
zombie process
On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution (via the exit system call) but still has an entry in the process table: it is a process in the " Terminated state ...
'' until its parent process calls the
wait
Wait or WAIT may refer to:
Music
* Wait (musician), British town pipers
Albums and EPs
* ''Wait'' (The Polyphonic Spree EP), by The Polyphonic Spree
* ''Wait'' (Emanuel Nice EP), a 2002 EP released by the band Emanuel Nice
* ''Wait'' (Stee ...
system call
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
to read its
exit status
The exit status of a process in computer programming is a small number passed from a child process (or callee) to a parent process (or caller) when it has finished executing a specific procedure or delegated task. In DOS, this may be referre ...
, at which point the process is removed from the process table, finally ending the process's lifetime. If the parent fails to call
wait
, this continues to consume the process table entry (concretely the
process identifier
In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernels—such as those of Unix, macOS and Windows—to uniquely identify an active process. This number may be used as a parameter in vario ...
or PID), and causes a
resource leak
In computer science, a resource leak is a particular type of resource consumption by a computer program where the program does not release resources it has acquired. This condition is normally the result of a bug in a program. Typical resource lea ...
.
Additional process states
Two additional states are available for processes in systems that support
virtual memory
In computing, virtual memory, or virtual storage is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very ...
. In both of these states, processes are "stored" on secondary memory (typically a
hard disk
A hard disk drive (HDD), hard disk, hard drive, or fixed disk is an electro-mechanical data storage device that stores and retrieves digital data using magnetic storage with one or more rigid rapidly rotating platters coated with mag ...
).
Swapped out and waiting
(Also called suspended and waiting.) In systems that support virtual memory, a process may be swapped out, that is, removed from main memory and placed on external storage by the scheduler. From here the process may be swapped back into the waiting state.
Swapped out and blocked
(Also called suspended and blocked.) Processes that are blocked may also be swapped out. In this event the process is both swapped out and blocked, and may be swapped back in again under the same circumstances as a swapped out and waiting process (although in this case, the process will move to the blocked state, and may still be waiting for a resource to become available).
See also
*
ps (Unix)
In most Unix and Unix-like operating systems, the ps program (short for "process status") displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes.
Implementations
KolibriOS ...
References
*
:Particularly chapter 3, section 3.2, "process states", including figure 3.9 "process state transition with suspend states"
{{DEFAULTSORT:Process States
Process (computing)