Process (computing)
From Wikipedia, the free encyclopedia
In computing, a process is an instance of a computer program that is being executed. While a program itself is just a passive collection of instructions, a process is something which actually executes those instructions. Several processes can be associated with the same program - each would execute independently. Modern computer systems allow multiple processes to be loaded into memory at the same time and, through time-sharing (or multitasking), give an appearance that they are being executed at the same time even if there is just one processor.
Contents |
[edit] Overview
In general, a computer system process consists of (or is said to 'own') the following resources:
- An image of the executable machine code associated with a program.
- Memory (typically some region of virtual memory and/or real memory), which contains the executable code and process-specific data, including a call stack (to keep track of active subroutines), and a heap holding data generated during run time.
- Operating system descriptors of resources that are allocated to the process, such as file descriptors (Unix terminology) or handles (Windows).
- Security attributes, such as the process owner and the process' set of permissions.
- Processor state (context), such as the content of registers, physical memory addressing, etc. The state is typically stored in computer registers when the process is executing, and in memory otherwise.[1]
The operating system holds most of this information about active processes in data structures called process control blocks (PCB).
Any subset of resources, but typically at least the processor state, may be associated with each of the process' threads in operating systems that support threads or 'daughter' processes.
The operating system keeps its processes separated and allocates the resources they need so that they are less likely to interfere with each other and cause system failures (e.g., deadlock or thrashing). The operating system may also provide mechanisms for inter-process communication to enable processes to interact in safe and predictable ways.
[edit] Threads
In modern operating systems, each process can have several threads of execution (or threads for short). Multiple threads share the same program code, operating system resources (such as memory and file access) and operating system permissions (for file access as the process they belong to). A process that has only one thread is referred to as a single-threaded process, while a process with multiple threads is referred to as a multi-threaded process. Multi-threaded processes have the advantage that they can perform several tasks concurrently without the extra overhead needed to create a new process and handle synchronised communication between these processes. For example a word processor could perform a spell check as the user types, without freezing the application - one thread could handle user input, while another runs the spell checking utility.[1]
[edit] Process states
Processes go through various process states which determine how the process is handled by the operating system kernel. The specific implementations of these states vary in different operating systems, and the names of these states are not standard, but the general high-level functionality is the same.[1]
When a process is created, it needs to wait for the process scheduler (of the operating system) to set its status to "waiting" and load it into main memory from secondary storage device (such as a hard disk or a CD-ROM). Once the process has been assigned to a processor by a short-term scheduler, a context switch is performed (loading the process into the processor) and the process state is set to "running" - where the processor executes its instructions. If a process needs to wait for a resource (such as waiting for user input, or waiting for a file to become available), it is moved into the "blocked" state until it no longer needs to wait - then it is moved back into the "waiting" state. Once the process finishes execution, or is terminated by the operating system, it is moved to the "terminated" state where it waits to be removed from main memory.[1][2]
[edit] Process management in multitasking operating systems
A multitasking operating system may just switch between processes to give the appearance of many processes executing concurrently or simultaneously, though in fact only one process can be executing at any one time on a single-core CPU.[3]
It is usual to associate a single process with a main program, and 'daughter' ('child') processes with any spin-off, parallel processes, which behave like asynchronous subroutines. A process is said to own resources, of which an image of its program (in memory) is one such resource. (Note, however, that in multiprocessing systems, many processes may run off of, or share, the same reentrant program at the same location in memory— but each process is said to own its own image of the program.[citation needed])
Processes are often called tasks in embedded operating systems.[citation needed] The sense of 'process' (or task) is 'something that takes up time', as opposed to 'memory', which is 'something that takes up space'.[citation needed] (Historically, the terms 'task' and 'process' were used interchangeably, but the term 'task' seems to be dropping from the computer lexicon.)[citation needed]
The above description applies to both processes managed by an operating system, and processes as defined by process calculi.
If a process requests something for which it must wait, it will be blocked. When the process is in the Blocked State, it is eligible for swapping to disk, but this is transparent in a virtual memory system, where blocks of memory values may be really on disk and not in main memory at any time. Note that even unused portions of active processes/tasks (executing programs) are eligible for swapping to disk. All parts of an executing program and its data do not have to be in physical memory for the associated process to be active.
[edit] Inter-process communication
Processes can communicate with each other via Inter-process communication (IPC). This is possible for both processes running on the same machine and on different machines.
[edit] History
- See also: History of operating systems
By the early 60s computer control software had evolved from Monitor control software, e.g., IBSYS, to Executive control software, making it possible to do multiprogramming. Multiprogramming is a rudimentary form of multiprocessing in which several programs are run "at the same time" (i.e., concurrently) on a single uniprocessor. That is, several programs are allowed to share the CPU- a scarce resource. Since there was only one processor, there was no true simultaneous execution of different programs. Instead, the later computer 'monitor-type' control software (known by then also as 'Executive' systems), and early "operating systems," typically allowed execution of part of one program until it was halted by some missing resource (e.g., input), or until some slow operation (e.g., output) had completed. At that point, a second (or nth) program was started or restarted. To the user it appeared that all programs were executing "at the same time" (hence the term, concurrent).
Shortly thereafter, the notion of a 'program' was expanded to the notion of an 'executing program and its context,' i.e., the concept of a process was born.[citation needed] Threads came somewhat later.[citation needed] However, with the advent of time-sharing; computer networks; multiple-CPU, shared memory computers; etc., the old "multiprogramming" gave way to true multitasking, multiprocessing and, later, multithreading.[citation needed]
[edit] See also
- Child process
- Exit
- Fork
- Orphan process
- Parent process
- Process states
- Task
- Thread
- Wait
- Zombie process
[edit] References and notes
- ^ a b c d SILBERSCHATZ, Abraham; CAGNE, Greg, GALVIN, Peter Baer (2004). "Chapter 4", Operating system concepts with Java, Sixth Edition, John Wiley & Sons, Inc.. ISBN 0-471-48905-0.
- ^ Stallings, William (2005). Operating Systems: internals and design principles (5th edition). Prentice Hall. ISBN 0-13-127837-1.
- Particularly chapter 3, section 3.2, "process states", including figure 3.9 "process state transition with suspend states"
- ^ Some modern CPUs combine two or more independent processors and can execute several processes simultaneously - see Multi-core for more information. Another technique called simultaneous multithreading (used in Intel's Hyper-threading technology) can simulate simultaneous execution of multiple processes or threads.