Please read carefully. This assignment has a lot information and i did the best
ID: 664964 • Letter: P
Question
Please read carefully. This assignment has a lot information and i did the best i could to cut it short. This subject is Data Structure. We are learning about intro to Queues. This is a two-part assignment.
1) 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
2) In this lab you will write a Java program that will simulate an operating system’s job scheduling policy to determine which process will be assigned the CPU when it becomes available. We will utilize a system of queues to simulate a sophisticated job scheduling mechanism, the multi-level feedback queue (MFQ)
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
- When the simulation is complete, you should also output the following:
· Total number of jobs
· Total time of all jobs in system – sum of the time each job is in the system
· Average response time – where response time is defines as the interval from the time a process enters the system to the time of first response, or the time it starts running
· Average turnaround time for the jobs – where turnaround time is defined as the interval from the time a process enters the system to the time of its completion
· Average waiting time – where waiting is the amount of time that a process is kept waiting in a queue
· Average throughout for the system as a whole – the number of jobs divided by the sum of total time of all jobs in the system
· Total CPU idle time – time the CPU has no jobs to run
- Be sure that your program sends all output to a file called csis.txt. This output file will be submitted along with our source code for the lab.
- Be sure all your data is properly labeled and all average values are displayed to two decimal places.
- Here is the data set, mfq,txt, which your program should run on:
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 1: Classes
Its important you should have 6 total classes for your lab:
Driver Job MFQ CPU ObjectQueue ObjectQueueInterface
The Job class include these class variables:
The CPU class include these class variables:
- Use this Driver class that is given
// Driver Class Java
Import java.io*;
public class Driver
{
publice static void(String [ ] args) throws IOException
{
PrintWriter pw = new PrintWriter(new FileWriter(“csis.txt”));
MFQ mfq = new MFQ(pw);
mfw.getJobs();
mfw.outputHeader();
mfw.runSimulation();
mfw.outStats();
pw.close();
}
}
- Use this ObjectQueue is given
//ObjectQueue.java
public class ObjectQueue {
private Object[] item;
private int front;
private int rear;
private int count;
public ObjectQueue() {
item = new Object[1];
front = 0;
rear = -1;
count = 0;
}
public boolean isEmpty() {
return count == 0;
}
public boolean isFull() {
return count == item.length;
}
public void clear() {
item = new Object[1];
front = 0;
rear = -1;
count = 0;
}
public void insert(Object o) {
if (isFull())
resize(2 * item.length);
rear = (rear+1) % item.length;
item[rear] = o;
++count;
}
public Object remove() {
if (isEmpty()) {
System.out.println("Queue Underflow");
System.exit(1);
}
Object temp = item[front];
item[front] = null;
front = (front+1) % item.length;
--count;
if (count == item.length/4 && item.length != 1)
resize(item.length/2);
return temp;
}
public Object query() {
if (isEmpty()) {
System.out.println("Queue Underflow");
System.exit(1);
}
return item[front];
}
private void resize(int size) {
Object[] temp = new Object[size];
for (int i = 0; i < count; ++i) {
temp[i] = item[front];
front = (front+1) % item.length;
}
front = 0;
rear = count-1;
item = temp;
}
}
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?
Lab Notes 3 - String Class Split Method to Parse Strings
- When reading in data from a file on a line-by-line basis, we often have the need to parse(i.e., divide up) the string to extract the individual pieces of information. The queue lab requires that you read the mfq.txt input file that contains three integers per line to grab each of the three integers on the line.
- We can use Scanner class to reach each line from the input file
- You could use then use the StringTokenizer class to parse each line read from the input file. However, the StringTokenizer class is losing favor to the split() method found in the String class.
Here is a diagram as well
Here is simulation lab flowchart
Explanation / Answer
ObjectQueue.java
IntQueue.java
Test.java
TestObject.java
VisualIntQueue.java
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.