OPERATING SYSTEM(CA457)
ASSIGNMENT-1
Submitted To: Submitted By:
GAURAV PANDEY SIR RUPESH KUMAR SINGH (MCA/10002/19)
1. Consider the following scenario, there are five processes with burst time
Process Burst Time (ms) Priority
P1 1 1
P2 1 1
P3 2 4
P4 1 5
P5 5 2
The processes are assumed to have arrived in order P1, P2, P3, P4, P5 all at
time 0.find the turnaround time of each process for each of the following scheduling algorithms
FCFS, SJF, a non-pre-emptive priority (a smaller priority implies a higher priority) and RR
(quantum=1) scheduling. also, draw the Gantt chart. (5)
SOLUTION
FCFS
Process Arrival Time Burst Time Turn Around Time
P1 0 1 1
P2 0 1 2
P3 0 2 4
P4 0 1 5
P5 0 5 10
GANTT CHART
P1 P2 P3 P4 P5
0 1 2 4 5 10
Average turn around time= 22/5 = 4.4ms.
SJF
Process Arrival Time Burst Time Turn Around Time
P1 0 1 1-0=1
P2 0 1 2-0=2
P3 0 2 5-0=5
P4 0 1 3-0=3
P5 0 5 10-0=10
GANTT CHART
P1 P2 P4 P3 P5
0 1 2 3 5 10
Average Turn Around Time=21/5=4.2ms
Round Robin
Process Arrival Time Burst Time Turn Around Time
P1 0 1 1-0=1
P2 0 1 2-0=2
P3 0 2 6-0=6
P4 0 1 4-0=4
P5 0 5 10-0=10
READY QUEUE
P1 P2 P3 P4 P5 P3 P5
GANTT CHART
P1 P2 P3 P4 P5 P3 P5
0 1 2 3 4 5 6 10
-Average Turn Around Time=23/5=4.6ms
2 .What is starvation? Which scheduling does not suffer from starvation
explain with an example.
Ans:-
A process which is ready to run can wait idefinitely because of low priority.
Starvation is the problem that occurs when high priority processes keep executing and low
priority processes get blocked for identifinite time.in starvation resources arev continosaly
utilize by high prority.
Scheduling algorithm does not suffer from starvation
First come first serve(FCFS):- the simplest CPU-scheduling algorithm is the
first-come, first-served (FCFS) scheduling algorithm. With this scheme, the
process that requests the CPU first is allocated the CPU first. The implementation
of the FCFS policy is easily managed with a FIFO queue. When a process enters
the ready queue, its PCB is linked onto the tail of the queue. When the CPU is
free, it is allocated to
the process at the head of the queue. The running process is then removed
fromthe queue. The code for FCFS scheduling is simple to write and understand.,
so it will not suffer from starvation.
FCFS example
Process Duration Order Arrival time
P1 28 1 0
P2 5 2 0
P3 6 3 0
Gantt chart :
P1 P2 P3
28 5 6
P1 waiting time:0
P2 waiting time:28
P3 waiting time:33 The Avberage waiting time=(0+28+33)/3=39
Round Robin(RR):- The round-robin (RR) scheduling algorithm is designed
especially for timesharing systems. It is similar to FCFS scheduling, but
preemption is added to enable the system to switch between processes. A small
unit of time, called atime quantum or time slice, is defined. A time quantum is
generally fronc 10 to 100 milliseconds in length. The ready queue is treated as a
circular queue. The CPU scheduler goes around the ready queue, allocating the
CPU to each process for a time interval of up to 1 time quantum. To implement
RR scheduling, we keep the ready queue as a FIFO queue o£ processes. New
processes are added to the tail of the ready queue. The CPU scheduler picks the
first process from the ready queue, sets a timer to interrupt after 1 time
quantum, and dispatches the process.
Round Robin example:-
Process Duration Order Arrival time
P1 4 1 0
P2 3 2 0
P3 3 3 0
(quantum=1 unit)
P1 P2 P3 P1 P2 P3 P1 P2 P3 P1
P1 Wt time =6
P2 wt time=4
P3 wt time=6
Average wt time(awt)=(4+6+6)/3=5.33