Question: Write C++ program ---- description --- 1. Time. We consider time as a whole integer. You can view time like a clock ticking. Time starts

Write C++ program ---- description --- 1. Time. We consider time as a whole integer. You can view time like a clock ticking. Time starts from 1. That is, once simulate starts, the first time tick is 1. Then, at each tick, time increases by one. 2. Task. A task is represented by one interval [a,b] (start and end time) or multiple such intervals. This task wants to run during these intervals. We assume these intervals cannot be delayed. There are different kinds of tasks. I have provided a base class, ECSimTask, and one concrete task, ECSoftIntervalTask. Some more details. (a) Three states of tasks: (i) idle (not running, either because it doesnt want to run at this time or it is chosen by scheduler to run); (ii) running (scheduled by the scheduler), and (iii) finished (it will no longer run, either because its time has passed or it early terminated by some condition). (b) Task is preemptable. That is, a running task can be put to idle by scheduler. (c) A task would keep track of how long it has run (only count the actual running time, not including idling time). (d) A task also keeps track of waiting time. Waiting time is the number of ticks when the task is ready to run but has to wait since the scheduler chose another task to run. 3. Scheduler. A scheduler keeps track a list of active tasks and picks a task to run at each time tick. Exactly how it decides what task to choose is up to the specific scheduler, which implements different scheduling algorithm. (a) A simulator keeps track of time (which initially is zero and the first simulation time tick is 1). It also keeps track of which task (if any) is running at the current time. (b) Only a single task can be chosen to run at any time tick. That is, there is no parallelization in this system. (c) Scheduler accepts new requests by the function AddTask. We say a task arrives if the task is added to the scheduler. The order of making these AddTask function call is important because the scheduler often prefers the tasks arrived earlier. (d) The key interface function of scheduler is Simulate. This function takes a time duration (number of ticks to run) and will run the simulation up to this time duration (it can early terminate if there is nothing more to run; the return value is equal to the number of time ticks the simulator actually runs). (e) A concrete type of scheduler, ECSimFIFOTaskScheduler, is given. This scheduler is first-come-first-serve (or first-in-first-out, FIFO). The FIFO scheduler always prefers the tasks that arrive (requested) earliest. 1 1 What you need to do Read the starter files for the exact function signatures you should implement. 1. Read the provided starter code in ECSimTaask.h, ECSimTask.cpp, ECSimTaskScheduler.h, ECSimTaskScheduler.cpp and ECSimTaskTests.cpp. Dont change these starter files. In autograder, we will actually use the provided files, even if you submit your own versions for these programs. These starter code should work in the first test case. Understand how the starter code works. One main difference of this assignment is that you are given much more starter code than previous assignments. And your main task is adding more functionalities to an existing code base. This is usually the case when you start a new job in the industry, where it is rare you will start from scratch. 2. There is a class hierarchy. Make sure you use your new classes fit into the class hierarchy. 3. Implement several additional types of tasks in ECSimTasks2.h/cpp. (a) ECMultiIntervalsTask. This type of task consists multiple intervals. It has a method AddInterval(int a,int b) to add an interval [a,b] to it. Other than this, it behaves the same as the single (soft) interval. (b) ECHardIntervalTask. This is different from the given ECSoftIntervalTask in that it must start at the time it requested; otherwise, this task would finish. Once it starts on time, it behaves just like ECSoftIntervalTask, which can run intermittently (i.e., sometimes running and sometimes idling). (c) ECConsecutiveIntervalTask. This type of task must run in consecutive interval. That is, once interrupted, it finishes. (d) ECPeriodicTask. This type of task is recurring: it requests to run periodically of fixed length and then idle for fixed time, after a certain starting time. 4. Implement several additional types of schedulers in ECSimTaskScheduler2.h/cpp. These schedulers implement different algorithms about choosing what tasks to schedule. (a) In all the following scheduling algorithms, when there is a tie, prefer the request that comes in the first (i.e, FIFO). This has been implemented in the starter code. (b) ECSimLWTFTaskScheduler. Longest waiting time first: choose the task that has waited for the longest time. (c) ECSimPriorityScheduler. Schedule the task with highest priority (recall lower priority value has higher priority; this is consistent with Unix/Linux priority). (d) ECSimRoundRobinTaskScheduler. Schedule the task that has been scheduled the least number of times (count each time unit).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!