Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You You must use this template package schedulingos; import java.util.Comparator; import java.util.PriorityQueue; public class FCFS{ static PriorityQueue processQueue = new PriorityQueue(10, new Comparator() { public

image text in transcribedimage text in transcribedYou You must use this template package schedulingos; import java.util.Comparator; import java.util.PriorityQueue;

public class FCFS{ static PriorityQueue processQueue = new PriorityQueue(10, new Comparator() { public int compare(Process process1, Process process2) { return (int)(process1.getArrivalTime()-process2.getArrivalTime()); } }); static PriorityQueue readyQueue = new PriorityQueue(10, new Comparator() {

public int compare(Process process1, Process process2) { return (int)(process1.getArrivalTime()-process2.getArrivalTime()); } }); static GlobalTimer globalTimer = new GlobalTimer(0);

public static void main(String[] args) { processQueue.add(new Process(1,3,2,globalTimer)); processQueue.add(new Process(2,6,3,globalTimer)); processQueue.add(new Process(3,1,4,globalTimer)); processQueue.add(new Process(4,4,5,globalTimer)); while(globalTimer.time

// TASK: Write your code here // Print performance statistics }

public static boolean checkIfNewProcessArrived(){ // TASK: Write your code here // return True/False by comparing the earliest arrival time from process queue with the global time } public static void runProcessInCpu(){ // TASK: Write your code here // Retrieve a process that is ready to run and run it

} }

package schedulingos; import java.util.Comparator; import java.util.PriorityQueue; public class FCFS{ static PriorityQueue(10, new Comparator() { public int compare(Process processi, Process process2) { return (int) (process1.getArrivalTime()-process2.getArrivalTime()); } }); static PriorityQueue readyQueue = new PriorityQueue(10, new Comparator() { public int compare (Process processi, Process process) { return (int) (process1.getArrivalTime()-process2.getArrivalTime()); } }); static GlobalTimer globalTimer = new GlobalTimer(); public static void main(String[] args) { processQueue.add(new Process(1,3,2, globalTimer)); processQueue.add(new Process (2,6,3, globalTimer)); processQueue.add(new Process(3,1,4,globalTimer)); processQueue.add(new Process(4,4,5,globalTimer)); while(globalTimer.time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

Students also viewed these Databases questions