Process management (computing): Difference between revisions

Content deleted Content added
copyediting, fixed some incorrect descriptions of how process management works, added some citation, deleted non relevant information.
Tags: Reverted nowiki added Visual edit
Undid revision 1214787996 by Punker1999 (talk) badly written; not an improvement
Tags: Undo Mobile edit Mobile web edit Advanced mobile edit
Line 2:
{{OS}}
 
Process management is the ways in which a modern-day [[operating system]] (OS) maintains program requirements and processes. A process is a thought or a segment of a program thatin is current executingexecution, not the whole program. <ref name=":0">{{Cite book |last=Silberschatz |first=Abraham |title=Operating System Concepts |last2=Gagne |first2=Greg |last3=Galvin |first3=Peter |publisher=WileyPLUS |year=2011 |isbn=978-1118112731 |edition=8th |___location=United States |pages=284-300 |language=English}}</ref> These processes areand an integral part of allany modern-day [[operating system]]<nowiki/>s (OS). The OS allocatesmust allocate resources to the[[process various(computing)|processes]], enable processes goingto onshare atand onceexchange toinformation, enableprotect theirthe synchronizationresources of each process from other processes and enable synchronization among processes. To meet programthese requirements., Thethe OS does this bymust maintainingmaintain a [[data structure]] for each process, which describingdescribes the state and resource ownership of that process., Thusand enablingwhich enables the OS to exert control over each process. The OS is responsible for both creating and managing these processes.
 
== Multiprogramming ==
== Early Computing without Process Management ==
In any modern operating system there can be more than one instance of a [[computer program|program]] loaded in memory at the same time. For example, more than one user could be executing the same program, each user having separate copies of the program loaded into memory. With some programs, it is possible to have one copy loaded into memory, while several users have shared access to it so that they each can execute the same program-code. Such a program is said to be [[Reentrant (subroutine)|re-entrant]].{{Relevance inline|date=November 2023}} The [[central processing unit|processor]] at any instant can only be executing one instruction from one program but several processes can be sustained over a period of time by assigning each process to the processor at intervals while the remainder become temporarily inactive. A number of processes being executed over a period of time instead of at the same time is called [[Concurrent computing|concurrent execution]].{{cn|date=November 2023}}
In early computing, computer programs would only execute one program at a time. This was difficult as it would not allow for background processes that exist in modern day computing.
 
A [[multiprogramming]] or [[Computer multitasking|multitasking]] OS is a system executing many processes concurrently. Multiprogramming requires that the processor be allocated to each process for a period of time and de-allocated at an appropriate moment. If the processor is de-allocated during the execution of a process, it must be done in such a way that it can be restarted later as easily as possible.
== Multi processing ==
[[Multiprocessing]] is a system executing multiple processes concurrently. This is done through the action of process management. With more complex OS, more is expected to be done for its users. The system wants to be able to work on multiple processes at once to be able to act concurrently. This is done by switching the CPU between what processes are happening. A number of processes being executed over a period of time instead of at the same time is called [[Concurrent computing|concurrent execution]].{{cn|date=November 2023}}
 
There are two possible ways for an OS to regain control of the processor during a program's execution in order for the OS to perform de-allocation or allocation:
Line 15 ⟶ 14:
# A hardware [[interrupt]] occurs; for example, a key was pressed on the keyboard, or a timer runs out (used in [[preemption (computing)|pre-emptive multitasking]]).
 
The stopping of one process and starting (or restarting) of another process is called a [[context switch]] or context change. In many modern operating systems, processes can consist of many sub-processes. This introduces the concept of a ''[[thread (computer science)|thread]]''. A thread may be viewed as a ''sub-process''; that is, a separate, independent sequence of execution within the code of one process. Threads are becoming increasingly important in the design of distributed, and [[client–server]] systems and in software run on [[Parallel computing|multi-processor]], and [[client–server]] software and systems.
 
==How multiprocessingmultiprogramming increases efficiency==
A common trait observed among processes associated with most computer programs, is alternatingthat they alternate between [[CPU]] cycles and [[I/O]] cycles. For athe portion of the time required for CPU cycles, the process is being executed; i.e. is occupying the CPU. During the time required for I/O cycles, the process is not using the processor. Instead, it is either waiting to perform Input/Output, or is actually performing Input/Output. ForAn example, of this is the reading from or writing to a file on disk. Prior to the advent of [[multiprogramming]], [[computers]] operated as single-user systems. Users of such systems quickly became aware that for much of the time that a computer was allocated to a single user, the processor was idle; when the user was entering information or debugging programs for example. [[Computer scientists]] observed that overall performance of the machine could be improved by letting a different process use the processor whenever one process was waiting for input/output. In a ''uni-programming system'', if ''N'' users were to execute programs with individual execution times of ''t''<sub>1</sub>, ''t''<sub>2</sub>, ..., ''t''<sub>''N''</sub>, then the total time, ''t''<sub>uni</sub>, to service the ''N'' processes (consecutively) of all ''N'' users would be:
The goal with multiprocessing is to have processes running at all times. Doing such allows users to utilize the most out of their CPU's capabilities.
 
A common trait observed among processes associated with most computer programs, is alternating between [[CPU]] cycles and [[I/O]] cycles. For a portion of the time required for CPU cycles, the process is being executed; i.e. is occupying the CPU. During the time required for I/O cycles, the process is not using the processor. Instead, it is either waiting to perform Input/Output, or is performing Input/Output. For example, reading from or writing to a file on disk. Prior to the advent of [[multiprogramming]], [[computers]] operated as single-user systems. Users of such systems quickly became aware that for much of the time that a computer was allocated to a single user, the processor was idle; when the user was entering information or debugging programs for example. [[Computer scientists]] observed that overall performance of the machine could be improved by letting a different process use the processor whenever one process was waiting for input/output. In a ''uni-programming system'', if ''N'' users were to execute programs with individual execution times of ''t''<sub>1</sub>, ''t''<sub>2</sub>, ..., ''t''<sub>''N''</sub>, then the total time, ''t''<sub>uni</sub>, to service the ''N'' processes (consecutively) of all ''N'' users would be:
 
: ''t''<sub>uni</sub> = ''t''<sub>1</sub> + ''t''<sub>2</sub> + ... + ''t''<sub>''N''</sub>.
Line 54 ⟶ 51:
 
Process creation in Windows is done through the CreateProcessA() system call. A new process runs in the security context of the calling process, but otherwise runs independently of the calling process. Methods exist to alter the security context in which a new processes runs. New processes are assigned identifiers by which the can be accessed. Functions are provided to synchronize calling threads to newly created processes.<ref>{{Cite web | url=https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa | title=CreateProcessA function (Processthreadsapi.h) - Win32 apps | date=9 February 2023 }}</ref><ref>{{Cite web | url=https://docs.microsoft.com/en-us/windows/win32/procthread/creating-processes | title=Creating Processes - Win32 apps | date=9 February 2023 }}</ref>
 
Processes have four states they can be in:
 
* New; a process that is currently being created
* Running; a process where instructions are being executed
* Ready; a process waiting for the processor
* Terminated: a process that has finished it's execution<ref name=":0" />
 
These names vary across operating systems and communities, but the concepts are the same.
 
== Process termination ==