Project 0

Imagine that much of the threads directory hasn't been implemented yet. You have a bunch of headers (thread.h, synch.h, scheduler.h, and kernel.h), but a lot of it just isn't there. This sample project essentially asks you to write part of the threads directory. Of course, you don't have to do any of this, but, this design document hopefully serves its purpose as a guide to help you write another four design docs. Fortunately for me, writing a design doc for working code is a lot easier than writing a design document for non-existent code. By the way, reading through the solution might help you understand why the code you're given looks the way it is. Anyway, on to the sample project...

Tasks:

  1. (25%) Implement the core Scheduler methods (ReadyToRun, FindNextToRun, Run). Use a FIFO scheduling policy.

  2. (40%) You are given a skeleton for a Thread class. Implement Begin, Finish, Fork, Yield, and Sleep. Note that StackAllocate, which deals with machine-dependent thread initialization, is implemented for you. You can access the scheduler methods you implemented through the kernel's scheduler (kernel->scheduler).

    At this point you can run threads, using the ThreadedKernel class we provide. ThreadedKernel::Initialize instantiates a Statistics object, an Interrupt object, and a Scheduler, and a Thread to represent the main thread. You can test your implementation inside ThreadedKernel::SelfTest.

  3. (35%) The current scheduler can be made preemptive by causing the current thread to yield every once in a while. Create an Alarm class that uses the Timer device to yield the current thread at regular intervals.