Wait (operating system)
Encyclopedia
In modern computer
Computer
A computer is a programmable machine designed to sequentially and automatically carry out a sequence of arithmetic or logical operations. The particular sequence of operations can be changed readily, allowing the computer to solve more than one kind of problem...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s, a process
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...

 (or task) may wait on another process to complete its execution. In most systems, a parent process
Parent process
In computing, a parent process is a process that has created one or more child processes.- Unix :In the operating system Unix, every process except is created when another process executes the fork system call. The process that invoked fork is the parent process and the newly-created process is...

 can create an independently executing child process
Child process
A child process in computing is a process created by another process .A child process inherits most of its attributes, such as open files, from its parent. In UNIX, a child process is in fact created as a copy of the parent...

. The parent process may then issue a wait system call
System call
In computing, a system call is how a program requests a service from an operating system's kernel. This may include hardware related services , creating and executing new processes, and communicating with integral kernel services...

, which suspends the execution of the parent process while the child executes. When the child process terminates, it returns an exit status
Exit status
The exit status or return code of a process in computer programming is a small number passed from a child process to a parent process when it has finished executing a specific procedure or delegated task...

 to the operating system, which is then returned to the waiting parent process. The parent process then resumes execution.

Modern operating systems also provide system calls that allow process threads to create other threads and wait for them to terminate ("join" them) in a similar fashion.

An operating system may provide variations of the wait call that allow a process to wait for any of its children processes to exit
Exit (operating system)
On many computer operating systems, a computer process terminates its execution by making an exit system call. More generally, an exit in a multithreading environment means that a thread of execution has stopped running. The operating system reclaims resources that were used by the process...

, or to wait for a single specific child process (identified by its process-ID
Process identifier
In computing, the process identifier is a number used by most operating system kernels to uniquely identify a process...

) to exit.

Some operating systems issue a signal
Signal (computing)
A signal is a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. Essentially it is an asynchronous notification sent to a process in order to notify it of an event that occurred. When a signal is sent to a process, the operating system...

 (SIGCHLD
SIGCHLD
On POSIX-compliant platforms, SIGCHLD is the signal sent to a process when a child process terminates. The symbolic constant for SIGCHLD is defined in the header file signal.h. Symbolic signal names are used because signal numbers can vary across platforms....

) to the parent process when a child process terminates, notifying the parent process and allowing it to then retrieve the child process's exit status.

The exit status
Exit status
The exit status or return code of a process in computer programming is a small number passed from a child process to a parent process when it has finished executing a specific procedure or delegated task...

 returned by a child process typically indicates whether the process terminated normally or abnormally
Abnormal end
An ABEND is an abnormal termination of software, or a program crash.This usage derives from an error message from the IBM OS/360, IBM zOS operating systems. Usually capitalized, but may appear as "abend"...

. For normal termination, this status also includes the exit code (usually a small integer value) that the process returned to the system.

A child process that terminates but is never waited on by its parent becomes a zombie process
Zombie process
On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the process to read its exit status. The term zombie process...

. Such a process continues to exist as an entry in the system process table even though it is no longer an actively executing program. Such situations are typically handled with a special "reaper" process that locates zombies and retrieves their exit status, allowing the operating system to then deallocate their resources.

Similarly, a child process whose parent process terminates before it does becomes an orphan process
Orphan process
An orphan process is a computer process whose parent process has finished or terminated, though itself remains running.In a Unix-like operating system any orphaned process will be immediately adopted by the special init system process. This operation is called re-parenting and occurs automatically...

. Such situations are typically handled with a special "root" (or "init") process, which is assigned as the new parent of a process when its parent process exits. This special process detects when an orphan process terminates and then retrieves its exit status, allowing the system to deallocate the terminated child process.

See also

  • Exit (operating system)
    Exit (operating system)
    On many computer operating systems, a computer process terminates its execution by making an exit system call. More generally, an exit in a multithreading environment means that a thread of execution has stopped running. The operating system reclaims resources that were used by the process...

  • Fork (operating system)
    Fork (operating system)
    In computing, when a process forks, it creates a copy of itself. More generally, a fork in a multithreading environment means that a thread of execution is duplicated, creating a child thread from the parent thread....

  • Sleep (operating system)
    Sleep (operating system)
    A computer program may sleep, which places it into an inactive state for a period of time. Eventually the expiration of an interval timer, or the receipt of a signal or interrupt causes the program to resume execution.- Usage :...

  • Spawn (computing)
    Spawn (computing)
    Spawn in computing refers to a function that loads and executes a new child process.The current process may or may not continue to execute asynchronously...

  • Wait (command)
  • Wait state
    Wait state
    A wait state is a delay experienced by a computer processor when accessing external memory or another device that is slow to respond.As of late 2011, computer microprocessors run at very high speeds, while memory technology does not seem to be able to catch up: typical PC processors like the Intel...

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK