Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

  1. Check if new jobs need to be added to the priority queue.

  2. 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

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

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago