Given Process Table
(Assume: lower priority number = higher priority)
| Process | Arrival Time | Burst Time | Priority |
|---|---|---|---|
| P1 | 0 | 5 | 3 |
| P2 | 2 | 3 | 5 |
| P3 | 3 | 2 | 1 |
| P4 | 1 | 3 | 2 |
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)
| Process | CT |
|---|---|
| P1 | 5 |
| P3 | 7 |
| P4 | 10 |
| P2 | 13 |
Turnaround Time (TAT = CT โ AT)
| Process | TAT |
|---|---|
| P1 | 5 โ 0 = 5 |
| P3 | 7 โ 3 = 4 |
| P4 | 10 โ 1 = 9 |
| P2 | 13 โ 2 = 11 |
Waiting Time (WT = TAT โ BT)
| Process | WT |
|---|---|
| P1 | 5 โ 5 = 0 |
| P3 | 4 โ 2 = 2 |
| P4 | 9 โ 3 = 6 |
| P2 | 11 โ 3 = 8 |
Average Times
- Average Waiting Time (0+2+6+8)/4=4
- Average Turnaround Time (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)
| Process | Arrival Time (AT) | Burst Time (BT) | Priority |
|---|---|---|---|
| P1 | 0 | 5 | 3 |
| P2 | 2 | 3 | 5 |
| P3 | 3 | 2 | 1 |
| P4 | 1 | 3 | 2 |
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)
| Process | CT |
|---|---|
| P1 | 5 |
| P2 | 8 |
| P4 | 11 |
| P3 | 13 |
Turnaround Time (TAT = CT โ AT)
| Process | TAT |
|---|---|
| P1 | 5 โ 0 = 5 |
| P2 | 8 โ 2 = 6 |
| P4 | 11 โ 1 = 10 |
| P3 | 13 โ 3 = 10 |
Waiting Time (WT = TAT โ BT)
| Process | WT |
|---|---|
| P1 | 5 โ 5 = 0 |
| P2 | 6 โ 3 = 3 |
| P4 | 10 โ 3 = 7 |
| P3 | 10 โ 2 = 8 |
Average Times
- Average Waiting Time (0+3+7+8)/4=4.5
- Average Turnaround Time (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
| Process | Arrival Time (AT) | Burst Time (BT) | Priority |
|---|---|---|---|
| P1 | 0 | 5 | 3 |
| P2 | 2 | 3 | 5 |
| P3 | 3 | 2 | 1 |
| P4 | 1 | 3 | 2 |
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)
| Process | CT |
|---|---|
| P1 | 8 |
| P2 | 5 |
| P4 | 11 |
| P3 | 13 |
Turnaround Time
TAT = CT โ AT
| Process | TAT |
|---|---|
| P1 | 8 โ 0 = 8 |
| P2 | 5 โ 2 = 3 |
| P4 | 11 โ 1 = 10 |
| P3 | 13 โ 3 = 10 |
Waiting Time
WT = TAT โ BT
| Process | WT |
|---|---|
| P1 | 8 โ 5 = 3 |
| P2 | 3 โ 3 = 0 |
| P4 | 10 โ 3 = 7 |
| P3 | 10 โ 2 = 8 |
Average Times
- Average Waiting Time
(3+0+7+8)/4=4.5
- Average Turnaround Time
(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: