Assignment
Assignment
P0 0-0=0
P1 5-1=4
P2 8-2=6
P3 16 - 3 = 13
P0 0 5 0
P1 1 3 5
P2 2 8 14
P3 3 6 8
Waiting time of each process is as follows −
P0 0-0=0
P1 5-1=4
P2 14 - 2 = 12
P3 8-3=5
P0 0 5 1 0
P1 1 3 2 11
P2 2 8 1 14
P3 3 6 3 5
P0 0-0=0
P1 11 - 1 = 10
P2 14 - 2 = 12
P3 5-3=2
P0 (0 - 0) + (12 - 3) = 9
P1 (3 - 1) = 2
P3 (9 - 3) + (17 - 12) = 11
Average Wait Time: (9+2+12+11) / 4 = 8.5
Multiple-level queues are not an independent scheduling algorithm. They make use
of other existing algorithms to group and schedule jobs with common
characteristics.
FCFS may suffer from the convoy effect if the burst time of the first job is the highest
among all. As in the real life, if a convoy is passing through the road then the other
persons may get blocked until it passes completely. This can be simulated in the
Operating System also.
If the CPU gets the processes of the higher burst time at the front end of the ready
queue then the processes of lower burst time may get blocked which means they
may never get the CPU if the job in the execution has a very high burst time. This is
called convoy effect or starvation.
Answer:
Ques 9) Explain Shortest-Job First Scheduling (SJF) and its advantage and
disadvantage.
Answer:
Advantages –
1. Shortest jobs are favored.
2. It is provably optimal, in that it gives the minimum average
waiting time for a given set of processes.
Disadvantages –
3. SJF may cause starvation, if shorter processes keep coming.
This problem is solved by aging.
4. It cannot be implemented at the level of short term CPU
scheduling.
Ques 10) Explain Priority Scheduling and its advantage and disadvantage.
Answer:
The processes with higher priority should be carried out first, whereas jobs with
equal priorities are carried out on a round-robin or FCFS basis. Priority depends
upon memory requirements, time requirements, etc.
If the system eventually crashes, all low priority processes get lost.
If high priority processes take lots of CPU time, then the lower priority
processes may starve and will be postponed for an indefinite time.
This scheduling algorithm may leave some low priority processes waiting
indefinitely.
A process will be blocked when it is ready to run but has to wait for the CPU
because some other process is running currently.
If a new higher priority process keeps on coming in the ready queue, then the
process which is in the waiting state may need to wait for a long duration of
time.
Ques 11) Explain Round-Robin Scheduling and its advantage and
disadvantage.
Answer:
The name of this algorithm comes from the round-robin principle, where each person
gets an equal share of something in turns. It is the oldest, simplest scheduling
algorithm, which is mostly used for multitasking.
In Round-robin scheduling, each ready task runs turn by turn only in a cyclic queue
for a limited time slice. This algorithm also offers starvation free execution of
processes.
Ques 12) Explain Multilevel Queue Scheduling and its advantage and
disadvantage.
Answer:
It may happen that processes in the ready queue can be divided into different
classes where each class has its own scheduling needs. For example, a common
division is a foreground (interactive) process and a background (batch) process.
These two classes have different scheduling needs. For this kind of situation
Multilevel Queue Scheduling is used. Now, let us see how it works.
Ready Queue is divided into separate queues for each class of processes. For
example, let us take three different types of processes System processes,
Interactive processes, and Batch Processes. All three processes have their own
queue. Now, look at the below figure.
Advantages –
1. Application of separate scheduling for various kind of processes is
possible.
System Process – FCFS
Interactive Process – SJF
Batch Process – RR
Student Process – PB
Disadvantages –
1. The lowest level process faces starvation problem.
Answer:
Advantages –
1. Low scheduling overhead.
2. Allows aging, thus no starvation.
Disadvantages –
1. It’s not flexible.
2. It also requires some means of selecting values for all the parameters to
define the best scheduler, thus it is also the most complex.
Ques 14)
Consider the following set of processes:
Answer:
Ques 15)
Consider the following set of processes:
Process Arrival Time Burst Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
Calculate waiting time, average waiting time, and turnaround time.
I.FCFS
II.SJF
III.SRTF
Answer:
Ques 16)
Consider the following set of processes:
Answer:
Ques 17)
Consider the following set of processes:
Process Burst Time
P1 53
P2 17
P3 68
P4 24
Time Quantum: 20
Calculate waiting time, average waiting time, and turnaround time.
I. FCFS
II. SJF
III. SRTF
IV. Round Robbin
Answer: