Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Okay i\'m in struggle with this lab In java, the input simulation will consist o

ID: 664876 • Letter: O

Question

Okay i'm in struggle with this lab

In java, the input simulation will consist of job requests, each composed of three elements: arival time, process identifier(pid), & CPU time. The output displayed in a tabular format, should include a table entry each time a job enters the system indicating the: event, system time, pid, cpu time needed. After the process is complete and leaves the system, an appropriate table entry should be output to indicate the: event, system time, pid, total time in the system, & identify of the lowest-level queue in which the process resided.

The classes we are using are Driver, Job, MFQ, CPU, ObjectQueue. The variables we can use for Job class are pid (identifies each process as it travels through the system), arrivalTime (time job entered the system), cpuTimeRequired (total CPU time needed by job when job enters the system), cpuTimeRemaining (time remaining for completion of job), & currentQueue (location of the current queue of the job. As for the variables apply to the CPU class are job (hold current Job on the CPU), cpuQuantumClock (keeps track of the quanta remaining for current job on CPU), & busyFlag (determines whether or not there is a job on the CPU).

Note: Please comment on code, not all but the important ones to understand. ObjectQueue interface class is not neccary.

ObjectQueue given

Data must be labled and all average values are displayed to two decimal places. Present a visual display of the simulation. After the simulation is complete, the output should display like this for example

Driver Class is given

This is what the class diagram would look like

Explanation / Answer

import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Queue; /* implement this class for all three strategies */ public abstract class AllocationStrategy { protected List Jobs; protected ArrayList Queue; public AllocationStrategy(List jobs) { super(); Jobs = jobs; } public abstract void run(); // update current job by 1 tick // check if the job queue might need to be changed. // check for jobs to add to the queue } FirstComeFirstServed.java import java.util.ArrayList; import java.util.List; public class FirstComeFirstServed extends AllocationStrategy { int temp; int proceessArrivalTime; int waitingTime; double avgWaitingTime; double avgTurnAroundTime; public FirstComeFirstServed(List jobs) { super(jobs); } @Override public void run() { } public void run(List jobList) { int count = 0; System.out.println("============================================ "); System.out.println("Process ID | Turnaround time | Waiting time "); System.out.println("============================================ "); for(Job job:jobList){ if(count==0){ job.processArrivalTime = job.getArrivalTime(); job.ProcessCompletionTime = job.getArrivalTime()+job.getCpuTime(); }else{ job.processArrivalTime = temp-job.getArrivalTime(); job.ProcessCompletionTime = temp+job.getCpuTime(); } temp = job.ProcessCompletionTime; job.turnAroundTime = temp-job.getArrivalTime(); job.waitingTime = job.turnAroundTime-job.getCpuTime(); count++; avgWaitingTime = avgWaitingTime+job.waitingTime; avgTurnAroundTime = avgTurnAroundTime+job.turnAroundTime; System.out.println(" "+job.getProcessId()+" | "+" "+job.turnAroundTime+" | "+" "+job.waitingTime+" "); System.out.println("----------------------------------------"); } System.out.println("==============================================="); System.out.println("Avg waiting time:"+avgWaitingTime/jobList.size()); System.out.println("==============================================="); System.out.println("Avg turn around time:"+avgTurnAroundTime/jobList.size()); System.out.println("==============================================="); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote