Escovidal, Joseph Armand D. Preemptive SJF

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

ESCOVIDAL, JOSEPH ARMAND D.

PREEMPTIVE SJF
1.
Process Arrival Time Burst Time Completion Waiting Turnaround
P1 0 5 10 5 10
P2 1 2 3 0 2
P3 2 3 6 1 4

0 1 2 3 4 5 6 7 8 9 10
P1 P2 P3 P1
P1 P2 P3

Waiting Time:
P1 = 0 – 0 + 5 = 5
P2 = 1 – 1 = 0
P3 = 3 – 2 = 1

AverageWaitingTime = 5 + 0 + 1 = 6/3 = 2

Turnaround Time:
P1 = 10 – 0 = 10
P2 = 3 – 1 = 2
P3 = 6 – 2 = 4

AverageTurnaroundTime = 10 + 2 + 4 = 16/3 = 5.33

2.
Process Arrival Time Burst Time Completion Waiting Turnaround
P1 0 3 3 0 3
P2 3 4 8 1 5
P3 4 5 13 4 9
P4 5 1 6 0 1

0 1 2 3 4 5 6 7 8 9 10 11 12 13
P1 P2 P4 P2 P3
P1 P2 P3 P4

Waiting Time:
P1 = 0 – 0 = 0
P2 = 3 – 3 + 1 = 1
P3 = 8 – 4 = 4
P4 = 5 – 5 = 0

AverageWaitingTime = 0 + 1 + 4 + 0 = 5/4 = 1.25

Turaround Time:
P1 = 3 – 0 = 3
P2 = 8 – 3 = 5
P3 = 13 – 4 = 9
P4 = 6 – 5 = 1

AverageTurnaroundTime = 3 + 5 + 9 + 1 = 18/4 = 4.5


ESCOVIDAL, JOSEPH ARMAND D.
3.

Process Arrival Time Burst Time Completion Waiting Turnaround


P1 1 2 3 0 2
P2 4 5 11 2 7
P3 0 4 6 2 6
P4 3 6 17 8 14

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
P3 P1 P3 P2 P4
P3 P1 P4 P2

Waiting Time:
P1 = 1 – 1 = 0
P2 = 6 – 4 = 2
P3 = 0 – 0 + 2 = 2
P4 = 11 – 3 = 8

AverageWaitingTime = 0 + 2 + 2 + 8 = 12/4 = 3

Turnaround Time:
P1 = 3 – 1 = 2
P2 = 11 – 4 = 7
P3 = 6 – 0 = 6
P4 = 17 – 3 = 14

AverageTurnaroundTime = 2 + 7 + 6 + 14 = 29/4 = 7.25

NON-PREEMPTIVE SJF
1.
Process Arrival Time Burst Time Completion Waiting Turnaround
P1 0 2 3 1 3
P2 0 1 1 0 1
P3 0 3 6 3 6

0 1 2 3 4 5 6
P2 P1 P3
P1
P2
P3

Waiting Time:
P1 = 1 – 0 = 1
P2 = 0 – 0 = 0
P3 = 3 – 0 = 3

AvgWT = 1 + 0 + 3 = 4/3 = 1.33

Turnaround Time:
P1 = 3 – 0 = 3
P2 = 1 – 0 = 1
P3 = 6 – 0 = 6

AvgTaT = 6 + 1 + 3 = 10/3 = 3.33


ESCOVIDAL, JOSEPH ARMAND D.
2.
Process Arrival Time Burst Time Completion Waiting Turnaround
P1 3 3 9 3 6
P2 0 2 2 0 2
P3 2 4 6 0 4
P4 1 5 14 8 13

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
P2 P3 P1 P4
P2 P4 P3 P1

Waiting Time:
P1 = 6 – 3 = 3
P2 = 0 – 0 = 0
P3 = 2 – 2 = 0
P4 = 9 – 1 = 8

AvgWT = 3 + 0 + 0 + 8 = 11/4 = 2.75

Turnaround Time:
P1 = 9 – 3 = 6
P2 = 2 – 0 = 2
P3 = 6 – 2 = 4
P4 = 14 – 1 = 13

AvgTaT = 6 + 2 + 4 + 13 = 25/4 = 6.25

3.
Process Arrival Time Burst Time Completion Waiting Turnaround
P1 6 2 9 1 3
P2 2 3 5 0 3
P3 4 2 7 1 3
P4 1 4 13 12 12
P5 0 2 2 0 2

0 1 2 3 4 5 6 7 8 9 10 11 12 13
P5 P2 P3 P1 P4
P5 P4 P2 P3 P1

Waiting Time:
P1 = 7 – 6 = 1
P2 = 2 – 2 = 0
P3 = 5 – 4 = 1
P4 = 13 – 1 = 12
P5 = 0 – 0 = 0

AvgWT = 1 + 0 + 1 + 12 +0 = 14/5 = 2.8

Turnaround Time:
P1 = 9 – 6 = 3
P2 = 5 – 2 = 3
P3 = 7 – 4 = 3
P4 = 13 – 1 = 12
P5 = 2 – 0 = 2

AvgTaT = 3 + 3 + 3 + 12 + 2 = 23/5 = 4.6

You might also like