


1) Completion Time: Time at which process completes its execution.
2) Turn Around Time: Time difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time.
3) Waiting Time(W.T.): Time difference between turn around time and the burst time. Waiting Time = Turn Around Time – Burst Time.
The first line of input contains an integer 'T' representing the number of test cases.
The first line of each test case contains a single integer, ‘N’, where ‘N’ represents the number of processes.
The next ‘N’ lines of each test case containing three space-separated integers, ‘processId’, ‘arrivalTime’ and ‘burstTime’, where ‘processId’, ‘arrivalTime’ and ‘burstTime’ represents the process id, arrival time, and burst time for the processes, respectively.
Note: It is guaranteed that each process has a unique process id.
For each test case, print ‘N’ lines, each having five space-separated integers, process id, arrival time, burst time, waiting time, and turnaround time.
Print the processes according to SJF scheduling. If multiple processes have the same execution time, schedule the process with a lower process id first.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 100
1 <= processId <= N
0 <= arrivalTime <= 10 ^ 7
1 <= burstTime <= 10 ^ 7
Where ‘T’ is the total number of test cases, ‘N’ denotes the number of processes, ‘processId’, ‘arrivalTime’, and ‘burstTime’ represents the process id, arrival time, and burst time of any process, respectively.
Time Limit: 1 sec
Approach: The idea here is to sort the given ‘N’ processes in increasing order of their arrival times. For the processes with the same arrival time, we will sort them in increasing order of burst time. We will iterate through all the processes from left to right, and for any process ‘i’, where ‘i’ is from 0 to ‘N’ - 1, we will find all the processes whose arrival time is less than or equal to the completion time of the i-th process. Among all those processes, we will take the process with minimum burst time, and we will swap it with the i-th process, as this process has a lower execution time than the i-th process. Simultaneously we will compute the completion time, waiting time, and turnaround time for each process.
Algorithm:
FCFS CPU Scheduling
FCFS CPU Scheduling
FCFS Scheduling Algorithm with Different Arrival Time
Priority CPU Scheduling : 2
Round Robin Scheduling with different arrival times
Page Faults