CSCI 402 - Operating Systems

NACHOS: The basis of class projects

The class assignments in this class will be written with the help of a hardware and operating simulator called NACHOS. You will be very familiar with it by the end of the semester.

To set it up, first download the Nachos source code.

Next, transfer the archive to one of the SCF machines (e.g., aludra) and extract the archive using the following procedure:

gtar xvzf nachos_su2008.tgz 

This creates a new directory in your account called nachos-csci402.

You must make sure you are using the 4.2.1 version of the g++ compiler. Nachos has been updated so that it can be compiled with the current default g++ compiler (as of late in 2004). You can check your compiler version as follows:

g++ --version

Note the 2 dashes in front of the word 'version'. If you see 4.2.1 in the message you are set. If you see an older version, then you need to make sure your .login file has the following line in it:

source /usr/usc/gnu/gcc/default/setup.csh

Note that this script will only work from the C-shell. If you use bash as your standard shell, make sure the source command is before you switch to bash.

You build Nachos this way:

cd nachos-csci402/code   //To change to the code directory within the Nachos directory structure
gmake    //To compile all of Nachos.

Be sure to use gnu make (gmake) to make the distribution, not regular 'make'.

One more thing you need to make sure of before you can run Nachos. There are two libraries that you will need. One is needed to run Nachos itself - libucb.so.1 - and the other is needed if you're going to run ddd - /usr/usc/gnu/gcc/2.95.2/lib.

Without access to the ucb library, you will see the following message when trying to run Nachos:

ld.so.1: nachos: fatal: libucb.so.1: open failed: No such file or directory

Without access to the old version of the gnu libraries, you will see the error below when trying to run ddd:

ld.so.1: /auto/usc/ddd/3.2.1/bin/ddd: fatal: libstdc++.so.2.10.0: open failed: No such file or directory

You need to modify the file '.cshrc' in your home directory for your account. You must add the following lines:

if ( ${?LD_LIBRARY_PATH} ) then
        setenv LD_LIBRARY_PATH /lib:/usr/lib:/usr/ucblib:/usr/usc/gnu/gcc/2.95.2/lib:$LD_LIBRARY_PATH
else
        setenv LD_LIBRARY_PATH /lib:/usr/lib:/usr/ucblib/:/usr/usc/gnu/gcc/2.95.2/lib
endif

What this says is that if the environment variable LD_LIBRARY_PATH exists, then execute the first setenv statement. This statement adds the directory /usr/ucblib to whatever LD_LIBRARY_PATH currently contains. If LD_LIBRARY_PATH does not exist, then execute the second setenv statement.

After making this change to the file, go back to the command line and type 'source .cshrc'. This will make that change take effect. After this, each time you log in, it will automatically be done for you.

To run Nachos, go to the 'threads' directory and type in 'nachos' you should see something like this:

*** thread 0 looped 0 times
*** thread 1 looped 0 times
*** thread 0 looped 1 times
*** thread 1 looped 1 times
*** thread 0 looped 2 times
*** thread 1 looped 2 times
*** thread 0 looped 3 times
*** thread 1 looped 3 times
*** thread 0 looped 4 times
*** thread 1 looped 4 times
No threads ready or runnable, and no pending interrupts.
Assuming the program completed.
Machine halting!

Ticks: total 130, idle 0, system 130, user 0
Disk I/O: reads 0, writes 0
Console I/O: reads 0, writes 0
Paging: faults 0
Network I/O: packets received 0, sent 0

Cleaning up...

If you see this, then you're ready to go. If you get a 'nachos not found', then do a 'gmake' from the threads directory and try again.

NACHOS Help and Documentation