0% found this document useful (0 votes)
2 views10 pages

Bsit Rough Draft

The document compares various CPU scheduling algorithms including FCFS, SJF (both non-preemptive and preemptive), HRRN, and Round Robin with different quantum values. It provides Gantt charts, per-process results, and average metrics for waiting time, turnaround time, and response time for each algorithm. The analysis concludes that SJF (preemptive) yields the best average metrics, while Round Robin shows increased waiting and turnaround times with larger quantum values.

Uploaded by

baburaja2063
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Bsit Rough Draft

The document compares various CPU scheduling algorithms including FCFS, SJF (both non-preemptive and preemptive), HRRN, and Round Robin with different quantum values. It provides Gantt charts, per-process results, and average metrics for waiting time, turnaround time, and response time for each algorithm. The analysis concludes that SJF (preemptive) yields the best average metrics, while Round Robin shows increased waiting and turnaround times with larger quantum values.

Uploaded by

baburaja2063
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1) FCFS (First Come First Served)

Gantt (time slots 0 - 15):

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

P1 P1 P1 P1 P1 P1 P1 P2 P2 P2 P2 P3 P4 P4 P4 P4

Per-process results:

● P1: initial 0, final 7, turnaround 7, waiting 0, response 0.


● P2: completion 7, plan 11, waiting 5, turnaround 9, response 5.
● P3, gen 11, completion 12, turnaround 8, wait time 7, response 7.
● P4: 12 16 11 7 turnaround 7 11 waiting 7 response 14.

Averages:

● Average waiting time = 4.75


● Average turnaround time = 8.75
● Average response time = 4.75

2) SJF Non-preemptive ( oldest job first, non-


preemptive )
Gantt (0 - 15):
P1 P1 P1 P1 P1 P1 P1 P3 P2 P2 P2 P2 P4 P4
P4 P4
Per-process:
P1: initial 0, completion 7, turnaround 7,
waiting time 0, response time 0.
P3: initial 7, final 8, turnaround = 4,
waiting =3, response=3.

P2: start 8, completion 12, turnaround = 10,


waiting = 6, response = 6.

P4: initial position = 12, final position = 16,


turnaround=11, waiting=7, response=7

Averages:
Average waiting time = 4.00

Average turnaround time = 8.00

Average response time = 4.00

(Non-preemptive SJF had lower average


waiting and turnaround than FCFS since the
short job P3 had been scheduled earlier when
P1 had completed its execution)
3) SJF Preemptive (SRTF: Shortest Remaining
Time First).
This will be SJF but then would expect a new
job with even less amount of time left in case it
would be awarded.
Gantt (0 - 15):
P1 P1 P2 P2 P3 P2 P2 P4 P4 P4 P4 P1 P1 P1
P1 P1
Per-process:
P1: start 0, completion 16, turnaround 16,
waiting 9, response 0.

P2: initial Q 2, final Q 7, turnaround Q 5,


wait Q 1, response Q 0.

P3: initial 4, final 5, turnaround 1, wait 0,


response 0.

Initial state in all the above is 7, final is 11,


turnaround is 6, wait 2 and response 2.
4) HRRN (Highest Response Ratio Next)
HRRN calculates highest response ratio of the
job = (waiting + service)/service).
Gantt (0 - 15):
P1 P1 P1 P1 P1 P1 P1 P3 P2 P2 P2 P2 P4 P4
P4 P4
Per-process:
P1: start 0, completion 7, turnaround 7,
waiting 0, response 0.

P3: inception 7, and termination 8,


turnaround time = 4, waiting time = 3 and
response = 3.

P2: start 8, completion 12, turnaround = 10,


waiting = 6, response = 6.

P4: start 12, completion 16, turnaround =


11, and waiting = 7, response = 7.
Averages:
Average waiting time = 4.00

Average turnaround time = 8.00

Average response time = 4.00

Here HRRN was like non-preemptive SJF


according to ordering and provided the same
averages.

5) Round Robin (RR) -- Quantum = 1


Gantt (0 - 15):
P1 P1 P1 P1 P2 P1 P1 P1 P3 P2 P4 P2 P2 P4
P4 P4
Per-process:
P1: commencement 0, finish 12, turnaround
12, waiting time 5, response time 0.
P2: s-value of 4, a final s-value of 15,
turnaround = 13, waiting = 9, response = 2.

P3: start 8, completion 9, turnaround = 5,


waiting= 4, response= 4.

P4: start 10, completion 16, turnaround =


11, waiting 7 response = 5.

Averages:
Average waiting time = 6.25

Average turnaround time = 10.25

Average response time = 2.75

Small scheduling (quantum =1) switches


between ready processes and processes before
them fast, - good in terms of fairness/response,
but more switching and waiting/turnaround
than SJF)
6) Round Robin (RR) -- Quantum = 3
Gantt (0 - 15):
P1 P1 P1 P1 P1 P1 P2 P2 P2 P1 P3 P4 P4 P4
P2 P4
Per-process:
P1: beginning 0, end 14, turnaround time
14, waiting time 7, response time 0.

P2: 6 start, 15 completion, 13 turnaround, 9


waiting, 4 response.

P3, initial (10) - final (11), waiting (6),


response (6) with turnaround (7).

P4: start 11, completion 16, turnaround =


11, waiting = 7, response = 6

Averages:
Average waiting time = 7.25

Average turnaround time = 11.25


Average response time = 4.00

Over long bursts, (As larger quantum RR


begins to behave rather like non-preemptive
FCFS) response time [Link]
comparison (averages summarized)
Algorithm Avg waiting Avg turnaround Avg response

FCFS 4.75 8.75 4.75

SJF (non-preemptive) 4.00 8.00 4.00

SJF (preemptive / SRTF) 3.00 7.00 0.50

HRRN 4.00 8.00 4.00

RR (q = 1) 6.25 10.25 2.75

RR (q = 3) 7.25 11.25 4.00

“Round Robin is also referred to as preemptive


FCFS"justification ( simple )
FCFS: The jobs are served off the queue as
they come; once a job is commenced it is
executed to the completion (non-preemptive).

Round Robin Jobs are placed into a ready


queue as well in FIFO (therefore arrival order
counts) and the job at the head of the queue is
scheduled, but after a time slice (quantum) the
job running is preempted and set at the tail of
the queue unless it finishes.

Thus RR maintains the order of


arrival/queues as in FCFS but Ruth it
preempts jobs repeatedly (time-slicing) to allow
other jobs to access the CPU.

Minuscule example (with these processes,


quantum = 1):
FCFS would first operate P1 then P2 then
P3 then P4.

RR (q=1) begins with P1 (secondly like


FCFS), but once 1 unit is already made it
preempts and places P1 at the end of the queue,
executes the next ready job and repeats this
actions and thus the order of access to the
ready queue is FIFO, but the switching
between jobs is preemptive (RR). It is the
reason why we can say that RR is preemptive
FCFS: it is FCFS queueing order and
preemption/time-slices.

If you want, I can:


present the Gantt charts in a mat or
diagram which is clean, or

repeat the RR example using another


quantum and depict precise time slices, or

Provide stepwise descriptions (where


applicable: how waiting/turnaround/response
were computed) in clear language of any of the
per-process calculations.

You might also like