Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Process (computing)

From Wikipedia, the free encyclopedia
Particular execution of a computer program
Program vs. Process vs.Thread
Scheduling,Preemption,Context Switching

Incomputing, aprocess is theinstance of acomputer program that is being executed by one or manythreads. There are many different process models, some of which are light weight, but almost all processes (even entirevirtual machines) are rooted in anoperating system (OS) process which comprises the program code, assigned system resources, physical and logical access permissions, and data structures to initiate, control and coordinate execution activity. Depending on the OS, a process may be made up of multiple threads of execution that execute instructionsconcurrently.[1][2]

While a computer program is a passive collection ofinstructions typically stored in a file on disk, a process is the execution of those instructions after being loaded from the disk into memory. Several processes may be associated with the same program; for example, opening up several instances of the same program often results in more than one process being executed.

Multitasking is a method to allow multiple processes to shareprocessors (CPUs) and other system resources. Each CPU (core) executes a single process at a time. However, multitasking allows each processor toswitch between tasks that are being executed without having to wait for each task to finish (preemption). Depending on the operating system implementation, switches could be performed when tasks initiate and wait for completion ofinput/output operations, when a task voluntarily yields the CPU, on hardwareinterrupts, and when the operating system scheduler decides that a process has expired its fair share of CPU time (e.g, by theCompletely Fair Scheduler of theLinux kernel).

A common form of multitasking is provided by CPU'stime-sharing that is a method for interleaving the execution of users' processes and threads, and even of independent kernel tasks – although the latter feature is feasible only in preemptivekernels such asLinux. Preemption has an important side effect for interactive processes that are given higher priority with respect to CPU bound processes, therefore users are immediately assigned computing resources at the simple pressing of a key or when moving a mouse. Furthermore, applications like video and music reproduction are given some kind of real-time priority, preempting any other lower priority process. In time-sharing systems,context switches are performed rapidly, which makes it seem like multiple processes are being executed simultaneously on the same processor. This seemingly-simultaneous execution of multiple processes is calledconcurrency.

For security and reliability, most modernoperating systems prevent directcommunication between independent processes, providing strictly mediated and controlled inter-process communication.

Representation

[edit]
A list of processes as displayed byhtop
A process table as displayed by KDE System Guard
A process table as displayed byKDE System Guard

In general, a computer system process consists of (or is said toown) the following resources:

  • Animage of the executablemachine code associated with a program.
  • Memory (typically some region ofvirtual memory); which includes the executable code, process-specific data (input and output), acall stack (to keep track of activesubroutines and/or other events), and aheap to hold intermediate computation data generated during run time.
  • Operating system descriptors of resources that are allocated to the process, such asfile descriptors (Unix terminology) orhandles (Windows), and data sources and sinks.
  • Security attributes, such as the process owner and the process' set of permissions (allowable operations).
  • Processor state (context), such as the content ofregisters and physical memory addressing. Thestate 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 calledprocess control blocks. Any subset of the resources, typically at least the processor state, may be associated with each of the process'threads in operating systems that support threads orchild processes.

The operating system keeps its processes separate and allocates the resources they need, so that they are less likely to interfere with each other and cause system failures (e.g.,deadlock orthrashing). The operating system may also provide mechanisms forinter-process communication to enable processes to interact in safe and predictable ways.

Multitasking and process management

[edit]
Main article:Process management (computing)

Amultitaskingoperating system may just switch between processes to give the appearance of many processesexecuting simultaneously (that is, inparallel), though in fact only one process can be executing at any one time on a singleCPU (unless the CPU has multiple cores, thenmultithreading or other similar technologies can be used).[a]

It is usual to associate a single process with a main program, and child processes with any spin-off, parallel processes, which behave likeasynchronous subroutines. A process is said toown resources, of which animage of its program (in memory) is one such resource. However, in multiprocessing systemsmany processes may run off of, or share, the samereentrant program at the same location in memory, but each process is said to own its ownimage of the program.

Processes are often called "tasks" inembedded operating systems. The sense of "process" (or task) is "something that takes up time", as opposed to "memory", which is "something that takes up space".[b]

The above description applies to both processes managed by an operating system, and processes as defined byprocess calculi.

If a process requests something for which it must wait, it will be blocked. When the process is in theblocked state, it is eligible for swapping to disk, but this is transparent in avirtual memory system, where regions of a process's memory may be really on disk and not inmain memory at any time. Even portions of active processes/tasks (executing programs) are eligible for swapping to disk, if the portions have not been used recently. Not all parts of an executing program and its data have to be in physical memory for the associated process to be active.

Process states

[edit]
Main article:Process state
The various process states, displayed in astate diagram, with arrows indicating possible transitions between states

An operating systemkernel that allows multitasking needs processes to havecertain states. Names for these states are not standardised, but they have similar functionality.[1]

  • First, the process is "created" by being loaded from asecondary storage device (hard disk drive,CD-ROM, etc.) intomain memory. After that theprocess scheduler assigns it the "waiting" state.
  • While the process is "waiting", it waits for thescheduler to do a so-calledcontext switch. The context switch loads the process into the processor and changes the state to "running" while the previously "running" process is stored in a "waiting" state.
  • If a process in the "running" state needs to wait for a resource (wait for user input or file to open, for example), it is assigned the "blocked" state. The process state is changed back to "waiting" when the process no longer needs to wait (in a blocked state).
  • Once the process finishes execution, or is terminated by the operating system, it is no longer needed. The process is removed instantly or is moved to the "terminated" state. When removed, it just waits to be removed from main memory.[1][3]

Inter-process communication

[edit]
Main article:Inter-process communication

When processes need to communicate with each other they must share parts of theiraddress spaces or use other forms of inter-process communication (IPC).For instance in ashellpipeline, the output of the first process needs to pass to the second one, and so on. Another example is a task that has been decomposed into cooperating but partially independent processes which can run simultaneously (i.e., using concurrency, or true parallelism – the latter model is a particular case of concurrent execution and is feasible whenever multiple CPU cores are available for the processes that are ready to run).

It is even possible for two or more processes to be running on different machines that may run different operating system (OS), therefore some mechanisms for communication and synchronization (calledcommunications protocols for distributed computing) are needed (e.g., theMessage Passing Interface {MPI}).

History

[edit]
See also:History of operating systems

By the early 1960s, computer control software had evolved frommonitor control software, for exampleIBSYS, toexecutive control software. Over time, computers got faster whilecomputer time was still neither cheap nor fully utilized; such an environment mademultiprogramming possible and necessary. Multiprogramming means that several programs runconcurrently. At first, more than one program ran on a single processor, as a result of underlyinguniprocessor computer architecture, and they shared scarce and limited hardware resources; consequently, the concurrency was of aserial nature. On later systems withmultiple processors, multiple programs may run concurrently inparallel.

Programs consist of sequences of instructions for processors. A single processor can run only one instruction at a time: it is impossible to run more programs at the same time. A program might need someresource, such as an input device, which has a large delay, or a program might start some slow operation, such as sending output to a printer. This would lead to processor being "idle" (unused). To keep the processor busy at all times, the execution of such a program is halted and the operating system switches the processor to run another program. To the user, it will appear that the programs run at the same time (hence the term "parallel").

Shortly thereafter, the notion of a "program" was expanded to the notion of an "executing program and its context". The concept of a process was born, which also became necessary with the invention ofre-entrant code.Threads came somewhat later. However, with the advent of concepts such astime-sharing,computer networks, and multiple-CPUshared memory computers, the old "multiprogramming" gave way to truemultitasking,multiprocessing and, later,multithreading.

See also

[edit]

Notes

[edit]
  1. ^Some modern CPUs combine two or more independent processors in amulti-core configuration and can execute several processes simultaneously. Another technique calledsimultaneous multithreading (used inIntel'sHyper-threading technology) can simulate simultaneous execution of multiple processes or threads.
  2. ^Tasks and processes refer essentially to the same entity. And, although they have somewhat different terminological histories, they have come to be used as synonyms. Today, the term process is generally preferred over task, except when referring to "multitasking", since the alternative term, "multiprocessing", is too easy to confuse with multiprocessor (which is a computer with two or more CPUs).

References

[edit]
  1. ^abcdSilberschatz, Abraham; Cagne, Greg; Galvin, Peter Baer (2004). "Chapter 4. Processes".Operating system concepts with Java (Sixth ed.).John Wiley & Sons.ISBN 0-471-48905-0.
  2. ^Vahalia, Uresh (1996). "Chapter 2. The Process and the Kernel".UNIX Internals: The New Frontiers. Prentice-Hall Inc.ISBN 0-13-101908-2.
  3. ^Stallings, William (2005).Operating Systems: internals and design principles (5th ed.). 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")

Further reading

[edit]

External links

[edit]
Wikiversity has learning resources aboutProcesses and Threads at
General
Levels
Multithreading
Theory
Elements
Coordination
Programming
Hardware
APIs
Problems
General
Variants
Kernel
Architectures
Components
Process management
Concepts
Scheduling
algorithms
Memory management,
resource protection
Storage access,
file systems
Supporting concepts
Authority control databases: NationalEdit this at Wikidata
Retrieved from "https://en.wikipedia.org/w/index.php?title=Process_(computing)&oldid=1297700782"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp