


A time quantum is associated with the algorithm. Each process gets CPU for some units of time, which are decided by time quantum value, and then again enter the ready queue if they have burst time remaining.
Arrival Time - The time when the process enters the system and is ready for execution.
Burst Time - The total time taken by the process for execution.
Completion Time - The time when the process completes its execution and leaves the system.
If two processes are having the same arrival time, then a process with a lower ID will be executed first.
The first line contains an integer ‘T’ denoting the number of test cases. Then each test case follows.
The first input line of each test case contains two integers ‘N’ and ‘M’, denoting the number of processes and the quantum time, respectively.
Each of the next ‘N’ lines contains two space integers denoting the arrival time and burst time of the ith process.
For each test case, print a single line containing ‘N’ space-separated integers denoting the complete time of each process.
The output of each test case will be printed in a separate line.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 5
1 <= N <= 1000
1 <= M <= 1000
1 <= ARRIVALTIME[i], BURSTTIME[i] <= 1000
Where ‘N’ and ‘M’ denotes the number of processes and the quantum time, respectively.
Time limit: 1 sec
The basic idea of this approach is to use a queue to solve the problem. We’ll keep the process in the queue which needs to be executed. And when a process is executed for the time quantum time, then we’ll push it to the end of the queue.
Consider the following steps:
FCFS CPU Scheduling
FCFS CPU Scheduling
Shortest Job First(Non - preemptive)
FCFS Scheduling Algorithm with Different Arrival Time
Priority CPU Scheduling : 2
Page Faults