Process
Last updated
Last updated
In multiprogramming the activity of the processor, because it is switching back and forth from process to process, is hard to perceive.
Thus, it is better to assume the existence of a number of virtual processors, one per existing process.
Turning off one virtual processor and on another, corresponds to a process switching.
Number of active virtual processors ≤ number of real processors.
The switching between processes, and thus the switching between virtual processors, can occur for different reasons, possibly not controlled by the running program.
Thus, to be viable, this process model requires that.
the execution of any process is not affected by the instant in time or the location in the code where the switching takes place.
No restrictions are imposed on the total or partial execution times of any process
A process can be not running for different reasons.
so, one should identify the possible process states.
The most important are:
RUN – the process is in possession of a processor and thus running.
BLOCKED – the process is waiting for the occurrence of an external event (access to a resource, end of an input/output operation, etc.)
READY – the process is ready to run, but waiting for the availability of a processor to start/resume its execution.
Transitions between states usually result from external intervention, but, in some cases, can be triggered by the process itself.
The part of the operating system that handles these transitions is called the (processor) scheduler and is an integral part of its kernel.
Different policies exist to control the firing of these transitions.
event wait – the running process is prevented to proceed, awaiting the occurrence of an external event.
dispatch – one of the processes ready to run is selected and given to the processor.
event occurs – an external event occurred and the process waiting for it is now ready to be given to the processor.
time-out – the time quantum assigned to the running process gets to the end, so the process is removed from the processor.
The main memory is finite, which limits the number of coexisting processes.
A way to overcome this limitation is to use an area in secondary memory to extend the main memory.
This is called the swap area (can be a disk partition or a file).
A non-running process, or part of it, can be swapped out, in order to free the main memory for other processes.
That process will be later on swapped in after the main memory becomes available.
Two new states should be added to the process state diagram to incorporate these situations:
suspended-ready – the process is ready but swapped out.
suspended-blocked – the process is blocked and swapped out.
Two new transitions appear:
suspend – the process is swapped out.
activate - the process is swapped in.
The previous state diagram assumes processes are timeless.
Apart from some system processes this is not true.
Processes are created, exist for some time, and eventually terminate.
Two new states are required to represent creation and termination.
new – the process has been created but not yet admitted to the pool of executable processes (the process data structure is been initialized).
terminated – the process has been released from the pool of executable processes, but some actions are still required before the process is discarded.
Three new transitions exist.
admit – the process is admitted (by the OS) to the pool of executable processes.
exit – the running process indicates the OS it has completed.
abort – the process is forced to terminate (because of a fatal error or because an authorized process aborts its execution).