Lab 7: Scheduler

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. You will be writing a library in lab 7 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. Lab 7 will be on implementing a simulation of different scheduling algorithms of an operating system. We have implemented a priority queue data structure to keep track of the different jobs/processes in the simulation. We will use the priority queue data structure that is given to you for implementing different scheduling policies.

 

Lab Materials
  1. Slides
  2. Lab Files
  3. Example Simulations:
  4. Video Discussions:

    1. Part 1 (Introduction)



    2. Part 2 (libpriqueue)



    3. Part 3 (libscheduler)



    4. Part 4 (Simulation)



Assignment

For this lab, you need to complete the implementation of the libscheduler.c program. You will have to implement the following functions inside libscheduler.c:

You will find several files:

[Part 1]: Priority Queue (GIVEN)

A scheduler needs a fundamental data structure that is a priority queue. You will be using this a priority queue library in your scheduler.

libpriqueue API

Full function descriptions are provided for each function outlined in libpriqueue.c. 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 this lab.

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

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 lab, you should apply the following rules:

Compile and Run

To compile, 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.

 

Test
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
or
make test
All differences will be printed. Therefore, if no data is printed, your program has passed the test cases in the examples directory.

 

Grading, Submission, and Other Details
The grading will be broken down by the following percentages:

 

When you're finished

Once you have implemented all the functions, you can use the given examples.pl script to test with the given proc.csv files in the examples directory. You should check if your priority queue is giving the right output. You should replace the XXXXXXXs in the Makefile with your KUID. Then, use the "submit" target for preparing submission. Submissions will be through Canvas.

This lab is adopted from Dr. Caccamo's systems programming course at UIUC.

< Back to the Lab Home Page