Process Management
Process Management
PROCESS
• A process is basically a program in execution. The execution of a process must
progress in a sequential fashion.
• A process will need certain resources—such as CPU time, memory, files, and
I/O devices — to accomplish its task.
CONT.
• These resources are allocated to the process either when it is created or while
it is executing.
• When a program is loaded into the memory and it becomes a process, it can
be divided into four sections ─ stack, heap, text and data.
CONT.
• When a process executes, it passes through different states. These stages may
differ in different operating systems, and the names of these states are also
not standardized.
• Ready:
• The process is waiting to be assigned to a processor.
• Ready processes are waiting to have the processor allocated to them by the
operating system so that they can run.
CONT.
• Process may come into this state after Start state or while running it may be
interrupted by the scheduler to assign CPU to some other process.
• Running:
• Once the process has been assigned to a processor by the OS scheduler, the
process state is set to running and the processor executes its instructions.
CONT.
• Waiting:
• Process moves into the waiting state if it needs to wait for a resource, such as
waiting for user input, or waiting for a file to become available.
• Terminated or Exit
• Once the process finishes its execution, or it is terminated by the operating
system, it is moved to the terminated state where it waits to be removed
from main memory.
TWO STATE PROCESS
• We can construct the simplest possible model by observing that, at any time,
a process is either being executed by a processor, or it isn’t. In this model, a
process may be in one of the two states: Running or Not Running.
CONT.
• When the OS creates a new process, it creates a process control block (PCB)
for the process and enters that process into the system in the Not Running
state. The process exists, is known to the OS, and is waiting for an opportunity
to execute.
• From time to time, the currently running process will be interrupted, and the
dispatcher portion of the OS will select some other process to run. The former
process moves from the Running state to the Not Running state, and one of the
other processes moves to the Running state.
TWO STATE PROCESS MODEL
DIAGRAMMATIC REPRESENTATION OF PROCESS
STATE
CONT.
THE CREATION AND TERMINATION OF
PROCESSES
• As another example, a server process (e.g., print server, file server) may
generate a new process for each request that it handles. When the OS creates a
process at the explicit request of another process, the action is referred to as
process spawning.
CONT
• When one process spawns another, the former is referred to as the parent
process, and the spawned process is referred to as the child process.
Typically, the “related” processes need to communicate and cooperate with
each other.
PROCESS TERMINATION
• Any computer system must provide a means for a process to indicate its completion.
A batch job should include a Halt instruction or an explicit OS service call for
termination. In the former case, the Halt instruction will generate an interrupt to
alert the OS that a process has completed.
• For an interactive application, the action of the user will indicate when the process is
completed. For example, in a time-sharing system, the process for a particular user is to be
terminated when the user logs off or turns off his or her terminal. On a personal computer or
workstation, a user may quit an application (e.g., word processing or spreadsheet). All of these
actions ultimately result in a service request to the OS to terminate the requesting process.
REASONS FOR PROCESS TERMINATION
CONT.
PROCESS CONTROL BLOCK (PCB)
• A PCB keeps all the information needed to keep track of a process as listed
below in the table −
CONT.
• Process State
• The current state of the process i.e., whether it is ready, running, waiting, or
whatever.
• Process privileges
• This is required to allow/disallow access to system resources.
• Process ID
• Unique identification for each of the process in the operating system.
CONT.
• Pointer
• A pointer to parent process.
• Program Counter
• Program Counter is a pointer to the address of the next instruction to be
executed for this process.
CONT.
• CPU registers
• Various CPU registers where process need to be stored for execution for
running state.
• Accounting information
• This includes the amount of CPU used for process execution, time limits,
execution ID etc.
CONT.
• IO status information
• This includes a list of I/O devices allocated to the process.
• The PCB is maintained for a process throughout its lifetime, and is deleted
once the process terminates.
PROCESS CONTROL BLOCK
PROCESS SCHEDULING
• The process scheduling is the activity of the process manager that handles the
removal of the running process from the CPU and the selection of another process
on the basis of a particular strategy ie scheduling algorithm.
• Such operating systems allow more than one process to be loaded into the
executable memory at a time and the loaded process shares the CPU using
time multiplexing.
PROCESS SCHEDULING QUEUES
• The OS maintains a separate queue for each of the process states and PCBs of
all processes in the same execution state are placed in the same queue.
• When the state of a process is changed, its PCB is unlinked from its current
queue and moved to its new state queue.
CONT.
• Job queue - This queue keeps all the processes in the system.
• Ready queue - This queue keeps a set of all processes residing in main
memory, ready and waiting to execute. A new process is always put in this
queue.
CONT.