Edit your .cshrc file in your home directory and add following line at the end of your file
setenv PATH /auto/usc/ddd/3.2.1/bin:$PATH
Type
source .cshrc
The main thing you have to do is to follow the simple test case provided to you. It shows how the threads are executed without synchronization. After you are done with installing and compiling the nachos and ddd, the main thing you have to do is to follow the instructions for running the simple default test case provided to you.
Before going further let me explain a few things in general and for main.cc in particular.
Global Variables: All global kernel variables are to be defined in the threads directory files system.h and system.cc. All the predefined Nachos global kernel variables are defined here. Any new ones that you need for any of the projects are to also be defined here. Follow the pattern that already exists: In system.h, you have an extern statement, the actual declaration goes in system.cc. If you declar a pointer variable, you need a 'new' statement in the Initialize function in system.cc.
These are:
Thread *currentThread; // the thread we are running now Thread *threadToBeDestroyed; // the thread that just finished Scheduler *scheduler; // the ready list Interrupt *interrupt; // interrupt status Statistics *stats; // performance metrics Timer *timer; // the hardware timer device
The Initialize function:The Initialize function is also implemented in system.cc.
What it does is take the argument variables from the command prompt and invokes
particular functions and
initializes Nacos kernel variables. Take a look inside this function to see which variables are initialized. Notice that
it is all the global kernel variables which are defined as pointers.
Macro Guards: You will encounter various macro guards #ifdef --- #endif at various places in
Nachos. These are used for defining the particular functions and variables associated
with THREADS (project1) for threads, USER_PROGRAM (project2) for user programs, USE_TLB and USE_VM (project3) use of TLB for
virtual memory, NETWORK (project4) for Nachos networking, and others.
Extern functions and variables:C/C++, be default, only allows a variable to have scope in the file in which it is declared. Nachos has lots of files with course code and all the global kernel variables need to be available to every Nachos source code file. The way this is achieved is to use the extern statement. For example, the statement:
extern void threadtest();is implemented in threadtest.cc in threads directory, but it is called in main.cc.
-P -d a
From the separate small ddd menu , you can press "step" to go inside the threadtest function. Stepping through will take you to the each detail of the function being called during the program execution.
The "Next" command on that menu will only execute the next line but will not take you inside a called function. It will execute the entire function.
currentthread->Finish()is called. This method terminates threads when they have executed all their code.