Assignment 2


Out: Wednesday, January 12

Due: Wednesday, January 19

Read the remainder of chapter 4.
Read chapter 6 (six) through the end of 6.6.
You may skip sections 6.2.1 and 6.2.2. (Note, we will read chapter 5 following chapter 6.)

Do problems 4.4, 4.5, 4.6, 4.7, 6.1, 6.6

Project Assignment 0

The point of this assignment is to make sure that you (1) familiarize yourself with Nachos, and (2), understand what happens during context switches. This project assignment should be done *individually* instead of with your group.

1. Download and install the Nachos distribution from the course web page. After saving the distribution file cse451-nachos.tar.gz, run "gunzip cse451-nachos.tar.gz", followed by "tar -xvf cse451-nachos.tar". This will create the "nachos-3.4" directory, which contains the source code and documentation for Nachos. The actual code you will be working with is in the "code" subdirectory. Compile the whole project by running "make" in the "code" directory.

2. For this assignment, you will be working in the "threads" directory. Edit threadtest.cc to run the code listed below. For each procedure call/return, give the name of the thread doing the call/return, the procedure name, and the values of any significant arguments. You only have to list calls and returns to routines defined in thread.cc, scheduler.cc, and switch.s, calls to Interrupt:SetLevel(), and calls to the functions defined below. In other words, you can ignore ASSERTs, DEBUG statements, calls to list routines, calls made internal to the interrupt simulation, and any trivial inline functions. You should also assume that timer interrupts are disabled, so there is no preemption. You should also assume that there are no threads on the ready list when SelfTest is called.

For example, you solution should begin:

                                readlist = NULL; running "main"
                                In "main" calling SelfTest
                                In "main" calling Thread::Thread("child 1")
                                In "main" returning from
				Thread::Thread("child 1")

You should generate your solution automatically by modifying the Nachos source files.

                void
                ChildFunction(int arg) {
                        currentThread->Yield();
                }

                void SelfTest() {
                        Thread *t1 = new Thread("child 1");
                        Thread *t2 = new Thread("child 2");
                        
                        t1->Fork(&ChildFunction, 1);
                        t2->Fork(&ChildFunction, 2);
                        currentThread->Yield();
                }