(A) FCFS:: Solution: T .A.T Copletion Time-Arrival Time

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

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: T .A.T= COPLETION TIME-ARRIVAL TIME

(a)FCFS: Since the arrival time of p1,p2,p,..p5 is 0 and it is mentioned in question they come in the order

P1->P2->P3->P4->P5 . So processor is allocated on the basis of their order.

Gantt chart:
P1 P2 P3 P4 P5
0 1 2
4 5 10

ANSWER:

PROCESS NO. ARRIVAL TIME BURST TIME COMPLETION TURN AROUND


TIME TIME=CT-AT
PROCESS 1 0 1 1 1-0= 1
PROCESS 2 0 1 2 2-0=2
PROCESS 3 0 2 4 4-0=4
PROCESS 4 0 1 5 5-0=5
PROCESS 5 0 5 10 10-0=10

(b)SJF: shortest job first is basically non pre-emptive ,since nothing is mentiond about preemption or non

Preemption considering non preemption shortest job first.

Sequence of arrival: P1->P2->P3->P4->P5

1
Gantt chart:

P1 P2 P4 P3 P5

0 1 2 3 5 10
Answer:

PROCESS NO. ARRIVAL TIME BURST TIME COMPLETION TURN AROUND


TIME TIME=CT-AT
PROCESS 1 0 1 1 1-0= 1
PROCESS 2 0 1 2 2-0=2
PROCESS 3 0 2 5 5-0=5
PROCESS 4 0 1 3 3-0=3
PROCESS 5 0 5 10 10-0=10
Non pre-
emptive
priority:(low value high priority): in non pre –emptive priority scheduling process with high priority executed
.if during its execution another process come with priority higher then current executing

Process then after completion of execution current process ,processor is allocated to next process

Sequence of arrival: P1->P2->P3->P4->P5.

Gantt chart:

P1 P2 P5 P3 P4

0 1 2 7 9 10

Answer:

PROCESS NO. ARRIVAL PRIORITY BURST TIME COMPLETION TURN


TIME TIME AROUND
TIME=CT-AT
PROCESS 1 0 1 1 1 1-0= 1
PROCESS 2 0 1 1 2 2-0=2
PROCESS 3 0 4 2 9 9-0=9
PROCESS 4 0 5 1 10 10-0=10
PROCESS 5 0 2 5 7 7-0=7

2
ROUND –ROBIN:

Time quantum: 1ms

Gantt chart:
P1 P2 P3 P4 P5 P3 P5 0
1 2 3
4 5 6 10

ANSWER:

PROCESS NO. ARRIVAL TIME BURST TIME COMPLETION TURN AROUND


TIME TIME=CT-AT
PROCESS 1 0 1 1 1-0= 1
PROCESS 2 0 1 2 2-0=2
PROCESS 3 0 2 6 6-0=6
PROCESS 4 0 1 4 4-0=4
PROCESS 5 0 5 10 10-0=10
Q2. What is
starvation? Which scheduling does not suffer from starvation explain with an example.

Answer : Starvation is a type of situation in which process under goes indefinitely in waiting state

For resources and never get resource to complete its execution.. starvation can occur in SJF ,SRTF,

FCFS,PRIORITY scheduling ,

Starvation in SJF & SRTF : this scheduling algorithm can cause starvation to some process p, if just before

currently running process completes its burst time another process always arrive with burst time

smaller then p

Starvation in FCFS : smaller FCFS does not gurantees that starvation will not occur if any pocess arrive

Infinite burst time then this process starve all the process in ready queue.

Starvation in priority : in this scheduling there is more possibilty of starvation can occur ,if any process

P is have less priority and the all arriving process high priority then process p will go on starvation.

How round robin prevent starvation:


Round robin scheduling algorithm ensure that no process will starve by allocating

Fixed time quantum to each process for execution and by context switching after every time quantum.

Let us consider given p1,p2,p3,p4…..p infinte process and each process require burst time (random no ) 1 ,5 ,6,9.

…… upto infinite.

If we use FCFS then process that comes in last has to wait until (last-1) process complete their execution, In case
3
of shortest job first a process which have highest burst time have to wait until all process complete their burst time ,

now , come to the point how round robin prevent starvation.

Round robin maintain a circular ready queue in all process that are raeady for execution are kept and this

Process are allowed to use cpu for some fixed time (time quantum) after that cpu is allocated to next process . every

Process after completing their burst time further enqueued into circular ready queue

Irrespective of process arrival time ,burst time and priority cpu is allocated to each process for fixed burst time.

If process p arrives at ready queue an it is at nth position then p has to wait for only .(n-1)*(time quantum)

Which always less then wait time of process in fcfs and srtf .

You might also like