Please read carefully. This is a hand simulation request only (NO CODE). Instruc
ID: 3859287 • Letter: P
Question
Please read carefully. This is a hand simulation request only (NO CODE).
Instructions: Perform a hand simulation (draw a pitcure) of the mfq simulation lab to ensure that you understand the algorithm. Your output should agree with the partial output provided in the lab document. This picture is really important for me to see
Here are materials on what to use for this lab below.
The input to this simulation will consist of job requests, each composed of three elements:
· Arrival time – Time job is initially submitted to the pattern
· Process identifier (pid) – Identifies each process as it travels through the system
· CPU time – CPU time required by the process to complete its job
The output, displayed in a tabular format, should include a table entry each time a job enters the system indicating the:
· Event
· System time
· Processor identifier (pid)
· CPU time needed
When a process a completes and leaves the system, an appropriate table entry should be output to the indicate:
· Event
· System time
· Process identifier (pid)
· Total time in the system
· Identify of the lowest- level queue in which the process resided
- Here is the data set, mfq,txt, which your program should run on:
Arrival Time, Process ID, CPU TIme
2 101 3
7 102 1
9 103 7
12 104 5
14 105 1
17 106 1
18 107 50
24 108 2
34 109 12
37 110 3
44 111 10
45 112 48
50 113 1
56 114 1
71 115 3
81 116 2
-Here are the first couple of lines of output and the last couple of lines of output that your program should generate. This is important as well to show that your output is displaying correctly.
Lab Notes 2 – Input Queue
Along with the four queues that you will be using for this lab, I would also recommend creating an input queue. Before the lab simulation begins, read each line of input from mfq.txt, insert data into a newly created Job object, and then insert the Job object at the front of the queue to determine whether or not it’s time for the Job object at the front of the input queue to determine whether or not it’s time for the Job object to enter the simulation, i.e., is the system time equal to the arrival time of the Job object at the front of the queue?
Here is simulation lab flowchart
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("==============================================="); } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.