Homework 4
W4118 Fall 2009
UPDATED: 11/2/2009 at 8:00pm EST
DUE: Tuesday 11/10/2009 at 11:59pm EST

Individual non-programming problems are to be done individually. Group programming problems are to be done in your assigned programming groups. All homework submissions are to be made via Git using similar instructions as for previous homeworks but using the new repository for this homework. You will use an individual repository for submitting the individual non-programming problems, and a group repository for submitting the programming problems. Be aware that commits pushed after the deadline will not be considered. Refer to the homework policy section on the class web site for further details.

The Git repository you will use for the individual non-programming submission is

ssh+git://UNI@os1.cs.columbia.edu/git/UNI/hmwk4.written (Replace UNI with your own UNI)

The Git repository you will use for the group programming submission is

ssh+git://UNI@os1.cs.columbia.edu/git/TEAMID/hmwk4 (Replace TEAMID with your own TEAMID)

Individual Non-Programming Problems:

Exercise numbers refer to the course textbook, Operating System Concepts. Each problem is worth 3 points.

  1. Exercise 5.11

  2. Exercise 5.12

  3. Exercise 5.18

  4. Exercise 5.19

  5. Exercise 5.20

  6. Exercise 5.21

  7. Three tasks are inserted in the runqueue at the same time in the order T1, T2, and T3. If they are all run using SCHED_RR in Linux 2.6.27 at the lowest priority for SCHED_RR, draw the Gantt chart for these three tasks for ten scheduling decisions.

  8. Three tasks are inserted in the runqueue at the same time in the order T1, T2, and T3. If they are all run using SCHED_NORMAL in Linux 2.6.27 at the default priority for SCHED_NORMAL, draw the Gantt chart for these three tasks for ten scheduling decisions.

  9. Two tasks T1 and T2 are inserted in the runqueue at time 0 and both run using SCHED_NORMAL in Linux 2.6.27. T1 has the default nice value while T2 has a nice value of -10. How long will T2 run until T1 is allowed to run?

  10. Fair queuing is considered more fair than weighted round-robin scheduling. Give an example using Gantt charts that illustrates this.
Please complete and submit a private group programming assignment evaluation. For your convenience, the evaluation template to complete is already in your repository for your individual written assignment submission.

Group Programming Problems:

You will be using and modifying the Linux 2.6.27 kernel for this assignment. For all programming problems you will be required to submit source code, a README file documenting your files and code, and a test run of your programs. The README should explain any way in which your solution differs from what was assigned, and any assumptions you made. Refer to the homework submission page on the class web site for additional submission instructions.

Make at least ten commits with Git. The point is to make incremental changes and use an iterative development cycle. Follow the Linux kernel coding style.

CWRR Scheduling. You will create a new scheduling class in Linux and some test cases to demonstrate that the scheduler is working correctly. This problem is worth 70 points.

The Linux scheduler repeatedly switches between all the running tasks on the system, attempting to give a fair amount of CPU time to each task. Unfortunately, this means that multi-threaded applications will get more CPU time just because they contain more threads. Similarly, users who run more processes will also get more CPU time. An alternative is to introduce a notion called a container, which contains a group of processes. Fair-share scheduling with containers is a strategy that shares the CPU among sets of processes according to the container that is associated with those processes. For example, suppose Mary, Jane, and Sam are each assigned a separate container and using a machine that uses fair-share scheduling. Suppose Mary has one runnable process, Jane has three, and Sam has six. Fair-share scheduling views the ten runnable processes in three containers, and each container receives one-third of the CPU cycles to allocate to the processes that it owns. So Mary's single process would get about 33 percent of the available CPU cycles, each of Jane's three processes would get roughly 11 percent of the available CPU cycles, and each of Sam's six processes would get about 5.5 percent of the CPU cycles. Suppose Jane created two more processes. Jane would still in total get one-third of the CPU, so that each of her processes would now get about 6.7% of the CPU.

Add a new scheduling policy to support fair-share scheduling. Call this policy CWRR, for container weighted round-robin scheduling. CWRR should introduce a container abstraction and use fair-share scheduling based on each process's assigned container. At each invocation of the scheduler, we will use a hierachical scheme to choose which task to run: first, a container is chosen, then, a task within that container's set is chosen. If we allow each container's chosen task the same amount of time on the CPU, each container should be represented equally.

Since we are making two choices in each scheduling decision, we need two algorithms: one to choose the container, and one to choose one of that container's tasks. Let's start by assuming we will use a Round-Robin scheme to decide which container to choose. We keep a queue of containers, and whichever container was chosen last time we scheduled, we choose the next container in the queue for this schedule. We then choose a task within this container's set of tasks (more on this later), and let it run for a fixed amount of time (the time quantum). Now every container gets an equal amount of CPU time.

Now let's say that some containers are more equal than others. Imagine that we associate an integer, which we'll call a weight, with each container, and when a user is chosen, we let the container's chosen tasks run for W time quanta (instead of a single time quantum), where W is the container's weight. In this way we can specify that some containers get more CPU time than others, and also how much more. A container with a weight of 3 will get 50% more CPU time than a container with weight 2. This is called proportional sharing. More specifically, this implementation of proportional sharing is called Weighted Round-Robin.

We still haven't specified how a task is to be chosen once we choose a container. For simplicity, use a simple round-robin (RR) scheduling algorithm to do that. The intracontainer RR scheduler should use the default DEF_TIMESLICE value used in parts of the Linux scheduler. Otherwise, the RR scheduler should work the same as CWRR except that it schedules tasks, not containers, and there are no different task weights.

  1. Implement a new task scheduler, which we will call Container-based Weighted Round-Robin, or CWRR:

  2. To test your scheduler, you should generate a set of test cases to demonstrate that your CWRR scheduler behaves properly. In particular, each group is expected to program and submit at least one test function that is unique. We will make all the test cases available to all groups as they are submitted to help with testing your schedulers. If multiple groups submit the same test case, the group that submitted first will receive credit for it. Since each group's test case must be unique, it is advisable to submit your test case early.

    Specifically, each team should email the w4118 staff mailing list a test case. The email should contain an attachment named teamID.c containing the test. In teamID.c, there should be a function with the prototype int test_XXX(void), with XXX the test name (like in Homework 3). The Git repository for those tests will be updated daily:

    ssh+git://UNI@os1.cs.columbia.edu/git/hmwk4.userspace (Replace UNI with your own UNI)