Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Process management (computing)

From Wikipedia, the free encyclopedia
Computer system for maintaining order among running programs
This article has multiple issues. Please helpimprove it or discuss these issues on thetalk page.(Learn how and when to remove these messages)
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Process management" computing – news ·newspapers ·books ·scholar ·JSTOR
(October 2025) (Learn how and when to remove this message)
This articlehas an unclearcitation style. The references used may be made clearer with a different or consistent style ofcitation andfootnoting.(October 2025) (Learn how and when to remove this message)
(Learn how and when to remove this message)
Operating systems
Common features

A process is a program in execution, and an integral part of any modern-dayoperating system (OS). The OS must allocate resources toprocesses, enable processes to share and exchange information, protect the resources of each process from other processes and enable synchronization among processes. To meet these requirements, The OS must maintain adata structure for each process, which describes the state and resource ownership of that process, and which enables the operating system to exert control over each process.

Multiprogramming

[edit]

In any modern operating system, there can be more than one instance of aprogram loaded in memory at the same 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. Such a program is calledre-entrant.[relevant?] At a given instant, theprocessor 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. The execution of multiple processes over a period of time, rather than simultaneously, is known as concurrent execution.

Amultiprogramming ormultitasking O.S. is a Operating 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 a way that the process can restart later as efficiently 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:

  1. The process issues asystem call (sometimes called asoftwareinterrupt); for example, an I/O request occurs requesting to access a file on a hard disk.
  2. A hardwareinterrupt occurs; for example, a key was pressed on the keyboard, or a timer runs out (used inpreemptive multitasking).

The stopping of one process and starting (or restarting) of another process is called acontext switch or context change. In many modern operating systems, processes can consist of many sub-processes. This introduces the concept of athread. A thread may be viewed as asub-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 andclient–server systems and in software run onmulti-processor systems.

How multiprogramming increases efficiency

[edit]

A common trait observed among processes associated with most computer programs is that they alternate betweenCPU cycles andI/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 ofmultiprogramming,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 – for example, when a user was entering information or debugging programs – 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 auni-programming system, ifN users were to execute programs with individual execution times oft1,t2, ...,tN, then the total time,tuni, to service theN processes (consecutively) of allN users would be:

tuni =t1 +t2 + ... +tN.

However, because each process consumes both CPU cycles and I/O cycles, the time which each process actually uses the CPU is a very small fraction of the total execution time for the process. So, for processi:

ti (processor)ti (execution)

where

ti (processor) is the time processi spends using the CPU, andti (execution) is the total execution time for the process; i.e. the time for CPU cycles plus I/O cycles to be carried out (executed) until completion of the process.

In fact, usually, the sum of all the processor time, used byN processes, rarely exceeds a small fraction of the time to execute any one of the processes;

j=1Ntj(processor)<ti(execution){\displaystyle \sum _{j=1}^{N}t_{j\,(\mathrm {processor} )}<t_{i\,(\mathrm {execution} \!)}}

Therefore, in uni-programming systems, the processor lays idle for a considerable proportion of the time. To overcome this inefficiency, multiprogramming is now implemented in modern operating systems such asLinux,UNIX andMicrosoft Windows. This enables the processor to switch from one process, X, to another, Y, whenever X is involved in the I/O phase of its execution. Since the processing time is much less than a single job's runtime, the total time to service allN users with a multiprogramming system can be reduced to approximately:

tmulti = max(t1,t2, ...,tN)

Process creation

[edit]
This sectionpossibly containsoriginal research. Pleaseimprove it byverifying the claims made and addinginline citations. Statements consisting only of original research should be removed.(November 2023) (Learn how and when to remove this message)

Operating systems need some ways to create processes. In a very simple system designed for running only a single application (e.g., the controller in a microwave oven), it may be possible to have all the processes that will ever be needed present when the system comes up. In general-purpose systems, however, some way is needed to create and terminate processes as needed during operation.
There are four principal events that cause a process to be created:

  • System initialization.
  • Execution of process creation system call by a running process.
  • A user request to create a new process.
  • Initiation of a batch job.

When an operating system is booted, several essential processes are typically initiated to prepare the system for operation. Some of these are foreground processes, that interact with a (human) user and perform work for them. Others arebackground processes, which are not associated with particular users, but instead have some specific function. For example, one background process may be designed to accept incoming e-mails, sleeping most of the day but suddenly springing to life when an incoming e-mail arrives. An alternative background process could be designed to accept incoming requests for web pages hosted on the machine, waking up only when a request arrives to service it.

Process creation in UNIX and Linux is done throughfork() or clone() system calls. There are several steps involved in process creation. The first step is the validation of whether theparent process has sufficient authorization to create a process. Upon successful validation, the parent process is copied almost entirely, with changes only to the unique process id, parent process, and user-space. Each new process gets its own user space.[1]

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 they can be accessed. Functions are provided to synchronize calling threads to newly created processes.[2][3]

Process termination

[edit]
This sectionpossibly containsoriginal research. The list combines immediate reasons for process termination and proximate ones (i.e. 'user logs off') without differentiating them. Pleaseimprove it byverifying the claims made and addinginline citations. Statements consisting only of original research should be removed.(November 2023) (Learn how and when to remove this message)

There are many reasons for process termination:

  • Batch job issues halt instruction
  • User logs off
  • Process executes a service request to terminate
  • Error and fault conditions
  • Normal completion
  • Time limit exceeded
  • Memory unavailable
  • Bounds violation; for example: attempted access of (non-existent) 11th element of a 10-element array
  • Protection error; for example: attempted to write to a read-only file
  • Arithmetic error; for example: attempted division by zero
  • Time overrun; for example: the process waited longer than a specified maximum for an event
  • I/O failure
  • Invalid instruction; for example: when a process tries to execute data (text)
  • Privileged instruction
  • Data misuse
  • Operating system intervention; for example: to resolve a deadlock
  • Parent terminates so child processes terminate (cascading termination)
  • Parent request

Two-state process management model

[edit]
This articlepossibly containsoriginal research. Pleaseimprove it byverifying the claims made and addinginline citations. Statements consisting only of original research should be removed.(November 2023) (Learn how and when to remove this message)

Theoperating system's principal responsibility is to control the execution ofprocesses. This includes determining the interleaving pattern for execution and allocation of resources to processes. One part of designing an OS is to describe the behavior that we would like each process to exhibit. The simplest model is based on the fact that a process is either being executed by a processor or it is not. Thus, a process may be considered to be in one of two states,RUNNING orNOT RUNNING. When the operating system creates a new process, that process is initially labeled asNOT RUNNING, and is placed into a queue in the system in theNOT RUNNING state. The process (or some portion of it) then exists inmain memory, and it waits in the queue for an opportunity to be executed. After some period of time, the currentlyRUNNING process will be interrupted, and moved from theRUNNING state to theNOT RUNNING state, making the processor available for a different process. The dispatch portion of the OS will then select, from the queue ofNOT RUNNING processes, one of the waiting processes to transfer to the processor. The chosen process is then relabeled from aNOT RUNNING state to aRUNNING state, and its execution is either begun if it is a new process, or is resumed if it is a process which was interrupted at an earlier time.

From this model, we can identify some design elements of the OS:

  • The need to represent, and keep track of each process
  • The state of a process
  • The queuing ofNON RUNNING processes

Three-state process management model

[edit]
This articlepossibly containsoriginal research. Pleaseimprove it byverifying the claims made and addinginline citations. Statements consisting only of original research should be removed.(November 2023) (Learn how and when to remove this message)

Although the two-state process management model is a perfectly valid design for an operating system, the absence of aBLOCKED state means that theprocessor lies idle when the active process changes from CPU cycles toI/O cycles. This design does not make efficient use of the processor. The three-state process management model is designed to overcome this problem, by introducing a new state called theBLOCKED state. This state describes any process which is waiting for an I/O event to take place. In this case, an I/O event can mean the use of some device or a signal from another process. The three states in this model are:

  • RUNNING: The process that is currently being executed.
  • READY: A process that is queuing and prepared to execute when given the opportunity.
  • BLOCKED: A process that cannot execute until some event occurs, such as the completion of an I/O operation.

At any instant, a process is in one and only one of the three states. For a single processor computer, only one process can be in theRUNNING state at any one instant. There can be many processes in theREADY andBLOCKED states, and each of these states will have an associated queue for processes.

Processes entering the system must go initially into theREADY state, and processes can only enter theRUNNING state via theREADY state. Processes normally leave the system from theRUNNING state. For each of the three states, the process occupies space in the main memory. While the reason for most transitions from one state to another might be obvious, some may not be so clear.

  • RUNNING → READY: The most common reason for this transition is that the running process has reached the maximum allowable time for uninterrupted execution; i.e. time-out occurs. Other reasons can be the imposition of priority levels as determined by thescheduling policy used for the Low LevelScheduler, and the arrival of a higher priority process into the READY state.
  • RUNNING → BLOCKED: A process is put into theBLOCKED state if it requests something for which it must wait. A request to the OS is usually in the form of a system call, (i.e. a call from the running process to a function that is part of the OS code). For example, a process might becomeBLOCKED if it is requesting a file from disk or a saving a section of code or data from memory to a file on disk.

Process description and control

[edit]

Eachprocess in the system is represented by a data structure called aProcess Control Block (PCB), or Process Descriptor inLinux.

Process Identification: Each process is uniquely identified by the user's identification and a pointer connecting it to its descriptor.

Process Status: This indicates the current status of the process;READY,RUNNING,BLOCKED,READY SUSPEND,BLOCKED SUSPEND.

Process State: This contains all of the information needed to indicate the current state of the job.

Accounting: This contains information used mainly for billing purposes and for performance measurement. It indicates what kind of resources the process has used and for how long.

Processor modes

[edit]
Main article:CPU modes
This sectionpossibly containsoriginal research. The terminology seems inconsistent. The text appears to imply that it refers to x86 at least partially, but uses terms not commonly used in application to this architecture. The claim that OS changes protection mode on software interrupt is likely incorrect. Pleaseimprove it byverifying the claims made and addinginline citations. Statements consisting only of original research should be removed.(November 2023) (Learn how and when to remove this message)

Contemporaryprocessors incorporate a mode bit to define the execution capability of a program in the processor. This bit can be set tokernel mode oruser mode. Kernel mode is also commonly referred to assupervisor mode,monitor mode orring 0.

In kernel mode, the processor can execute every instruction in its hardware repertoire, whereas in user mode, it can only execute a subset of the instructions. Instructions that can be executed only in kernel mode are called kernel, privileged, or protected instructions to distinguish them from the user mode instructions. For example,I/O instructions are privileged. As such, if anapplication program executes in user mode, it cannot perform its ownI/O. Instead, it must request the OS to performI/O on its behalf.

The Kernel system concept

[edit]

The critical parts of theOS run inkernel mode, while othersoftware (such as system utilities and application programs) run inuser mode. This serves as the fundamental distinction between the OS and othersystem software. The part of the system executing in the kernel mode is called thekernel, 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 inuser 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 inuser mode, it lacks access to kernel data structures but requires minimal effort to invoke. Although functions implemented in the kernel can be straightforward, thetrap 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

[edit]

There are two techniques by which a program executing in user mode can request thekernel's services:

Operating systems are designed with one or the other of these two facilities, but not both. First, assume that auser process wishes to invoke a particular target system function. For thesystem call approach, the user process uses the trap instruction. The idea is that the system call should appear to be an ordinary procedure call to the application program; theOS provides a library of user functions with names corresponding to each actual system call. Each of these stub functions contains a trap to the OS function. When the application program calls the stub, it executes the trap instruction, which switches theCPU tokernel mode, and then branches (indirectly through an OS table[jargon]), to the entry point of the function which is to be invoked. When the function completes, it switches the processor touser mode and then returns control to the user process, thus simulating a normal procedure return.[citation needed]

In themessage 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 trustedOSprocess. The send function serves the same purpose as the trap; that is, it carefully checks the message, switches theprocessor 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 systems based on asystem 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 processmultiplexing, 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 inuser mode changes tokernel 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 user processes in kernel mode. Procedure-based operating systems usually include at least a fewsystem processes (calleddaemons inUNIX) to handle situations whereby the machine is otherwise idle such asscheduling and handling the network.[citation needed]

See also

[edit]

References

[edit]
  1. ^"A Sneak-Peek into Linux Kernel - Chapter 2: Process Creation"
  2. ^"CreateProcessA function (Processthreadsapi.h) - Win32 apps". 9 February 2023.
  3. ^"Creating Processes - Win32 apps". 9 February 2023. Archived fromthe original on 2023-03-29.

Sources

[edit]
  • Operating System incorporating Windows and UNIX, Colin Ritchie.ISBN 0-8264-6416-5
  • Operating Systems, William Stallings, Prentice Hall, (4th Edition, 2000)
  • Multiprogramming, Process Description and Control
  • Operating Systems – A Modern Perspective, Gary Nutt, Addison Wesley, (2nd Edition, 2001).
  • 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 (https://codex.cs.yale.edu/avi/os-book/OS9/slide-dir/), John Wiley & Sons, (6th Edition, 2003)
General
Variants
Kernel
Architectures
Components
Process management
Concepts
Scheduling
algorithms
Memory management,
resource protection
Storage access,
file systems
Supporting concepts
Retrieved from "https://en.wikipedia.org/w/index.php?title=Process_management_(computing)&oldid=1318314456"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp