0% found this document useful (0 votes)
51 views

Name:Chaitanya Santosh Mhetre. Roll No (24) .: Assignment No.14: Implement Scheduling Algorithms

This document contains an assignment submitted by a student named Chaitanya Santosh Mhetre with roll number 24. The assignment compares scheduling algorithms SJF, priority, and RR in terms of turnaround time and average waiting time. It also defines preemptive and non-preemptive scheduling, describes problems with FCFS scheduling, provides formulas for turnaround time and average waiting time, and draws Gantt charts and calculates metrics for sample processes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Name:Chaitanya Santosh Mhetre. Roll No (24) .: Assignment No.14: Implement Scheduling Algorithms

This document contains an assignment submitted by a student named Chaitanya Santosh Mhetre with roll number 24. The assignment compares scheduling algorithms SJF, priority, and RR in terms of turnaround time and average waiting time. It also defines preemptive and non-preemptive scheduling, describes problems with FCFS scheduling, provides formulas for turnaround time and average waiting time, and draws Gantt charts and calculates metrics for sample processes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name:Chaitanya Santosh Mhetre. Roll No(24).

Assignment No.14: Implement scheduling algorithms.


1. Compare SJF, Priority and RR with respect to turn around time and average waiting time.
Ans:
Shortest Job First (SJF) Round-Robin (RR)
Shortest Job First (SJF) executes the processes Round-Robin (RR) executes the processes based
based upon their burst time i.e. in ascending order upon the time quantum defined i.e. each process
of their burst times. is executed for a fixed amount of time.
SJF is also non-preemptive but its preemptive
version is also there called Shortest Remaining Round-Robin (RR) is preemptive in nature.
Time First (SRTF) algorithm.
The average waiting time for given set of
The average waiting time for given set of
processes is quite small and depends on the time
processes is minimum.
quantum.
The real difficulty with SJF is knowing the length
It is quite easy to implement RR.
of the next CPU request or burst.
Each process is executed and every user feels
A long process may never get executed and the
that his work is being done as the CPU gives
system may keep executing the short processes.
equal amount of time to each process.
In case of RR, if the time quantum is very small
In case of SJF, elapsed time should be recorded, then context switch takes place again and again
results in more overhead on the processor. after very short intervals of time which leads to
overhead.

2. State the conditions for preemptive and non-preemptive scheduling algorithm.


Ans:
Preemptive scheduling conditions: A preemptive scheduling allows a higher priority process
to replace a currently running process even its time slot is not completed or has not requested
for any IO.
Non-preemptive scheduling conditions: In non-preemptive scheduling once the CPU is
assigned to process the processor do not release until the completion of that process.

3. Give the reason of problems arises in FCS.


Ans:
First come first serve (FCFS) scheduling algorithm simply schedules the jobs according to
their arrival time. FCFS scheduling may cause the problem of starvation if the burst time of
the first process is the longest among all the jobs.

4. Write a formula for turnaround time.


Ans:
Turnaround time = Finding time – Arrival time

5. Write a formula for average waiting time.


Ans:
Average waiting time = (starting time – Arrival time)/ total number of process.

6. Draw the Gantt chart for above mention example.


Ans:
P1 P2 P3 P4
0 10 14 28 36

7. The jobs are scheduled for execution as follows:

Process Arrival Time Burst Time

1 IF Department
Name:Chaitanya Santosh Mhetre. Roll No(24).

P1 0 10
P2 1 4
P3 2 14
P4 3 8

i. Solve the problem by using FCFS and preemptive SJF

P1 P2 P3 P4
0 10 14 28 36

Waiting time = starting time – arrival time


P1 = 0 – 0 = 0
P2 = 10 – 1 = 9
P3 = 14 – 2 = 12
P4 = 28 – 3 = 25

Average waiting time = (0+9+12+25)/4 = 11.5 msc

P1 P2 P4 P1 P3
0 1 5 13 22 36

Waiting time = starting time – arrival time


P1 = 13 – 1 = 12
P2 = 1 – 1 = 0
P3 = 22 – 2 = 20
P4 = 5 – 3 = 2

Average waiting time = (12+0+20+2)/4 = 8.5 msc

ii. Find average waiting time using Gantt chart

P1 P2 P3 P4
0 10 14 28 36

Waiting time = starting time – arrival time


P1 = 0 – 0 = 0
P2 = 10 – 1 = 9
P3 = 14 – 2 = 12
P4 = 28 – 3 = 25

Average waiting time = (0+9+12+25)/4 = 11.5 msc

2 IF Department

You might also like