This document discusses different types of process schedulers in an operating system:
1. Long term schedulers determine which programs are admitted to the system and load them into memory.
2. Short term (CPU) schedulers select ready processes and allocate the CPU to one of them.
3. Medium term schedulers handle swapped out processes and can reintroduce processes back into memory.
Context switching allows multiple processes to share the CPU by storing and restoring a process's state from its process control block when switching between processes. This switching is computationally expensive so some hardware uses multiple register sets.
2. An operating system executes a variety of programs:
✦ batch system – jobs
✦ time-shared systems – user programs or tasks
textbook uses the terms job and process almost
interchangeably.
Process – a program in execution; process execution
must progress in sequential fashion.
A process includes:
✦ program counter
✦ stack
✦ data section
PROCESS SCHEDULING
3. As a process executes, it changes state
✦ new: the process is being created.
✦ Running: instructions are being executed.
✦ Waiting: the process is waiting for some event to
occur.
✦ Ready: the process is waiting to be assigned to a
process.
✦ Terminated: the process has finished execution.
4. Process termination
process executes last statement and asks the operating
system to decide it (exit).
✦ Output data from child to parent (via wait).
✦ Process’ resources are deallocated by operating system.
Parent may terminate execution of children processes
(abort).
✦ Child has exceeded allocated resources.
✦ Task assigned to child is no longer required.
✦ Parent is exiting.
✔ Operating system does not allow child to continue if its
parent terminates.
✔ Cascading termination.
5. Cooperating processes
independent process cannot affect or be
affected by the
execution of another process.
Cooperating process can affect or be affected by
the execution of another process
advantages of process cooperation
✦ information sharing
✦ computation speed-up
✦ modularity
✦ convenience
6. Definition:
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.
Process scheduling is an essential part of a
Multiprogramming operating system. Such
operating systems allow more than
one process to be loaded into the executable
memory at a time and loaded process shares the
CPU using time multiplexing.
7. 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,
it's PCB is unlinked from its current queue and moved to its
new state queue.
Job queue - This queue keeps all the processes in the
system.
Ready queue - This queue keeps set of all processes
residing in main memory, ready and waiting to execute. A
new process is always put in this queue.
Device queues - The processes which are blocked due to
unavailability of an I/O device constitute this queue.
9. Two State Process Model
1 .
2.
Running
When new process is created by
Operating System that process
enters into the system as in the
running state.
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
10. schedulers are special system softwares which
handles 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
1.long term scheduler
2.short term scheduler
3.medium term scheduler
Schedulers
11. long Term Scheduler:
it is also called job scheduler. long term scheduler determines
which programs are admitted to the system for processing.
job scheduler selects processes from the queue and loads them
into memory for execution. process loads into the memory
for cpu scheduling. the primary objective of the job scheduler is to
provide a balanced mix of jobs, such as i/o bound
and processor bound. it also controls the degree of
multiprogramming. if the degree of multiprogramming is stable,
then the average rate of process creation must be equal to the
average departure rate of processes leaving the system.
on some systems, the long term scheduler may not be available
or minimal. time-sharing operating systems have no long
term scheduler. when process changes the state from new to
ready, then there is use of long term scheduler.
12. Short Term Scheduler:
It Is Also Called CPU Scheduler. Main Objective Is
Increasing 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
Process Among The Processes That Are Ready To
Execute And Allocates CPU To One Of Them. Short Term
Scheduler Also Known As Dispatcher, Execute Most
Frequently And Makes The Fine Grained Decision Of
Which Process To Execute Next. Short Term Scheduler Is
Faster Than Long Term Scheduler.
13. Medium Term Scheduler:
Medium Term Scheduling Is Part Of The 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. Running Process May
Become Suspended If It Makes An I/O Request. Suspended
Processes Cannot Make Any Progress Towards Completion. In
This Condition, To Remove The Process From Memory And
Make Space For Other Process, 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.
14. S.N. Long Term
Scheduler
Short Term
Scheduler
Medium Term
Scheduler
1. It is a job scheduler It is a CPU
scheduler
It is a process
swapping scheduler.
2. Speed is lesser than
short term
scheduler
Speed is fastest
among other
two
Speed is in between
both short and
long term scheduler.
3. It controls the
degree of
multiprogramming
It provides lesser
control over
degree of
multiprogramming
It reduces the
degree of
multiprogramming.
4. It is almost absent
or minimal in
time sharing system
It is also minimal in
time
sharing system
It is a part of Time
sharing systems.
5. It selects processes
from pool and
loads them into
memory for
execution
It selects those
processes
which are ready to
execute
It can re-introduce
the process into
memory and
execution can be
continued.
15. CONTEXT SWITCH:
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 state from the current running
process is stored into the process control block. after this
completes, 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 begin executing.
16. context switches are computationally intensive since
register and memory state must be saved and restored
and 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