Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write the code in java and use an input file. Do not use the code already posted for other questions because that code is

image text in transcribedimage text in transcribedimage text in transcribed

Please write the code in java and use an input file. Do not use the code already posted for other questions because that code is incorrect!

2. This problem is to simulate scheduling CPU jobs by using a priority queue to be built. Your program to be written for the simulation should run in a loop, each iteration of which corresponds to a time slice for the CPU. Each job is assigned a priority, which is an integer between -10 (highest priority) and +10 (lowest priority), inclusive. Each job is also assigned an arrival time - the time at which the job shows up at the CPU. From among all jobs waiting to be processed in a time slice, the CPU, the CPU must work on a job with highest priority. In this simulation, each job will come with arrival time, which is the time at which the job has arrived (integer0). Each job will also include a length value, which is an integer between 1 and 100, inclusive, indicating the number of time slices that are needed to process this job For simplicity, you may assume jobs cannot be interrupted - once it is scheduled on the CPU, a job runs for a number of time slices equal to its length (no preemption). Your simulator must output the name of the job running on the CPU in each time slice as shown below. Input File format: Each line in the input file contains the details one single job delimited by "space" Read the entire file first and then process the priority queue algorithm on all the jobs based on the arrival time. As some jobs will have a different arrival time, the priority queue will have to be re-done after every job is completed and new job arrivals need to be taken into consideration. The order of the jobs in the input file are random and not sorted in any way. JobName arrivalTime priority lengthOfJob Example input fil Job114 0 -9 25 Job345 0 2 66 Job234 10 -10 5 Job999 27 10 56 Output File format: Output on the command line should display the job arrivals on that time slice (if any) and job that is being executed for that timeslice along with the priority and the remaining time of that job. Time Slice #n -Job arrivals at this time slice (if any) Executing JobName priority remainingLengthOfJob Example output File: For the same input example file as above, the output should will be as follows: Time Slice #1 -Job 1 14 arrived Job345 arrived Executing Job114 -9 25 Time Slice #2 -Executing Job!14-9 24 Time Slice #3 -Executing Job!14-9 23 Time Slice #4 -Executing Job!14-9 22 Time Slice #5 -Executing Job!14-9 21 Time Slice #10 -Job234 arrived Executing Job114 -9 16 Time Slice #11 -Executing Job!14-9 15 Time Slice #12 -Executing Job!14-9 14 Time Slice #13 -Executing Job!14-9 13 Time Slice #14 -Executing Job!14-9 12 Time Slice #15 -Executing Job 1 1 4-9 11 Time Slice #16 -Executing Job!14-9 10 Time Slice #25 -Executing Job!14-9 1 Time Slice #26 -Executing Job234-10 5 Time Slice #27 -Job 999 arrived Executing Job234 -10 4 Time slice #28 -Executing Job234-10 3 Time Slice #29 -Executing Job2 34-10 2 Time slice #30 -Executing Job2 34-10 1 Time Slice #31 -Executing Job 345 2 66 Time Slice #32 -Executing Job 345 2 65 Time Slice #33 -Executing Job 34 5 2 64 Time Slice #34 -Executing Job 345 2 63 Time Slice #35 -Executing Job 345 2 62 Time Slice #96 -Executing Job345 2 1 Time Slice #97 -Executing Job999 10 56 Time Slice #98 -Executing Job999 10 55 Time Slice #99 -Executing Job 999 10 54 The output of all the time slices MUST be printed to the console. A command line user interface to read the input must be provided as follows: Enter your input file name: The program is to be submitted to the directory in "handin". Provide a README file with specific instructions for compilation and execution for the grader to follow, and any notes you want to add 2. This problem is to simulate scheduling CPU jobs by using a priority queue to be built. Your program to be written for the simulation should run in a loop, each iteration of which corresponds to a time slice for the CPU. Each job is assigned a priority, which is an integer between -10 (highest priority) and +10 (lowest priority), inclusive. Each job is also assigned an arrival time - the time at which the job shows up at the CPU. From among all jobs waiting to be processed in a time slice, the CPU, the CPU must work on a job with highest priority. In this simulation, each job will come with arrival time, which is the time at which the job has arrived (integer0). Each job will also include a length value, which is an integer between 1 and 100, inclusive, indicating the number of time slices that are needed to process this job For simplicity, you may assume jobs cannot be interrupted - once it is scheduled on the CPU, a job runs for a number of time slices equal to its length (no preemption). Your simulator must output the name of the job running on the CPU in each time slice as shown below. Input File format: Each line in the input file contains the details one single job delimited by "space" Read the entire file first and then process the priority queue algorithm on all the jobs based on the arrival time. As some jobs will have a different arrival time, the priority queue will have to be re-done after every job is completed and new job arrivals need to be taken into consideration. The order of the jobs in the input file are random and not sorted in any way. JobName arrivalTime priority lengthOfJob Example input fil Job114 0 -9 25 Job345 0 2 66 Job234 10 -10 5 Job999 27 10 56 Output File format: Output on the command line should display the job arrivals on that time slice (if any) and job that is being executed for that timeslice along with the priority and the remaining time of that job. Time Slice #n -Job arrivals at this time slice (if any) Executing JobName priority remainingLengthOfJob Example output File: For the same input example file as above, the output should will be as follows: Time Slice #1 -Job 1 14 arrived Job345 arrived Executing Job114 -9 25 Time Slice #2 -Executing Job!14-9 24 Time Slice #3 -Executing Job!14-9 23 Time Slice #4 -Executing Job!14-9 22 Time Slice #5 -Executing Job!14-9 21 Time Slice #10 -Job234 arrived Executing Job114 -9 16 Time Slice #11 -Executing Job!14-9 15 Time Slice #12 -Executing Job!14-9 14 Time Slice #13 -Executing Job!14-9 13 Time Slice #14 -Executing Job!14-9 12 Time Slice #15 -Executing Job 1 1 4-9 11 Time Slice #16 -Executing Job!14-9 10 Time Slice #25 -Executing Job!14-9 1 Time Slice #26 -Executing Job234-10 5 Time Slice #27 -Job 999 arrived Executing Job234 -10 4 Time slice #28 -Executing Job234-10 3 Time Slice #29 -Executing Job2 34-10 2 Time slice #30 -Executing Job2 34-10 1 Time Slice #31 -Executing Job 345 2 66 Time Slice #32 -Executing Job 345 2 65 Time Slice #33 -Executing Job 34 5 2 64 Time Slice #34 -Executing Job 345 2 63 Time Slice #35 -Executing Job 345 2 62 Time Slice #96 -Executing Job345 2 1 Time Slice #97 -Executing Job999 10 56 Time Slice #98 -Executing Job999 10 55 Time Slice #99 -Executing Job 999 10 54 The output of all the time slices MUST be printed to the console. A command line user interface to read the input must be provided as follows: Enter your input file name: The program is to be submitted to the directory in "handin". Provide a README file with specific instructions for compilation and execution for the grader to follow, and any notes you want to add

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago