RR Scheduling With Priority
RR Scheduling With Priority
Task Description:
Modify the given Round Robin scheduling implementation to include a Priority Scheduling
feature. The updated program should execute processes in a priority-based manner if two
or more processes have the same burst time. If priorities are equal, the Round Robin
approach should handle the time-sharing.
Steps to Implement the Task:
1. Add a Priority Array:
- Introduce a new integer array `priority[]` that holds the priority values of each process.
Higher priority is represented by a lower value (e.g., 1 is higher than 2).
2. Modify the RR Algorithm:
- Before starting the Round Robin scheduling, sort the processes based on their priority.
- If two or more processes have the same priority, process them in the order they appear
in the array (Round Robin logic applies).
3. Update the Output:
- Display the priority of each process in the final table, alongside the Process ID, Burst
Time, Waiting Time, and Turnaround Time.
Previous task code implementation is Given below use this code and convert it
into Priority Round Robin
implementation of RR scheduling
#include <iostream>
using namespace std;
// Driver code
int main()
{
// process id's
int processes[] = {1, 2, 3};
int n = sizeof processes / sizeof processes[0];
// Time quantum
int quantum = 2;
findavgTime(processes, n, burst_time, quantum);
return 0;
}
Output:
PN BT Priority WT TAT
1 10 2 8 18
2 5 1 0 5
3 8 3 14 22