this progrm still not easy for me can u help Introduction: This project utilizes
ID: 3620210 • Letter: T
Question
this progrm still not easy for me can u helpIntroduction:
This project utilizes linked lists and queues.
Overview:
A scheduler selects from a set of waiting tasks according to its algorithm. In this project you will
implement three different scheduling algorithms.
Description:
Write a command-line program (no GUI) that performs the following algorithms on a set of tasks:
Algorithms
1. FIFO - tasks are executed to completion in the order they are added.
2. Shortest - the shortest task is executed to completion, then the next shortest task, etc.
3. Round Robin - each task is executed for one unit of time in a rotation.
Tasks should be objects. A task is created with a duration that determines how long it should
execute. Tasks also have names and know how long they have executed.
Each scheduler should be an object derived from an abstract scheduler class. A scheduler will
accept and run a list of tasks. Running a task simply adds to the amount of time
the task has been executing. New tasks cannot be added once a scheduler begins running the tasks.
A separate class called "TestScheduler" should be created. It should be able to read in the
name and duration of each task from a file called "tasks.txt". It should create an object for
each scheduler, and an object for each task, and run the set of tasks with each scheduler.
You should write your own generic linked list class and generic queue class (your queue should
utilize your linked list). You can refer to the linked list code in the textbook, but should
avoid copying it directly.
Output:
Output must include:
1. The task names and durations
2. The length of execution each time a task is run
3. The ending of a task
Here is an example for the "Shortest" algorithm:
Job A is 5 units
Job B is 3 units
Job C is 1 unit
Job C ran 1 units
Job C is done
Job B ran 3 units
Job B is done
Job A ran 5 units
Job A is done
Here is an example for the "Round Robin" algorithm:
Job A is 5 units
Job B is 3 units
Job A ran 1 units
Job B ran 1 units
Job A ran 1 units
Job B ran 1 units
Job A ran 1 units
Job B ran 1 units
Job B is done
Job A ran 1 units
Job A ran 1 units
Job A is done
Explanation / Answer
Dear.. // java code for FIFO algorithm: public final class TestScheduler { RingList list = new RingList(); public TestScheduler ( ) // Constructor { } public int size() // actual size { return list.size(); } public boolean contains( Object o ) { RingElement rh = list.getHead(); RingElement re = rh; while (re != null) { if (re.getObject().equals( o )) return true; re = re.getNext(); if (re == rh) re = null; } return false; } public void clear() { list.removeAllElements(); } public boolean remove( Object o ) { RingElement rh = list.getHead(); RingElement re = rh; while (re != null) { if (re.getObject().equals( o )) { list.remove( re ); return true; } re = re.getNext(); if (re == rh) re = null; } return false; } public void put( Object o ) // Add a object to the queue. { list.insert( new RingElement( o ), list.HEAD ); } public Object get( ) // Removes the oldest object from the queue { RingElement re = list.getTail(); list.remove( re ); return re.getObject(); } public Object peek( ) { return list.getTail().getObject(); } protected void finalize() throws Throwable { list.removeAllElements(); list = null; super.finalize(); } } ______________________________________________________________________ public class RoundRobin { private int len; private StubData[] sd; private double[] load; private Set previousSet = null; private static final double MIN_THRESHOLD_RESET = 100.0; public RoundRobin() { len = 0; } public RoundRobin(Set c) { reset(c); } private void reset(Set stubs) { previousSet = stubs; len = stubs.size(); sd = new StubData[len]; load = new double[len]; Iterator it = stubs.iterator(); for (int i = 0; i 0) { for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.