Skip to main content
added 2356 characters in body
Source Link
JustinC
  • 19
  • 1
  • 5
All
1. ProcessesConsider Arrivalthe Timefollowing =0.
Iset finishedof thisprocesses, onwith mythe paper.length Areof theythe right?CPU burst and given in milliseconds:


Process    Time    Burst     Priority
p1
P1                0           4            3 
p2
P2                0           7            2
p3
P3                0           2            6
p4
P4                0           5            1
p5
P5                0           4            2


          WT                       BT 

Gannt|-Chart---------------------- |-------------------------|

AT FCFS                                                CT                 

|----------------------TAT-----------------------|


The p4processes are |assumed p5to have arrived |in p2the order P1, P2, P3, |P4, p1P5 all |p2at |time 0.

a.) Draw four Gantt chars that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, Non-preemptive Priority (a smaller priority number implies a higher priority), and RR (quantum=2).

b.) What is the turnaround time of each process for each of the scheduling algorithms in part a?

c.) What is the waiting time of each process for each of these scheduling algorithms?


Process    Time    Burst     Priority

P1                0           4            3

P2                0           7            2

P3                0           2            6

P4                0           5      9      1

P5  16    20  22        0           4            2



Complete Time = CT

Turn Around Time = TAT 

Burst Time = BT

Wait Time (= WT)

Average Wait Time = (0+5+9+16+20)/5AWT


WT = 50TAT /- 5BT

TAT = 10CT m- AT


Since they all arrived at time 0 but in order of P1, P2, P3, P4 P5.s We run at P1 first down to P5 in order on FCFS disregarding the Priority
I think I got a lot of wrong here since I was not paying attention. 
Gannt                                    CT-ChartAT      TAT-BT SJF
Process AT  Burst  Priority   CT     TAT        WT
|p1 p4  | p5  0 |   4         3      4       4         0
p2     | p10  |p2 | 7         2      11      11        4
p3      0    2 5      9  6      1613    20  2213        11 
Waitp4 Time (WT) = (0+5+9+16+20)/5 = 500 /   5 = 10 m.s      1      18      18        13
p5      0    4         2      22      22        18


Gannt-Chart - Non-preemptive PriorityFCFS

| p4p1  | p5p2   | p2p3    |   p4  | p1 p5 |p2 |
0     54     11 9     13   16   18 20     22
AverageNeeds Waita Timelot (of corrections below:
AWT) = (0+5+9+16+200+4+11+13+18)/5 = 5046 / 5 = 10 m9.s
2 ms

RoundTAT Robin= (Quantum=24+11+13+18+22)/5 = 68/5=13.6 ms

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|******************
0 
Gannt-SJF


1. 2Sort all 4the processes 6in increasing 8order according 10to 12burst 14time. 16

2. 18Then 19simply, 21apply 22FCFS.

P4There 5-2-2-1-1=0
p5is a tie between P1 and P5 because Burst is 4-2 so two Gannt-2=0Chart
p2
P1 7-2-2-2-1=0first


| p3  | p1 4-2-2=0  | p5   |   p4  |    p2 |
p30     2-2=0

Average Wait Time (AWT)  6      10       15     22
p4
AWT = 0+(10-2)+(18-120+2+6+10+15)/5 =14= 33/5 = 6.6 ms
p5
TAT = 2+(12-42+6+10+15+22)=10/5 =55/5= 11 ms

P5 first


| p3  | p5   | p1   |   p4  |    p2 =|
0 4+(14-    2      6)+(19-16)=15     10      15      22
p1
AWT = 6+(16-80+2+6+10+15)=14
p3/5 = 833/5 = 6.6 ms

AVTTAT = (14+10+15+14+82+6+10+15+22)/5=5 9= m.s55/5 = 11 ms

*****************
 
Alternate orGannt-Chart possible- GannNon-Chartpreemptive forPriority

1. FCFSSort andall Prioritythe Non-Preemptiveprocesses withoutin Pickingincreasing BTorder first.according to priority

Gannt-Chart2. -Then simply, apply FCFS.


There is a tie between p2 and p5 because priority is 2.

p2 first

| p4  | p2    | p5    |   p1  |p2|    p3    |
0     5     12  12    16       20  22
Average Wait Time (   22

AWT) = (0+5+12+16+20)/5 = 5310.6 ms

TAT =(5+12+16+20+22) /5 = 75/5 =15 ms


p5 first

| p4  | p5   | p2   |   p1  |    p3    |
0     5      9     16      20         22

AWT = (0+5+9+16+20)/5 = 10.6 mms

TAT = (5+9+16+20+22)/5 = 14.s4 ms

*************************
Gannt-Chart -Round PriorityRobin Non-Preemptive(Quantum=2)
|

|p1 p4 |p2 ||p3 p2 |p4 |p5  ||p1 p5 |p2  |p4  |p5  |P2  |p4 | p1  |p2p2 |         
0    2 5  4    6   8   10    12   14   16   18   20  22
Average Wait21 Time ( 22

AWT) = (0+5+12+16+208+15+4+16+14)/5 = 5311.4 ms

TAT = (12+22+6+21+18)/5= 79 / 54 = 1015.68 m.sms


All Processes Arrival Time =0.
I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Average Wait Time (AWT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s


Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

Average Wait Time (AWT)
p4 = 0+(10-2)+(18-12) =14
p5 = 2+(12-4)=10
p2 = 4+(14-6)+(19-16)=15
p1 = 6+(16-8)=14
p3 = 8

AVT = (14+10+15+14+8)/5= 9 m.s


 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s



1. Consider the following set of processes, with the length of the CPU burst and given in milliseconds:


Process    Time    Burst     Priority

P1                0           4            3 

P2                0           7            2

P3                0           2            6

P4                0           5            1

P5                0           4            2


          WT                       BT 

|----------------------- |-------------------------|

AT                                                 CT                 

|----------------------TAT-----------------------|


The processes are assumed to have arrived in the order P1, P2, P3, P4, P5 all at time 0.

a.) Draw four Gantt chars that illustrate the execution of these processes using the following scheduling algorithms: FCFS, SJF, Non-preemptive Priority (a smaller priority number implies a higher priority), and RR (quantum=2).

b.) What is the turnaround time of each process for each of the scheduling algorithms in part a?

c.) What is the waiting time of each process for each of these scheduling algorithms?


Process    Time    Burst     Priority

P1                0           4            3

P2                0           7            2

P3                0           2            6

P4                0           5            1

P5                0           4            2



Complete Time = CT

Turn Around Time = TAT 

Burst Time = BT

Wait Time = WT

Average Wait Time = AWT


WT = TAT - BT

TAT = CT - AT


Since they all arrived at time 0 but in order of P1, P2, P3, P4 P5. We run at P1 first down to P5 in order on FCFS disregarding the Priority
I think I got a lot of wrong here since I was not paying attention. 
                                    CT-AT      TAT-BT 
Process AT  Burst  Priority   CT     TAT        WT
p1      0    4         3      4       4         0
p2      0    7         2      11      11        4
p3      0    2         6      13      13        11 
p4      0    5         1      18      18        13
p5      0    4         2      22      22        18


Gannt-Chart - FCFS

| p1  | p2   | p3    |   p4  |  p5  |
0     4     11      13      18      22
Needs a lot of corrections below:
AWT = (0+4+11+13+18)/5 = 46 / 5 = 9.2 ms

TAT = (4+11+13+18+22)/5 = 68/5=13.6 ms

******************

Gannt-SJF


1. Sort all the processes in increasing order according to burst time. 

2. Then simply, apply FCFS.

There is a tie between P1 and P5 because Burst is 4 so two Gannt-Chart

P1 first


| p3  | p1   | p5   |   p4  |    p2 |
0     2     6      10       15     22

AWT = (0+2+6+10+15)/5 = 33/5 = 6.6 ms

TAT = (2+6+10+15+22)/5 =55/5= 11 ms

P5 first


| p3  | p5   | p1   |   p4  |    p2 |
0     2      6     10      15      22

AWT = (0+2+6+10+15)/5 = 33/5 = 6.6 ms

TAT = (2+6+10+15+22)/5 = 55/5 = 11 ms

*****************

Gannt-Chart - Non-preemptive Priority

1. Sort all the processes in increasing order according to priority

2. Then simply, apply FCFS.


There is a tie between p2 and p5 because priority is 2.

p2 first

| p4  | p2   | p5    |   p1  |    p3    |
0     5     12      16       20        22

AWT = (0+5+12+16+20)/5 = 10.6 ms

TAT =(5+12+16+20+22) /5 = 75/5 =15 ms


p5 first

| p4  | p5   | p2   |   p1  |    p3    |
0     5      9     16      20         22

AWT = (0+5+9+16+20)/5 = 10 ms

TAT = (5+9+16+20+22)/5 = 14.4 ms

*************************
Gannt-Chart Round Robin (Quantum=2)


|p1  |p2 |p3  |p4 |p5  |p1  |p2  |p4  |p5  |P2  |p4 |   p2 |         
0    2   4    6   8   10    12   14   16   18   20   21   22

AWT = (8+15+4+16+14)/5 = 11.4 ms

TAT = (12+22+6+21+18)/5= 79 / 4 = 15.8 ms


added 32 characters in body
Source Link
JustinC
  • 19
  • 1
  • 5
All Processes Arrival Time =0.
I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Average Wait Time (AWT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s


Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

Average Wait Time (AWT)
p4 = 0+(10-2)+(18-12) =14
p5 = 2+(12-4)=10
p2 = 4+(14-6)+(19-16)=15
p1 = 6+(16-8)=14
p3 = 8

AVT = (14+10+15+14+8)/5= 9 m.s


 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Average Wait Time (AWT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s


Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

Average Wait Time (AWT)
p4 = 0+(10-2)+(18-12) =14
p5 = 2+(12-4)=10
p2 = 4+(14-6)+(19-16)=15
p1 = 6+(16-8)=14
p3 = 8

AVT = (14+10+15+14+8)/5= 9 m.s


 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


All Processes Arrival Time =0.
I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Average Wait Time (AWT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s


Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

Average Wait Time (AWT)
p4 = 0+(10-2)+(18-12) =14
p5 = 2+(12-4)=10
p2 = 4+(14-6)+(19-16)=15
p1 = 6+(16-8)=14
p3 = 8

AVT = (14+10+15+14+8)/5= 9 m.s


 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


added 278 characters in body
Source Link
JustinC
  • 19
  • 1
  • 5
I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s
 

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Average Wait Time (AWT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s


Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

Average Wait Time (AWT)
p4 = 0+(10-2)+(18-12) =14
p5 = 2+(12-4)=10
p2 = 4+(14-6)+(19-16)=15
p1 = 6+(16-8)=14
p3 = 8

AVT = (14+10+15+14+8)/5= 9 m.s


 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
 
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
 
Average Wait Time (WTAWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
 
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
 
Average Wait Time (WTAWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s
 

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
 
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
 
Wait Time (WT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
 
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
 
Wait Time (WT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


I finished this on my paper. Are they right?

Process  Burst  Priority
p1       4      3
p2       7      2
p3       2      6
p4       5      1
p5       4      2   

Gannt-Chart - FCFS

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22

Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - SJF

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Wait Time (WT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s

Gannt-Chart - Non-preemptive Priority

| p4  | p5   | p2     | p1  |p2 |
0     5      9        16    20  22
Average Wait Time (AWT) = (0+5+9+16+20)/5 = 50 / 5 = 10 m.s


Round Robin (Quantum=2)

|p4|p5|p2|p1|p3|p4|p5|p2|p1|P4|p2|p2|
0  2  4  6  8  10 12 14 16 18 19 21 22

P4 5-2-2-1-1=0
p5 4-2-2=0
p2 7-2-2-2-1=0
p1 4-2-2=0
p3 2-2=0

Average Wait Time (AWT)
p4 = 0+(10-2)+(18-12) =14
p5 = 2+(12-4)=10
p2 = 4+(14-6)+(19-16)=15
p1 = 6+(16-8)=14
p3 = 8

AVT = (14+10+15+14+8)/5= 9 m.s


 
Alternate or possible Gann-Chart for FCFS and Priority Non-Preemptive without Picking BT first. 

Gannt-Chart - FCFS
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Gannt-Chart - Priority Non-Preemptive
| p4  | p2    | p5  | p1  |p2 |
0     5       12    16    20  22
Average Wait Time (AWT) = (0+5+12+16+20)/5 = 53 / 5 = 10.6 m.s


Source Link
JustinC
  • 19
  • 1
  • 5
Loading