Project 2: Non-Preemptive Scheduling


Overview

Your main task for this project is to extend the sources we give you to support non-preemptively scheduled kernel threads and ``user'' processes, and mutual exclusion besides. You must also measure the cost of context switches between threads and processes. Students in previous semesters have found this project to be significantly harder than the previous one, so start early!

Yun Zhang will be the TA in charge of this project.

Important Dates

Precept 1: Oct 1, Wed, 20:30-21:30, COS 105.
Slides
Design Review 1: Oct 6, Mon, 19:00-21:00, FC 010, sign up here
Precept 2: Oct 8, Wed, 20:30-21:30, COS 105, Slides
Project Due: Oct 13, Mon, 23:59

Design Review

Design Review is graded as follows:
Data structures diagram
1 point. Draw the contents of the data structures for PCBs, locks, and any other structures you need.
Scheduling
1 point. Given that the threads below are listed in order, explain how the execution unfolds and why.
Kernel threads and scheduling design
1 point. Describe at a medium level how you will implement this part, with particular emphasis on how you are using your data structures.
Processes and system calls design
1 point. Similar to the above.
Mutual exclusion design
1 point. Similar to the above.

The threads:

Thread 1
lock_init(&lock);
lock_acquire(&lock);
do_yield();
lock_release(&lock);
do_exit();
Thread 2
while(TRUE) {
    do_yield();
}
Thread 3
do_yield();
lock_acquire(&lock);
lock_release(&lock);
do_exit();
Thread 4
lock_acquire(&lock);
lock_release(&lock);
do_exit();

Glossary

address line 20
When PCs boot up, addresses 0x100000 to 0x1fffff are aliases for 0x00000 to 0xfffff to accommodate badly written real mode programs. Programs that use more than one megabyte of memory must disable this behavior. See http://www.win.tue.nl/~aeb/linux/kbd/A20.html.
kernel mode
Synonym for protection ring 0.
process control block
The process control block (PCB) contains all of the state the kernel needs to keep track of a process or kernel thread.
protected mode
In (16-bit) real mode, an address ds:si refers to byte 16*ds + si. In 32-bit protected mode, the segment registers contain offsets into the global descriptor table, whose entries control the translation of memory accesses into physical addresses. The boot block provided to you sets up the global descriptor table and segment registers so that no translation is applied; you can ignore the segment registers for this project. See http://my.execpc.com/~geezer/os/pm.htm.
protection ring
Intel processors since the 286 have four privilege levels, ring 0 through ring 3. Ring 0 is the most privileged; ring 3 is the least. Typically the kernel runs in ring 0, and user processes run in ring 3. For this project, all processes run in ring 0.
system call
In modern operating systems, processes are enjoined from accessing memory that they do not own. System calls are how processes communicate with the kernel. Typically, the process writes the system call number and its arguments in its own memory, and then it transfers control to the kernel with a special kind of far call. The kernel then performs the desired action and returns control to the process.
task
Following Linux, we use ``task'' to mean process or kernel thread.

Extra Credit

For 1 point extra credit: using util.c:get_timer(), implement a scheduler that allocates CPU time fairly, together with some tests that prove to us that it's working. The grading criteria will be similar to that of the main assignment.

Hints

(borrowed from previous years. Hints will be updated as questions come out from office hours / design reviews)

Submission

Grading Criteria

Will be updated soon.