Lab 2: Scheduler

Handed out Friday October 30, 2020

Due Friday Wednesday November 20, 2020

1. Getting Started

Download a new directory of starter code of XV6 for Lab2 from this link.

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

2. Assignment (95%)

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 thread/process first. All the processes should have a default initial priority of 10.

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.

Goals: Understand how the scheduler works. Understand how to implement a scheduling policy and characterize its impact on performance. Understand priority inversion and a possible solution for it.

3. Bonus Section (upto 10%)

Implement up to two of the next three items. Each is a 5% bonus. To get credit for a bonus part, you must also develop a user test that will illustrate it.

  • To avoid starvation, implement aging of priority. If a process waits increase its priority. When it runs, decrease it. (Possible Bonus 1)

  • Implement priority donation/priority inheritance. (Possible Bonus 2)

  • 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. (Possible Bonus 3)

4. Questions to Explore

  • Explain how the current scheduler works, including interaction with the timer.