Processor Management Cpu Scheduling
Processor Management Cpu Scheduling
INTRODUCTION
The CPU allocation strategy is the key area of processor management and is
handled by the Operating system.
PROCESSOR SCHEDULING
1. Be Fair
2. Maximise Throughput
3. Maximise Number of Interactive Users
4. Minimise Overheads
5. Be Predictive
6. Balance Resource Use
7. Avoid Indefinite Postponement
8. Enforce Priority
9. Give Preferences to processes holding Key resources
10. Give better service to process exhibiting desirable behavior
11. Degrade gracefully under heavy loads
Process & Schedulers :
Types of Schedulers
c) The short term scheduler (also called the CPU scheduler) selects
from among the processes in memory which are ready to execute
and assigns the CPU to one of them.
f) It may also be very important that long term scheduler should take a
careful selection of processes i.e. processes should be combination
of CPU and I/O bound types.
Generally, most processes can be put into any of two categories: CPU
bound or I/O bound
If all processes are I/O bound, the ready queue will always be empty and the
short term scheduler will have nothing to do.
If all processes are CPU bound. no process will be waiting for I/O operation
and again the system will be unbalanced. Therefore, the long term scheduler
provides good performance by selecting combination of CPU bound and I/O
bound process.
2. Medium term scheduler:
a) Most of the processes require some I/O operation. In that case, it may
become suspended for I/O operation after running a while.
b) It is beneficial to remove these process (suspended) from main memory to
hard disk to make room for other processes.
c) At some later time these process can be reloaded into memory and continued
where from it was left earlier. This is said to be Context Switching. The
process is swapped in and swap out by the medium term scheduler.
(Context Switching)
d) The medium term scheduler has nothing to do with the suspended processes.
But the moment the suspending condition is fulfilled, the medium term
scheduler get activated to allocate the memory and swap in the process and
make it ready for commenting CPU resources.
e) In order to work properly, the medium term scheduler must be provided with
information about the memory requirement of swapped out processes which
is usually recorded at the time of swapping and stored in the related process
control block.
f) In term of the process state transition diagram the medium term scheduler
controls suspended to ready transition of swapped processes.
Some performance criteria that are frequently used optimizing goal are:
1. CPU Utilisation
2. Throughput
3. Turnaround Time
4. Waiting Time
5. Response Time
CPU Utilisation:
Turnaround Time:
It is the time interval, from the time of submission of a job to the time
of its completion.
It may be the sum of the periods spent waiting to get into memory,
waiting in the ready queue, CPU time and I/O operations etc.
Waiting Time:
Response time:
The Response time is the time a job has to wait in the ready queue
to get the CPU for the first time. (first response)
P1 P2 P3
0 24 27 30
2. Shortest-job-First (SJF)-Scheduling
Waiting time is
0 + 3 + 8 + 16 / 4 = 27/4 = 6.75 units of time.
If we were using the FCFS scheduling then the average waiting time will be
= (0 + 5 + 15 + 23)/4 = 43/4 = 10.75 units of time.
Shortest job first (SJF) may be implemented in either non- preemptive or
preemptive varieties (SJN, SRT).
In either case, whenever the SJF scheduler is invoked, it searches the ready
queue to find the job or the process with the shortest execution time. The
difference between the two (preemptive or non-Preemptive) SJF scheduler
lies in the condition that lead to invocation of the scheduler and
consequently the frequency of its execution.
Example: If there are 3 processes: P1, P2 and P3 which require the following
CPU time
P1 P2 P3 P1 P1 P1 P1
0 5 10 15 20 25 30 35
Context switching is the key consideration.
A priority is associated with each process and the scheduler always picks up
the highest priority process for execution from the ready queue.
Equal priority processes are scheduled FCFS. The level of priority may be
determined on the basis of resource requirements, processes characteristics
and its run time behaviour.
A multi queue scheduling algorithm partitions the ready queue into separate
queues. Processes are permanently assigned to each queue, usually based upon
properties such as memory size or process type. Each queue has its own
scheduling algorithm. The interactive queue might be scheduling by a round-
robin algorithm while batch queue follows FCFS.
As an example of multiple queues scheduling one simple approach to
partitioning of the ready queue into system processes, interactive processes and
batch processes which creates a three ready queues