Question: Hello, Please explain this java code written for ''longest processing time scheduling in parallel machines'' step by step. I do not understand it so I

Hello, Please explain this java code written for ''longest processing time scheduling in parallel machines'' step by step. I do not understand it so I need help. Thank you.

public class LPT {

public static void main(String[] args) { int m = Integer.parseInt(args[0]); // number of machines

int n = StdIn.readInt(); Job[] jobs = new Job[n]; for (int i = 0; i < n; i++) { String name = StdIn.readString(); double time = StdIn.readDouble(); jobs[i] = new Job(name, time); }

// sort jobs in ascending order of processing time Arrays.sort(jobs);

// generate m empty processors and put on priority queue MinPQ pq = new MinPQ(m); for (int i = 0; i < m; i++) pq.insert(new Processor()); // assign each job (in decreasing order of time) to processor that is least busy for (int j = n-1; j >= 0; j--) { Processor min = pq.delMin(); min.add(jobs[j]); pq.insert(min); } // print out contents of each processor while (!pq.isEmpty()) StdOut.println(pq.delMin()); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!