Lab 2: Scheduler

Handed out Monday April 26, 2021
Due Sunday May 9, 2021

Implement Priority Scheduling

In this part of the assignment, you will change the scheduler from a simple round-robin to a priority scheduler. Add a priority value to each process (lets say taking a range between 0 to 31). The range does not matter, it is just a proof of concept. When scheduling from the ready list you will always schedule the highest priority process (the one with the lowest value) first.

Add a system call to change the priority of a process. A process can change its priority at any time. If the priority becomes lower than any process on the ready list, you must switch to that process.

To avoid starvation, you need to implement aging of priority. If a process waits increase its priority (decrease its value). When it runs, decrease it (increase its value).

You also need to add fields to track the scheduling performance of each process. These values should allow you to compute the turnaround time and wait time for each process. Add a system call to extract these values or alternatively print them out when the process exits.

You need to develop a test program to illustrate prority scheduling.

Getting Started

To get started, look at the file proc.c.

What to submit

You need to submit a report that includes the folowing:
  • All code changes you made on xv6 source code
  • Detailed explanation about these changes
  • Screenshots about how you run the related program(s) and results