Question
THIS IS A LAB TO BE CODED IN JAVA THIS SHOULD NOT BE CODED IN PYTHON2 PLEASE USE NETBEANS Overview: In this lab, you will
THIS IS A LAB TO BE CODED IN JAVA
THIS SHOULD NOT BE CODED IN PYTHON2
PLEASE USE NETBEANS
Overview:
In this lab, you will write a program called JobScheduler; it should take a single input file as a command-line argument. Each line in the input file has the following format:
e.g. a file might contain:
1 3 10 100
5 2 20 50
8 4 5 100
(all values will be positive integers)
These jobs might represent computer programs (or threads) that need to be run by the operating system.
Your task is to write a job scheduler that decides, for each second, what job should be run. The job that is available that has the highest priority value should be scheduled for the next second (ties can be broken arbitrarily). The central data structure to use a priority queue. You should implement your own priority queue, rather than rely on a built-in data structure.
Notes:
The list of jobs will first need to be sorted by arrival time.
The simulation begins at time 0 and runs until all jobs are finished.
At the beginning of each second:
-
Check if new jobs need to be added to the priority queue.
-
If the queue is non-empty, get the top priority job and run it for 1 second. If it finishes remove it, otherwise put it back in the queue.
Output:
Your program should print out which job is running each second. You should also compute the waiting time and total execution time for each job. The waiting time is the time the job actually starts versus when it was first available. The total execution time is the number of seconds that it takes to finish the job once it begins (this will be greater than or equal to its duration). Some points will be awarded for nicely-formatted output.
Example: suppose a job arrives at time 10s with duration 10s, starts at time 15s and finishes at time 30s. Then the waiting time is 5s, and the execution time is 15s.
Your program should run from the command line:
java -jar JobScheduler.jar input.txt
Please code this in Java.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started