You are on page 1of 10

UNIT II

PROCESS MANAGEMENT
PROCESS SCHEDULING

1. SCHEDULING is the method by which work is assigned to


resources that complete the work. 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.
2. SCHEDULER is what carries out the scheduling activity.
Schedulers are often implemented so they keep all computer
resources busy (as in load balancing), allow multiple users to
share system resources effectively, or to achieve a target quality
of service makes it possible to have computer multitasking with a
single central processing unit (CPU).
A scheduler may aim at one or more goals, for example:

∙ maximizing throughput (the total amount of work completed


per time unit);
∙ minimizing wait time (is the total time spent by the process in
the ready state waiting for CPU.);
∙ minimizing latency or response time (time spent between the
ready state and getting the CPU for the first time. But the
waiting time is the total time taken by the process in the
ready state);
∙ maximizing fairness (equal CPU time to each process, or
more generally appropriate times according to the priority
and workload of each process).
3. PROCESS SCHEDULING is an OS task that schedules
processes of different states like ready, waiting, and running.

∙ Process scheduling allows OS to allocate a time interval of


CPU execution for each process. Another important reason
for using a process scheduling system is that it keeps the
CPU busy all the time. This allows you to get the minimum
response time for programs.

∙ Process scheduling is an essential part of a Multiprogramming


operating systems. 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.

4. PROCESS SCHEDULING QUEUES

∙ The OS maintains all PCBs in 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.
Three types of operating system queues are:
1. Job queue – It helps you to store all the processes in the
system.
2. Ready queue – This type of queue helps you to set every
process residing in the main memory, which is ready and
waiting to execute.
3. Device queues – It is a process that is blocked because of the
absence of an I/O device.
In the above-given Diagram,
∙ Rectangle represents a queue.

∙ Circle denotes the resource

∙ Arrow indicates the flow of the process.

1. Every new process first put in the Ready queue .It waits in
the ready queue until it is finally processed for execution.
Here, the new process is put in the ready queue and wait until
it is selected for execution or it is dispatched.
2. One of the processes is allocated the CPU and it is
executing 3. The process should issue an I/O request
4. Then, it should be placed in the I/O queue.
5. The process should create a new subprocess
6. The process should be waiting for its termination. 7. It should
remove forcefully from the CPU, as a result interrupt. Once
interrupt is completed, it should be sent back to ready queue.
5.TWO STATE PROCESS MODEL
Two-state process models are:
∙ Running
∙ Not Running

Running
In the Operating system, whenever a new process is built, it is
entered into the system, which should be running.
Not Running
The process that are not running are kept in a queue, which is
waiting for their turn to execute. Each entry in the queue is a point
to a specific process.
S.N. State & Description

1 Running
When a new process is created, it enters into the system as
in the running state.

2 Not Running
Processes that are not running are kept in queue, waiting
for their turn to execute. Each entry in the queue is a
pointer to a particular process. Queue is implemented by

using linked list. Use of dispatcher is as follows. When a


process is interrupted, that process is transferred in the
waiting queue. If the process has completed or aborted,
the process is discarded. In either case, the dispatcher
then selects a process from the queue to execute.

6. SCHEDULING OBJECTIVES
Here, are important objectives of Process scheduling
∙ Maximize the number of interactive users within acceptable
response times.
∙ Achieve a balance between response and utilization. ∙ Avoid

indefinite postponement and enforce priorities. ∙ It also should


give reference to the processes holding the key resources.

7.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.
Schedulers are of three types −
∙ Long-Term Scheduler
∙ Short-Term Scheduler

∙ Medium-Term Scheduler

LONG TERM SCHEDULER


 It is also called a job scheduler. A long-term scheduler
determines which programs are admitted to the system
for processing.
1.) It selects processes from the queue and
2.) loads them into memory for execution.
3.) Process loads into the memory for CPU scheduling.
 When a process changes the state from new to
ready, then there is use of long-term scheduler.
 It also regulates the degree of multi-programing.
However, the main goal of this type of scheduler is to
offer a balanced mix of jobs, like Processor, I/O jobs.,
that allows managing multiprogramming.

SHORT TERM SCHEDULER

∙ It is also called as CPU scheduler.

 Its main objective is to increase system performance in


accordance with the chosen set of criteria.
 It is the change of ready state to running state of the
process. CPU scheduler selects a process among the
processes that are ready to execute and allocates CPU to
one of them.
 Short-term schedulers, also known as dispatchers, make
the decision of which process to execute next.
 Short-term schedulers are faster than long-term
schedulers.
 The main goal of this scheduler is to boost the system
performance according to set criteria. This helps you to
select from a group of processes that are ready to execute
and allocates CPU to one of them.
 The dispatcher gives control of the CPU to the process
selected by the short term scheduler.
MEDIUM TERM SCHEDULER
 Medium-term scheduling is a part of swapping.
 It removes the processes from the memory.
 It reduces the degree of multiprogramming.
 The medium-term scheduler is in-charge of handling the
swapped out-processes.
 A running process may become suspended if it makes an
I/O request. A suspended processes cannot make any
progress towards completion. In this condition, to remove
the process from memory and make space for other
processes, the suspended process is moved to the
secondary storage. This process is called swapping, and
the process is said to be swapped out or rolled out.
Swapping may be necessary to improve the process mix.
 Medium-term scheduling is an important part of
swapping. It enables you to handle the swapped out-
processes. In this scheduler, a running process can become
suspended, which makes an I/O request.
 A running process can become suspended if it makes an
I/O request. A suspended processes can't make any
progress towards completion. In order to remove the
process from memory and make space for other processes,
the suspended process should be moved to secondary
storage.

Comparison among Scheduler


S.N. Long-Term Short-Term Medium-Term
Scheduler Scheduler Scheduler

1 It is a job scheduler It is a CPU It is a process


scheduler swapping
scheduler.
2 Speed is lesser Speed is fastest Speed is in between
than short term among other two both short and long
scheduler term scheduler.
3 It controls the It provides lesser It reduces the
degree of control over degree of
multiprogramming degree of multiprogramming.
multiprogramming

4 It selects processes It selects those It can re-introduce


from pool and processes which the process into
loads them into are ready to memory and
memory for execute execution can be
execution continued.

8.CONTEXT SWITCH
It is a method to store/restore the state or of a CPU in PCB.
So that process execution can be resumed from the same
point at a later time.
The context switching method is important for multitasking
OS.
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 state from the current running
process is stored into the process control block. After this,
the state for the process to run next is loaded from its own
PCB and used to set the PC, registers, etc. At that point, the
second process can start executing.
Context switches are computationally intensive since register
and memory state must be saved and restored.
To avoid the amount of context switching time, some
hardware systems employ two or more sets of processor
registers. When the process is switched, the following
information is stored for later use.
∙ Program Counter
∙ Scheduling information

∙ Base and limit register value

∙ Currently used register


∙ Changed State
∙ I/O State information

∙ Accounting information

Summary:
∙ Process scheduling is an OS task that schedules the processes
of different states like ready, waiting, and running. ∙ Two-state
process models are 1) Running, and )Not Running ∙ Process
scheduling maximizes the number of interactive users, within
acceptable response times.
∙ A scheduler is a type of system software that allows you to

handle process scheduling.


∙ Three types of the scheduler are 1) Long term 2) Short term 3)

Medium-term
∙ Long term scheduler regulates the program and select process

from the queue and loads them into memory for execution.
∙ The medium-term scheduler enables you to handle the

swapped out-processes.
∙ The main goal of short term scheduler is to boost the system

performance according to set criteria


∙ Long term is also known as a job scheduler, whereas the short

term is also known as CPU scheduler, and the medium term is


also called swapping scheduler.

You might also like