Process management (computing): Difference between revisions

Content deleted Content added
m I made grammatical and spelling changes and adjusted the flow of the article.
A multiprogramming or multitasking O.S. is a Operating System that can execute many processes concurrently. Added Operating before system for disambiguition.
 
(14 intermediate revisions by 11 users not shown)
Line 5:
 
== Multiprogramming ==
In any modern-day operating system, there iscan be more than one instance of a [[computer program|program]] loaded in memory at athe givensame time. For example, more than one user can be executing the same program, with 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 can each execute the same program -code. TheSuch a program is called [[centralReentrant processing unit(subroutine)|processorre-entrant]],.{{Relevance atinline|date=November any2023}} At a given instanceinstant, the [[central processing unit|processor]] can only executebe executing one instruction from one program, but several processes can be sustained over a period of time. The processor accomplishes this by assigning each separate process to the processor andat duringintervals these intervals,while the remaining processesremainder become temporarily inactive. The execution of multiple processes over a period of time, rather than simultaneously, is known as concurrent execution.
 
A [[multiprogramming]] or [[Computer multitasking|multitasking]] OSO.S. is a systemOperating System that can execute many processes concurrently. Multiprogramming requires that the processor be allocated to each process for a period of time and de-allocated or issued 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 itthe process can be restartedrestart later as easilyefficiently as possible.
 
There are two 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 14:
# A hardware [[interrupt]] occurs; for example, a key was pressed on the keyboard, or a timer runs out (used in [[preemption (computing)|preemptive multitasking]]).
 
The terminationstopping 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]] systems.
 
==How multiprogramming increases efficiency?==
A common trait observed among processes associated with most computer programs is that they alternate between [[CPU]] cycles and [[I/O]] cycles. For the portion of the time required for CPU cycles, the process is being executed and 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. An example of this is 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 become aware that for much of the time that a computer was allocated to a single user -- {{snd}}for example, when a user was entering information or debugging programs -- {{snd}}the processor was idle. [[Computer scientists]] observed that the 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 115:
 
== The Kernel system concept ==
 
{{Repetition section|date=November 2023}}<!-- This appears to be a second section in a row describing CPU modes. -->
 
The parts of the [[operating system|OS]] that are critical to its correct operation execute in [[kernel mode]], while other [[software]] (such as generic system software) and all application programs execute in [[user mode]]. This serves as the fundamental distinction between the operating system and other [[system software]]. The part of the system executing in the kernel supervisor state is called the [[kernel (computer science)|kernel]], or nucleus, of the [[operating system]]. The kernel operates as trusted software, meaning that when it was designed and implemented, it was intended to implement protection mechanisms that could not be covertly changed through the actions of untrusted software executing in user space. Extensions to the OS execute in [[user mode]], so the OS does not rely on the correctness of those parts of the system software for the correct operation of the OS. Hence, a fundamental design decision for any function to be incorporated into the OS is whether it needs to be implemented in the kernel. If it is implemented in the kernel, it will execute in kernel (supervisor) space, and have access to other parts of the kernel. It will also be trusted software by the other parts of the kernel. If the function is implemented to execute in [[user mode]], it will have no access to kernel data structures. However, the advantage is that it will normally require very limited effort to invoke the function. While kernel-implemented functions may be easy to implement, the trap mechanism and authentication at the time of the call are usually relatively expensive. The kernel code runs fast, but there is a large performance overhead in the actual call. This is a subtle, but important point.
The critical parts of the [[operating system|OS]] run in [[kernel mode]], while other [[software]] (such as system utilities and application programs) run in [[user mode]]. This serves as the fundamental distinction between the OS and other [[system software]]. The part of the system executing in the kernel mode is called the [[kernel (computer science)|kernel]], or nucleus, of the OS. The kernel is designed as trusted software, meaning it implements protection mechanisms that cannot be covertly modified by untrusted software running in user mode. Extensions to the OS operate in [[user mode]], so the core functionality of the OS does not depend on these extensions for its correct operation.
 
A key design decision for any OS function is determining whether it should be implemented in the kernel. If implemented in the kernel, it operates in kernel mode, gaining access to other parts of the kernel and being trusted by them. Conversely, if the function executes in [[user mode]], it lacks access to kernel data structures but requires minimal effort to invoke. Although functions implemented in the kernel can be straightforward, the [[trap (computing)|trap mechanism]] and authentication process required during the call can be relatively resource-intensive. While the kernel code itself runs efficiently, the overhead associated with the call can be significant. This is a subtle but important distinction.
 
== Requesting system services ==
Line 127 ⟶ 130:
In the [[message passing]] approach, the user process constructs a message that describes the desired service. Then it uses a trusted send function to pass the message to a trusted [[operating system|OS]] [[process (computing)|process]]. The send function serves the same purpose as the trap; that is, it carefully checks the message, switches the [[Microprocessor|processor]] to kernel mode, and then delivers the message to a process that implements the target functions. Meanwhile, the user process waits for the result of the service request with a message receive operation. When the OS process completes the operation, it sends a message back to the user process.
 
The distinction between the two approaches has important consequences regarding the independence of the OS behavior from the application process behavior, and the resulting performance. As a rule of thumb, [[operating system|operating systems]] based on a [[system call]] interface can be made more efficient than those requiring messages to be exchanged between distinct processes. This is the case even though the system call must be implemented with a trap instruction; that is, even though the trap is relatively expensive to perform, it is more efficient than the message-passing approach, where there are generally higher costs associated with the process [[multiplexing]], message formation and message copying. The system call approach has the interesting property that there is not necessarily any OS process. Instead, a process executing in [[user mode]] changes to [[kernel mode]] when it is executing kernel code, and switches back to user mode when it returns from the OS call. If, on the other hand, the OS is designed as a set of separate processes, it is usually easier to design it so that it gets control of the machine in special situations, than if the kernel is simply a collection of functions executed by usersuser processes in kernel mode. Procedure-based operating systems usually include at least a few [[system process]]es (called [[daemon (computer software)|daemons]] in [[UNIX]]) to handle situations whereby the machine is otherwise idle such as [[scheduling (computing)|scheduling]] and handling the network.{{cn|date=November 2023}}
 
== See also ==
Line 142 ⟶ 145:
* Process Management Models, Scheduling, UNIX System V Release 4:
* Modern Operating Systems, Andrew Tanenbaum, Prentice Hall, (2nd Edition, 2001).
* Operating System Concepts, Silberschatz & Galvin & Gagne (httphttps://codex.cs.yale.edu/avi/os-book/OS9/slide-dir/), John Wiley & Sons, (6th Edition, 2003)
 
{{Operating System}}