![]() |
VOOZH | about |
Implementing priority CPU scheduling. In this problem, we are using Min Heap as the data structure for implementing priority scheduling.
In this problem smaller numbers denote higher priority.
The following functions are used in the given code below:
struct process {
processID,
burst time,
response time,
priority,
arrival time.
}
Implementation:
process id = 3 current time = 1 process id = 3 current time = 2 process id = 5 current time = 3 process id = 1 current time = 4 process id = 4 current time = 5 process id = 4 current time = 6 process id = 4 current time = 7 process id = 1 current time = 8 process id = 1 current time = 9 process id = 1 current time = 10 process id = 1 current time = 11 process id = 1 current time = 12 process id = 2 current time = 13 process id = 5 current time = 14 process id = 5 current time = 15 process id = 5 current time = 16 Average waiting time = 4.200000 Average response time =1.600000 Average turn around time = 7.400000
The output displays the order in which the processes are executed in the memory and also shows the average waiting time, average response time and average turn around time for each process.
If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.