From Wikipedia, the miễn phí encyclopedia
In computing, a process is the instance of a computer program that is being executed by one or many threads. There are many different process models, some of which are light weight, but almost all processes (even entire virtual machines) are rooted in an operating system (OS) process which comprises the program code, assigned system resources, physical and logical access permissions, and data structures lớn initiate, control and coordinate execution activity. Depending on the OS, a process may be made up of multiple threads of execution that execute instructions concurrently.
Bạn đang xem: process là gì
While a computer program is a passive collection of instructions typically stored in a tệp tin 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 phàn nàn one process being executed.
Multitasking is a method lớn allow multiple processes lớn share processors (CPUs) and other system resources. Each CPU (core) executes a single process at a time. However, multitasking allows each processor lớn switch between tasks that are being executed without having lớn wait for each task lớn finish (preemption). Depending on the operating system implementation, switches could be performed when tasks initiate and wait for completion of input/output operations, when a task voluntarily yields the CPU, on hardware interrupts, and when the operating system scheduler decides that a process has expired its fair share of CPU time (e.g, by the Completely Fair Scheduler of the Linux kernel).
A common size of multitasking is provided by CPU's time-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 preemptive kernels such as Linux. Preemption has an important side effect for interactive processes that are given higher priority with respect lớn CPU bound processes, therefore users are immediately assigned computing resources at the simple pressing of a key or when moving a mouse. Furthermore, applications lượt thích Clip 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 lượt thích multiple processes are being executed simultaneously on the same processor. This seemingly-simultaneous execution of multiple processes is called concurrency.
For security and reliability, most modern operating systems prevent direct communication between independent processes, providing strictly mediated and controlled inter-process communication.
In general, a computer system process consists of (or is said lớn own) the following resources:
- An image of the executable machine code associated with a program.
- Memory (typically some region of virtual memory); which includes the executable code, process-specific data (input and output), a gọi stack (to keep track of active subroutines and/or other events), and a heap lớn hold intermediate computation data generated during lập cập time.
- Operating system descriptors of resources that are allocated lớn the process, such as tệp tin descriptors (Unix terminology) or handles (Windows), and data sources and sinks.
- Security attributes, such as the process owner and the process' mix of permissions (allowable operations).
- Processor state (context), such as the nội dung of registers and physical memory addressing. The state is typically stored in computer registers when the process is executing, and in memory otherwise.
The operating system holds most of this information about active processes in data structures called process 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 tư vấn threads or child processes.
The operating system keeps its processes separate and allocates the resources they need, sánh that they are less likely lớn interfere with each other and cause system failures (e.g., deadlock or thrashing). The operating system may also provide mechanisms for inter-process communication lớn enable processes lớn interact in safe and predictable ways.
Multitasking and process management
A multitasking operating system may just switch between processes lớn give the appearance of many processes executing simultaneously (that is, in parallel), though in fact only one process can be executing at any one time on a single CPU (unless the CPU has multiple cores, then multithreading or other similar technologies can be used).[a]
Xem thêm: next là gì
It is usual lớn associate a single process with a main program, and child processes with any spin-off, parallel processes, which behave lượt thích asynchronous subroutines. A process is said lớn own resources, of which an image of its program (in memory) is one such resource. However, in multiprocessing systems many processes may lập cập off of, or share, the same reentrant program at the same location in memory, but each process is said lớn own its own image of the program.
Processes are often called "tasks" in embedded operating systems. The sense of "process" (or task) is "something that takes up time", as opposed lớn "memory", which is "something that takes up space".[b]
The above mô tả tìm kiếm applies lớn 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 lớn disk, but this is transparent in a virtual memory system, where regions of a process's memory may be really on disk and not in main memory at any time. Even portions of active processes/tasks (executing programs) are eligible for swapping lớn disk, if the portions have not been used recently. Not all parts of an executing program and its data have lớn be in physical memory for the associated process lớn be active.
An operating system kernel that allows multitasking needs processes lớn have certain states. Names for these states are not standardised, but they have similar functionality.
- First, the process is "created" by being loaded from a secondary storage device (hard disk drive, CD-ROM, etc.) into main memory. After that the process scheduler assigns it the "waiting" state.
- While the process is "waiting", it waits for the scheduler lớn bởi a so-called context switch. The context switch loads the process into the processor and changes the state lớn "running" while the previously "running" process is stored in a "waiting" state.
- If a process in the "running" state needs lớn wait for a resource (wait for user input or tệp tin lớn open, for example), it is assigned the "blocked" state. The process state is changed back lớn "waiting" when the process no longer needs lớn 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 lớn the "terminated" state. When removed, it just waits lớn be removed from main memory.
When processes need lớn communicate with each other they must share parts of their address spaces or use other forms of inter-process communication (IPC). For instance in a shell pipeline, the output of the first process need lớn pass lớn the second one, and sánh on; another example is a task that can be decomposed into cooperating but partially independent processes which can lập cập at once (i.e., using concurrency, or true parallelism – the latter model is a particular case of concurrent execution and is feasible whenever enough CPU cores are available for all the processes that are ready lớn run).
It is even possible for two or more processes lớn be running on different machines that may lập cập different operating system (OS), therefore some mechanisms for communication and synchronization (called communications protocols for distributed computing) are needed (e.g., the Message Passing Interface, often simply called MPI).
Xem thêm: vegetarian là gì
By the early 1960s, computer control software had evolved from monitor control software, for example IBSYS, lớn executive control software. Over time, computers got faster while computer time was still neither cheap nor fully utilized; such an environment made multiprogramming possible and necessary. Multiprogramming means that several programs lập cập concurrently. At first, more phàn nàn one program ran on a single processor, as a result of underlying uniprocessor computer architecture, and they shared scarce and limited hardware resources; consequently, the concurrency was of a serial nature. On later systems with multiple processors, multiple programs may lập cập concurrently in parallel.
Programs consist of sequences of instructions for processors. A single processor can lập cập only one instruction at a time: it is impossible lớn lập cập more programs at the same time. A program might need some resource, such as an input device, which has a large delay, or a program might start some slow operation, such as sending output lớn a printer. This would lead lớn 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 lớn lập cập another program. To the user, it will appear that the programs lập cập at the same time (hence the term "parallel").
Shortly thereafter, the notion of a "program" was expanded lớn the notion of an "executing program and its context". The concept of a process was born, which also became necessary with the invention of re-entrant code. Threads came somewhat later. However, with the advent of concepts such as time-sharing, computer networks, and multiple-CPU shared memory computers, the old "multiprogramming" gave way lớn true multitasking, multiprocessing and, later, multithreading.
- ^ Some modern CPUs combine two or more independent processors in a multi-core configuration and can execute several processes simultaneously. Another technique called simultaneous multithreading (used in Intel's Hyper-threading technology) can simulate simultaneous execution of multiple processes or threads.
- ^ Tasks and processes refer essentially lớn the same entity. And, although they have somewhat different terminological histories, they have come lớn be used as synonyms. Today, the term process is generally preferred over task, except when referring lớn "multitasking", since the alternative term, "multiprocessing", is too easy lớn confuse with multiprocessor (which is a computer with two or more CPUs).
- Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau (2014). "Operating Systems: Three Easy Pieces". Arpaci-Dusseau Books. Relevant chapters: Abstraction: The Process The Process API
- Gary D. Knott (1974) A proposal for certain process management and intercommunication primitives ACM SIGOPS Operating Systems Review. Volume 8, Issue 4 (October 1974). pp. 7 – 44
- Media related lớn Process (computing) at Wikimedia Commons
- Online Resources For Process Information
- Computer Process Information Database and Forum
- Process Models with Process Creation & Termination Methods Archived 2021-02-06 at the Wayback Machine