the Priority Scheduling โ€“ Non-Preemptive solution for the given data.

Given Process Table

(Assume: lower priority number = higher priority)

ProcessArrival TimeBurst TimePriority
P1053
P2235
P3321
P4132

Step-by-Step Scheduling (Non-Preemptive)

Time = 0

  • Available: P1
  • Execute P1 (only process available)

P1 runs from 0 โ†’ 5


Time = 5

Available processes:

  • P2 (priority 5)
  • P3 (priority 1)
  • P4 (priority 2)

👉 Highest priority = P3

P3 runs from 5 โ†’ 7


Time = 7

Remaining processes:

  • P2 (priority 5)
  • P4 (priority 2)

👉 Highest priority = P4

P4 runs from 7 โ†’ 10


Time = 10

Remaining process:

  • P2

P2 runs from 10 โ†’ 13


Gantt Chart

| P1 |  P3 |  P4 |  P2 |
0    5     7     10    13

Completion Time (CT)

ProcessCT
P15
P37
P410
P213

Turnaround Time (TAT = CT โˆ’ AT)

ProcessTAT
P15 โˆ’ 0 = 5
P37 โˆ’ 3 = 4
P410 โˆ’ 1 = 9
P213 โˆ’ 2 = 11

Waiting Time (WT = TAT โˆ’ BT)

ProcessWT
P15 โˆ’ 5 = 0
P34 โˆ’ 2 = 2
P49 โˆ’ 3 = 6
P211 โˆ’ 3 = 8

Average Times

  • Average Waiting Time (0+2+6+8)/4=4(0 + 2 + 6 + 8) / 4 = \mathbf{4}(0+2+6+8)/4=4
  • Average Turnaround Time (5+4+9+11)/4=7.25(5 + 4 + 9 + 11) / 4 = \mathbf{7.25}(5+4+9+11)/4=7.25

This is the complete solution using Priority Scheduling (Non-Preemptive method).
If you want, I can also solve the preemptive version or convert this into exam-ready steps.

PROCESS ID ARRIVAL TIME BURST TIME PRIORITY P1 0 5 3 P2 2 3 5 P3 3 2 1 P4 1 3 2 above algorithm solved non priority and 5 is a highest priority

Below is the Priority Scheduling โ€“ Non-Preemptive solution when priority number 5 is the HIGHEST priority.


Given Process Table

(Higher number = Higher priority)

ProcessArrival Time (AT)Burst Time (BT)Priority
P1053
P2235
P3321
P4132

Step-by-Step Scheduling (Non-Preemptive)

Time = 0

Available process:

  • P1

👉 Execute P1 (non-preemptive)

P1 runs from 0 โ†’ 5


Time = 5

Available processes:

  • P2 (priority 5) ⭐
  • P3 (priority 1)
  • P4 (priority 2)

👉 Highest priority = P2

P2 runs from 5 โ†’ 8


Time = 8

Remaining processes:

  • P3 (priority 1)
  • P4 (priority 2)

👉 Highest priority = P4

P4 runs from 8 โ†’ 11


Time = 11

Remaining process:

  • P3

P3 runs from 11 โ†’ 13


Gantt Chart

| P1 |  P2 |  P4 |  P3 |
0    5     8     11    13

Completion Time (CT)

ProcessCT
P15
P28
P411
P313

Turnaround Time (TAT = CT โˆ’ AT)

ProcessTAT
P15 โˆ’ 0 = 5
P28 โˆ’ 2 = 6
P411 โˆ’ 1 = 10
P313 โˆ’ 3 = 10

Waiting Time (WT = TAT โˆ’ BT)

ProcessWT
P15 โˆ’ 5 = 0
P26 โˆ’ 3 = 3
P410 โˆ’ 3 = 7
P310 โˆ’ 2 = 8

Average Times

  • Average Waiting Time (0+3+7+8)/4=4.5(0 + 3 + 7 + 8) / 4 = \mathbf{4.5}(0+3+7+8)/4=4.5
  • Average Turnaround Time (5+6+10+10)/4=7.75(5 + 6 + 10 + 10) / 4 = \mathbf{7.75}(5+6+10+10)/4=7.75

Solved using Priority Scheduling (Non-Preemptive) where 5 is the highest priority.

Below is the Priority Scheduling โ€“ Preemptive solution
👉 Higher number = higher priority (5 is highest)


Given Process Table

ProcessArrival Time (AT)Burst Time (BT)Priority
P1053
P2235
P3321
P4132

Step-by-Step Execution (Preemptive)

Time 0

  • Available: P1
  • Execute P1

P1 runs from 0 โ†’ 2 (remaining BT = 3)


Time 2

  • P2 arrives (priority 5 โ€“ highest)
    👉 Preempts P1

P2 runs from 2 โ†’ 5 (finishes)


Time 5

Available processes:

  • P1 (remaining BT = 3, priority 3)
  • P3 (BT = 2, priority 1)
  • P4 (BT = 3, priority 2)

👉 Highest priority = P1

P1 runs from 5 โ†’ 8 (finishes)


Time 8

Remaining processes:

  • P4 (priority 2)
  • P3 (priority 1)

👉 Highest priority = P4

P4 runs from 8 โ†’ 11 (finishes)


Time 11

Remaining:

  • P3

P3 runs from 11 โ†’ 13 (finishes)


Gantt Chart (Preemptive)

| P1 | P2 | P1 | P4 | P3 |
0    2    5    8    11   13

Completion Time (CT)

ProcessCT
P18
P25
P411
P313

Turnaround Time

TAT = CT โˆ’ AT

ProcessTAT
P18 โˆ’ 0 = 8
P25 โˆ’ 2 = 3
P411 โˆ’ 1 = 10
P313 โˆ’ 3 = 10

Waiting Time

WT = TAT โˆ’ BT

ProcessWT
P18 โˆ’ 5 = 3
P23 โˆ’ 3 = 0
P410 โˆ’ 3 = 7
P310 โˆ’ 2 = 8

Average Times

  • Average Waiting Time

(3+0+7+8)/4=4.5(3 + 0 + 7 + 8) / 4 = \mathbf{4.5}(3+0+7+8)/4=4.5

  • Average Turnaround Time

(8+3+10+10)/4=7.75(8 + 3 + 10 + 10) / 4 = \mathbf{7.75}(8+3+10+10)/4=7.75


This is the correct Priority-Based Preemptive Scheduling solution where 5 is the highest priority.

If you want, I can also:

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *