← Back to STL Containers
Question 500
Round-Robin Scheduler
Round-Robin Scheduler
Write a round-robin CPU scheduler. Input: the first line holds the time quantum Q (a positive integer); every following line holds a process name and its burst time, separated by a space, until the input ends. Queue the processes in the order they were read and start the clock at 0. Take the front process and run it formin(Q, remaining burst): add that amount to the clock and subtract it from the process's remaining burst. If its remaining burst is now 0, printNAME finished at time Ton its own line, where T is the current clock value; otherwise push it to the back of the queue. Repeat until the queue is empty. Example input: 3 A 6 B 2 The output for that input is shown in Expected Output.
Expected Output:
B finished at time 5 A finished at time 8 Q finished at time 3 P finished at time 7 R finished at time 8
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL ContainersQueues
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.