Operating System: Lecture #5 Process Management
Operating System: Lecture #5 Process Management
Lecture #5
Process Management
Objectives
• Concept of Process.
• Operations on Processes
• Process control block.
Process
• A process is an activity of executing a program. Basically, it is a program under execution.
• Every process needs certain resources to complete its task.
• The execution of a process is a complex activity. It involves various operations.:
• Creation.
• Schedule.
• Premption
• Blocking
• Termination
Operations on Processes
Creation
• This is the initial step of process execution activity. Process creation means the
construction of a new process for the execution. This might be performed by
system, user or old process itself. There are several events that leads to the
process creation. Some of the such events are following:
• When we start the computer, system creates several background processes.
• A user may request to create a new process.
• A process can create a new process itself while executing.
• Batch system takes initiation of a batch job.
Scheduling/Dispatching
• The event or activity in which the state of the process is changed from
ready to running.
• It means the operating system puts the process from ready state into the
running state.
• Dispatching is done by operating system when the resources are free or
the process has higher priority than the ongoing process.
Blocking
• When a process invokes an input-output system call that blocks the
process and operating system put in block mode.
• Block mode is basically a mode where process waits for input-output.
Hence on the demand of process itself, operating system blocks the
process and dispatches another process to the processor.
• Hence, in process blocking operation, the operating system puts the
process in ‘waiting’ state.
Preemption
• When a timeout occurs that means the process hadn’t been terminated in
the allotted time interval and next process is ready to execute, then the
operating system preempts the process.
• This operation is only valid where CPU scheduling supports preemption.
Basically this happens in priority scheduling where on the incoming of
high priority process the ongoing process is preempted. Hence, in process
preemption operation, the operating system puts the process in ‘ready’
state.
Termination
• Process termination is the activity of ending the process. In other words, process
termination is the relaxation of computer resources taken by the process for the execution.
• Like creation, in termination also there may be several events that may lead to the process
termination.
• Process completes its execution fully and it indicates to the OS that it has finished.
• Operating system itself terminates the process due to service errors.
• There may be problem in hardware that terminates the process.
• One process can be terminated by another process.
Process States
• A process, from its creation to completion goes through different states.
Generally, a process may be present in one of the 5 states during its execution:
• New
• Ready
• Block or waiting
• Running
• Terminated
Process States
Process States
• New: This state contains the processes which are ready to be loaded by the
operating system into the main memory.
• Ready: This state contains the process which is both ready to be executed
and is currently in the main memory of the system. The operating system
brings the processes from secondary memory(hard disk) to main
memory(RAM). As these processes are present in the main memory and
are waiting to be assigned to the CPU, the state of these processes is
known as Ready state.
Process States
• Running: This state contains the processes which are currently executed by the
CPU in our system. If there is a total x CPU in our system, then a maximum
number of running processes for a particular time is also x.
• Block or wait: A process from its running state may transition to a block or wait
for state depending on the scheduling algorithm or because of the internal behavior
of the process (process explicitly wants to wait).
• Termination: A process that completes its execution comes to its termination state.
All the contents of that process(Process control block) will also be deleted by the
operating system.
• Lifecycle of A process
Process Life Cycle In OS
Process Control Block
• Process Control Block is a data structure that contains information of the process
related to it. The process control block is also known as a task control block, entry
of the process table, etc.
• It is very important for process management as the data structuring for processes is
done in terms of the PCB. It also defines the current state of the operating system.
• It’s a repository of information associated with a specific process.
• PCBs are stored in specially reserved memory for the operating system known
as kernel space.
Process Control Block
• The role of the process control block arises as an identification card for each process. The
Operating System doesn't know which process is which, until Operating System refers through
the PCB of every process.
• For Example:, there are MS word processes, pdf processes, printing processes, and many
background processes are running currently on the CPU. How will OS identify and manage
each process without knowing the identity of each process?
• So, here PCB comes into play as a data structure to store information about each process.
• Therefore, whenever a user triggers a process (like print command), a process control
block (PCB) is created for that process in the operating system which is used by the operating
system to execute and manage the processes when the operating system is free.
Process Control Block
Process Control Block
• Process State
• This specifies the process state i.e. new, ready, running, waiting or terminated.
• Process ID
• This shows the number of the particular process.
• Program Counter
• This contains the address of the next instruction that needs to be executed in the process.
• Registers
• This specifies the registers that are used by the process. They may include accumulators, index
registers, stack pointers, general purpose registers etc.
Process Control Block
• List of Open Files
• These are the different files that are associated with the process
• CPU Scheduling Information
• The process priority, pointers to scheduling queues etc. is the CPU scheduling information
that is contained in the PCB. This may also include any other scheduling parameters.
• Memory Management Information
• The memory management information includes the page tables or the segment tables
depending on the memory system used. It also contains the value of the base registers, limit
registers etc.
Process Control Block
• I/O Status Information
• This information includes the list of I/O devices used by the process, the list of files etc.
• Accounting information
• The time limits, account numbers, amount of CPU used, process numbers etc. are all a part of
the PCB accounting information.
• Location of the Process Control Block
• The process control block is kept in a memory area that is protected from the normal user
access. This is done because it contains important process information. Some of the operating
systems place the PCB at the beginning of the kernel stack for the process as it is a safe location.
Any Query??