CS444 Lab 3

Modifying the Xv6 Scheduler

While your operating system started out rather spartan, those days are over. It is time now to add some true functionality. Gone are the days of the text processing software your homework is idly sitting in using all your computer power - no! Finally, now, the kitten-picture browsing session can have the priority it deserves.

Front Matter

We made some changes to the scheduler recently which should improve Odin's performance when many people are trying their code in the QEMU VM; it allows the OS to intelligently detect when there's nothing to do, and idle to save processor cycles on our host :) . Because these changes are in the scheduler, you'll want to pull these changes before you start working.

Try the following code in your repository root: git pull upstream master This may ask you to make a merge commit, so don't be alarmed if a text editor pops up :)

If that doesn't work correctly, try this: git remote add upstream https://gitlab.cosi.clarkson.edu/cs444-sp17/xv6-cs444.git git pull upstream master ...if either of these complain about "please, commit or stash your changes", try running git stash before doing the pull, and git stash pop afterward; finally, if any of these complain about "merge conflicts", you're about to have fun; you might want to ask for some help :)

In any case, also feel free to contact me if you feel you need help (it's better than accidentally destroying your work)!

Material

For this lab, you should read (if you haven't already) chapter 5 of the XV6 book.

The current scheduler in is, as the book elucidates, a round robin scheduler with no other special properties. The scheduler you should implement will be a slight variation on their round-robin design, but with priorities, and the guarantee that a higher-priority runnable process should be selected before any runnable process of lower priority.

There are various ways of achieving this, and I encourage your creativity, but if you're lost, here's a naïve implementation in pseudocode: iterate over all priorities, from highest to lowest, and do the round-robin loop on each one; if a process was found to run, reset the priority to the highest value and continue, otherwise, proceed to the next lower priority. If you make it through this entire loop without finding a runnable process, halt (until the next interrupt).

The astute reader will note the previous example is O(PRIORITIES * NPROC), which is pretty bad; exercises on fixing this complexity are not necessary, but recommended for bonus credit :)

Assignment

Due by 5:00PM on Thursday, March 9, 2017

Implement the setpriority syscall and userspace program. Modify the scheduler to run the modified priority algorithm described in the slides.

You'll want to work in the following locations:

As before, submit your work to your xv6 GitLab repository to hand it in.