Scheduling Concepts: I) Increased CPU Utilization Ii) Higher Throughput
Scheduling Concepts: I) Increased CPU Utilization Ii) Higher Throughput
Scheduling Concepts: I) Increased CPU Utilization Ii) Higher Throughput
In Multiprogramming we run many processes at the same time in order to improve CPU
utilization. In uni programming CPU sits idles when a running process needs I/O
operation, but in multiprogramming when one process needs I/O operation, then
operating system gives the CPU to another process.
We have two processes P1 and P2. First we run P1 that takes two minutes to complete,
then we run P2 that also takes two minutes to complete. Although the process execution
for each process is 1 minute but due to I/O operations both processes took double-time to
complete. So our CPU utilization is only 50 percent.
Process P1
P2
start idle stop
Process execution with Multiprogramming
Scheduling Queues
Job Queue
Job Queue consists of all processes residing in mass storage and waiting for the allocation
of main memory.
Ready Queue
The processes that are residing in main memory and are
ready to execute are kept in a list called the Ready Queue.
So, all the processes that are in ready state and waiting
for CPU time are considered to be part of ready queue.
Device Queue
Device Queue consists of processes that are waiting for
some I/O device. So, all the processes that are in waiting
or blocked state are considered to be part of device
queue. Each device has its own device queue.
Types of Schedulars
Long Term Schedular or Job Schedular or admission scheduler
selects processes present in the Job Queue and loads them into memory for execution.
Context Switch
Switching the CPU to another process requires saving the state of the old process
and loading the saved state for the new process. This task is known as a context switch.
Context Switch time is pure overhead and depends upon the speed of memory and
number of registers etc.
i) Context switching
ii) Switching to user mode
iii) Jumping to the location in the user program to restart that program.
Scheduling Algorithms
Criteria for comparing CPU-scheduling Algorithms include the following:
1. CPU Utilization: To keep the CPU as busy as possible we would like the
CPU to be utilized as much as we can.
P1 P2 P3
0 24 27 30
If these processes are executed using FCFS algorithm then the waiting time for
process P1 is 0 ms, 24 ms for P2 and 27 ms for P3. So, the average waiting time is
(0+24+27) / 3 = 17 ms. If the process arrive in the order P2, P3 and P1 then the average
waiting time is (6+0+3) / 3 = 3 ms.
P2 P3 P1
0 3 6 30
So the average waiting time in FCFS Scheduling Algorithm depends upon the
CPU burst times of processes.
P1 = 6, P2 = 8, P3 = 7 and P4 = 3 ms.
P4 P1 P3 P2
0 3 9 16 24
Waiting time for P1 is 3 ms, 16 ms for P2 and 9 ms for P3 and 0 ms for P4. So,
the average waiting time is (3+16+9+0) / 4 = 7ms. The average waiting time for this
Situation is FCFS scheduling is 10.25 ms.
A set of processes arrive at time 0 have following CPU burst time and priority.
The processes will be scheduled in the following order using priority scheduling
and the average waiting time calculated is 8.2 ms.
P2 P5 P1 P3 P4
0 1 6 16 18 19
Internal or External priorities can be defined in Priority Scheduling. Internally
defined priorities use measurable quantities i.e. time limits or memory requirements etc.
Externally defined priorities are set by criteria that are external to the Operating System
i.e. amount of funds paid, department sponsoring the work etc.
Priority scheduling can be preemptive or non-preemptive. Preemptive priority
assigns the CPU to the newly arrived process if its priority is higher than the currently
running process. In non-preemptive priority the newly arrived process will be at the head
of the ready queue and CPU will be assigned to this process when the currently running
process will finish.
Starvation the problem in Priority scheduling is that it will leave low priority processes
waiting for CPU for a long time and this problem is called Starvation.
Aging the solution for starvation is aging. In this technique a waiting process priority is
increased after a fixed time. So, even a process of low priority will execute, as its priority
will be increased within few hours or days.
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
Interactive Processes
Batch Processes
Lowest Priority
Student Processes
Quantum = 8
Quantum = 16
FCFS
Multilevel Feedback queue is a very general scheduling scheme but is also the
most complex.
Algorithm Evaluation
In algorithm evaluation, we evaluate different scheduling algorithm and try to find
the efficiency of scheduling algorithms depending upon certain conditions. There are
many evaluation methods that can be used for this purpose.
Analytic Evaluation
Is an important class of evaluation in which different techniques can be used for
finding the efficiency of algorithms.
Deterministic Modeling
In this method we check the performance of different algorithms for a defined
workload i.e.
P1 = 0
P2 = 10+3+7+10+2 = 32
P3 = 20
P4 = 23
P5 = 30+10 = 40
0 + 32 + 20 + 23 + 40 = 115/5 = 23ms
An equation
n= λxw
known as Little’s formula and can be used for determining the efficiency of
scheduling algorithm.
n is the queue length, λ is the average arrival rate for new processes in the queue
and w is the waiting time.
If 7 processes arrived every second and queue length is 14 then average waiting
time per process can be calculated i.e. 2 seconds
n= λxw
w=n/λ
w = 14 / 7 = 2 Seconds.
Simulations
Can be used for accurate evaluation of scheduling algorithms. In simulations we
monitor the real system and record the sequence of actual events and then we use this
sequence in our simulation i.e. a model of the computer system, Programmed.