MP4: Schedule Me!

CS 241


Introduction

One piece of software that every modern operating system must contain in a scheduler: without one, only one task could be run at a time. In this MP, you will be writing a library to perform basic scheduling of tasks. Rather than interacting directly with the operating system, we have provided for you a discrete event simulator: we will simulate time, jobs arriving, and jobs running. Your library will inform the scheduler which job should run next.

You will find several files:

[Part 1]: Priority Queue

To build a scheduler, a fundamental data structure is a priority queue. The first part of this MP requires you to complete libpriqueue, a priority queue library. You will be using this library in your scheduler.

libpriqueue API

To complete libpriqueue, you must implement the functions outlined in libpriqueue.c. These functions are self-descriptive, but a full function outline is provided for you below for each function. In every function, you may assume that all pointers given will be valid, non-NULL pointers.

[Part 2]: Scheduler

You will need to implement a multi-core scheduler in a simulated computer. You will be provided with a set of cores to schedule a set of tasks on, much like a real Linux scheduler.

You should use your priority queue you just built to help you complete this part of the MP.

To complete this MP, you must implement the eight functions defined in libscheduler/libscheduler.c. These functions are self-descriptive, but a full function outline is provided for you below for each function.

Additionally, we provide one function to help you with debugging:

Scheduler Details

The simulator will always follow a few, very specific rules. It's not important to understand the specifics of the simulator, but we provide these to help you with debugging:

There are a few specific cases where a scheduler needs to define behavior based on the scheduling policy provided. In this MP, you should apply the following rules:

Examples

Consider the following simple schedule:

job number arrival time running time priority
0 0 8 1
1 1 8 1
2 3 4 2

Using the schedule above, step-by-step examples are shown for three different possible running conditions:

Compile and Run

To compile this MP, run:
make clean
make
To run the helper tester program for part1, run:
./queuetest
To run the simulator, run:
./simulator -c <cores> -s <scheme> <input file>
For example:
./simulator -c 2 -s fcfs examples/proc1.csv
The acceptable values for scheme (outlined above) are: We provide three sample schedules: examples/proc1.csv, examples/proc2.csv and examples/proc3.csv. We also provide the expected output of those schedules in the examples directory. It's only important that lines starting with FINAL TIMING DIAGRAM match. We will not grade any output except the last few lines, as show_queue() is not required to be implemented in the same way as we did.

To test your program aganist all the test cases in an automated way, we provide a simple perl script. To run all 54 tests, simply run:
perl examples.pl
All differences will be printed. Therefore, if no data is printed, your program has passed the test cases in the examples directory.

Lab Report

In your lab report, please include answers to:

Grading, Submission, and Other Details

The grading will be broken down by the following percentages: Please fully read cs241.html for more details on grading, submission, and other topics that are shared between all MPs in CS 241.