Hung_Nguyen_HA6
docx
keyboard_arrow_up
School
George Mason University *
*We aren’t endorsed by this school
Course
342
Subject
Industrial Engineering
Date
Feb 20, 2024
Type
docx
Pages
3
Uploaded by hungnguyen090600
Scheduling Algorithms
Part 1
First Come First Serve
Consider the following processes along with their burst time (in Calculate the average
waiting time if the processes arrive in the following order
Process
Burst Time in Ms
P1
20
P2
10
P3
5
Calculate the average waiting time if the processes arrive in the following order
(i)P1, P2, P3
(ii)P2, P3, P1
(i) Case 1:
Consider a case if processes P1, P2, P3 arrive
at the same time
say 0 ms in
the system in the order P1, P2, P3. The arrival of processes is represented in the Gantt chart
as shown below.
Gantt chart
P1
P2
P3
20 30
35
Process
Waiting Time
Turnaround Time
P1
0
20
P2
20
30
P3
30
35
Therefore, average waiting time = (0+20+30)/3 ms
= 16.67 ms
The average waiting time is 16.67 ms.
Turnaround Time = (20+30+35)/3 ms
= 28.33 ms
The average turnaround time is 28.33 ms.
Case 2:
Processes arrive in order P1, P2, P3, let us assume at 0 ms, 2 ms and 4 ms, respectively.
Arrival Time
:
Time
at which the process arrives in the ready queue.
Process
Burst Time
Arrival Time
P1
20
0
P2
10
2
P3
5
4
Gantt chart: Draw the Gantt Chart
0 2 4
P1
P2
P3
-----------------------------------
20
------------------------------------------------------
30
-------------------------------------------------------------------
35 Waiting time for process P1 = 0 ms
Waiting time for process P2 = 20 ms – 2 ms = 18 ms
Waiting time for process P3 = 30 ms- 4 ms = 26 ms
Calculate the average waiting time
(0+18+26)/3 = 14.67 ms
The average waiting time is 14.67 ms.
Calculate the Turnaround Time
Turnaround time = exit time – arrival time
Turn around for process P1 = 20 – 0 = 20 ms
Turn around for process P2 = 30 – 2 = 28 ms
Turn around for process P3 = 35 – 4 = 31 ms
(20+28+31)/3 = 26.33 ms
The average time for turnaround time is 26.33 ms.
Part 2
Round Robin Scheduling
Process
Burst Time in Ms
P1
4
P2
2
P3
1
Calculate the average waiting time and turnaround time using round robin scheduling, where the time
quantum q = 2 ms
According to the Round Robin algorithm, the arrival of processes is shown in the following Gantt chart.
P1
P2
P3
P1
P2
P3
P1
P2
P3
P1
0
2
4
6
8
10
12
14
15 16
18
From the Gantt chart, the waiting time and the turnaround time are calculated as:
Waiting time for P1 = 18 – 8 = 10 ms
Waiting time for P2 = 15 – 5 = 10 ms
Waiting time for P3 = 16 – 5 = 11 ms
Therefore, the average waiting time = (10+10+11)/3 = 10.33 ms
The average waiting time is 10.33 ms.
Turn around time for process P1 = 18 – 0 = 18 ms
Turn around time for process P2 = 15 – 0 = 15 ms
Turn around time for process P3 = 16 – 0 = 16 ms
Turnaround time= (18+15+16)/3 = 16.33 ms
The average turnaround time is 16.33 ms.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help