0% found this document useful (0 votes)
3 views10 pages

Process Management

The document provides an overview of process management, defining processes and programs, and detailing types of processes such as processor-bound and I/O-bound. It explains process creation, termination, life cycle, control blocks, context switching, and scheduling, including types of schedulers and scheduling policies. Additionally, it discusses job queues, ready queues, and the swapping mechanism for managing memory resources.

Uploaded by

deepthi dayasena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views10 pages

Process Management

The document provides an overview of process management, defining processes and programs, and detailing types of processes such as processor-bound and I/O-bound. It explains process creation, termination, life cycle, control blocks, context switching, and scheduling, including types of schedulers and scheduling policies. Additionally, it discusses job queues, ready queues, and the swapping mechanism for managing memory resources.

Uploaded by

deepthi dayasena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Process Management

Process
A process is basically a program in execution. Process is not a program. A
program may have many processes. It contains the program code and its current
state.
Program
A computer program is a sequence of instructions, written to perform a
specified task with a computer.
Ex. “notepad.exe” is a program containing set of instructions which help us
to edit and print text files. When we run multiple instances of notepad program,
each instance is called a process.
Types of processes
1. Processor Bound Processes
Processes which spend the majority of their time using the CPU
(doing calculations). In Processor Bound Processes, the time it takes
to complete a computation is principally determined by the speed of
the Central processing unit.

2. I/O Bound Processes


Processes which are mostly associated with input/output based
activity like reading/writing from files, etc. In I/O Bound Processes,
the time it takes to complete a computation is principally determined
by the period it spent waiting for input/output operations to be
completed.
Process requirements
The process must have (at least):
 ID
 Executable code
 Data needed for execution
 Execution context (priorities, waiting for I/O or not)
Process creation
Reasons for process creation:
 User starts a program
 OS creates a process to provide a service
 Running program starts another process
Process Termination
On process termination, OS reclaims all resources assigned to the process.
Reasons for process termination:
 Normal termination
 Execution time-limit exceeded
 A resource requested is unavailable
 An execution error
 A memory access violation
 An operating system or parent process request
 Parent process has terminated.
Interrupts and Interrupts Handling
An interrupt is a signal to the processor from a device that requires attention.
For example when a disk driver has finished transferring the requested data, it
generates and sends an interrupt to the processor to inform that the task is over.
Interrupt Handling
I/O models are slower than the processor. After each I/O call, the processor
has to sit idle until I/O device completes the operation, so processor saves the
status of current process and begin executing some other processes. When I/O
operation is over, I/O devices issue an interrupt to the processor then it stores back
the original process and resumes execution.
Process Life Cycle
When a process executes, it passes through different states. In general, a
process can have one of the following seven states at a time.
1. New - Contains the processes which are newly coming for
execution.
2. Ready – Contains the processes which are in the main memory
and available for execution.
3. Running - Contains the processes which are being running or
executing at the moment.
4. Exit - Contains the processes which are completely executed.
5. Blocked - Contains the processes which are in the main memory
and awaiting for an event occurrence.
6. Blocked Suspend - Contains the processes which are in the
secondary memory and awaiting for an event occurrence.
7. Ready Suspend - Contains the processes which are in the
secondary memory but is available for execution as soon as it is
loaded into main memory.

Seven state process transition Diagram


Process Transitions
New Ready or New Ready Suspend
When a new process is created it can either be added to the ready
queue or Ready Suspend queue.
Running Ready
A Running process can be moved to Ready state when its time
allocation expires.
Blocked Blocked Suspend
If there are no Ready processes, Blocked processes are moved to the
secondary memory to make room for new processes.
Blocked Suspend Blocked
This transition might occur when there is a process in the Blocked
Suspend queue with a high priority than processes in the Ready queue.
Blocked Suspend Ready Suspend
A process in the Blocked Suspend state is moved to Ready Suspend
state when the event for which it has been waiting for occurs.
Ready Ready Suspend
To free up sufficiently large memory for a new process OS may
Swap Ready processes to Ready Suspend.
Process Control Block (PCB)
A Process Control Block is a data structure maintained by the Operating
System for every process. The PCB is identified by an integer called process ID
(PID). A PCB keeps all the information need to keep track of a process. The PCB
is maintained for a process throughout its lifetime, and is deleted once the process
terminates.
Context Switching
 A context switch is the mechanism to store and restore the state or
context of a CPU in Process Control block so that a process
execution can be resumed from the same point at a later time.
 Using this technique a context switcher enables multiple processes
to share a single CPU. Context switching is an essential part of a
multitasking operating system features.
 When the scheduler switches the CPU from executing one process
to execute another, the context switcher saves the content of all
processor registers for the process being removed from the CPU,
in its process control block.
 When a process is switched, the following information is stored
for later use.
 Program Counter
 Currently used registers
 Changed State
 I/O State information
 Accounting information (the amount of CPU used for
process execution, time limits)
Process Scheduling
Process scheduling is the activity of an operating system that handles the
removal of the running process from the CPU and the selection of another process
to be executed on the basis of a particular strategy. Process scheduling is an
essential part of a Multiprogramming operating systems.
Process Schedulers
Schedulers are special system software which handle process scheduling in
various ways. Their main task is to select the jobs to be submitted into the system
and to decide which process to run.
A scheduler may aim at one or more of many goals, for example:
maximizing Throughput (Total number of processes completed per unit time),
minimizing Wait time (The amount of time a process spends in the ready queue
waiting until its turn to use the CPU), minimizing Response time (the amount of
time it takes to respond to a request for service) or minimize Turnaround time
(the amount of time required for a particular process to complete, from submission
to completion).
There are three type of schedulers.
1. Long-Term Scheduler
2. Medium-Term Scheduler
3. Short-Term Scheduler

1. Long-Term Scheduler (job scheduler)


 Determines which programs are admitted to the system for
processing.
 Selects processes from the job queue and loads them into memory
for execution.
 Controls the degree of multiprogramming.
Long-Term scheduler may attempt to keep a mix of processor-
bound and I/O-bound processes (If all processes are I/O-bound, the
ready queue will almost always be empty, and if all processes are
CPU-bound, the I/O waiting queue will almost always be empty).
2. Medium-Term Scheduler
 Medium-Term schedulers are in charge of swapping processes
between the main memory and the secondary storage.
 Medium-term scheduler may decide to swap out a process which
has not been active for some time, or a process which has a low
priority, or a process which is taking up a large amount of memory
in order to free up main memory for other processes.
 Reduces the degree of multiprogramming.

3. Short-Term Scheduler (CPU Scheduler)


 Decides which of the ready, in-memory processes is to be executed
next and allocates the CPU to one of them.
 Also known as the dispatcher (dispatching processes to the CPU).
 Dispatching is carried out after a clock interrupt, an I/O interrupt,
or an operating system call.

Job queue/ Job pool


Job queue is the list of processes that resides in mass storage/secondary
storage and awaits main memory allocation.
Ready queue
The list of processes that resides in main memory and are ready and waiting
for execution.
Scheduling Policies
Non-preemptive and Preemptive
Non-preemptive scheduling is designed so that once a process enters
the running state, it cannot be preempted/interrupted until it completes its
allocated time.
Preemptive scheduling is based on priority and a scheduler may
preempt/interrupt a low priority running process anytime when a high
priority process enters into a ready state. The running process is interrupted
for some time and resumed later when the high priority process has finished
its execution.
Swapping
Swapping is a mechanism in which a process can be moved temporarily out
of main memory to secondary storage and make that memory available to other
processes. At some later time, the system moves back the process from the
secondary storage to the main memory.

You might also like