Introduction to Building and Using Nachos
This document is intended as a short introduction to Nachos.
The commands the user would type are shown in bold face.
Any comments are shown in italics. Output from commands is
shown in normal type.
Nachos, SmartGDB, and the
support tools are installed only on the cse451 Linux box.
You MUST ssh (or rlogin or telnet) to this machine to use these tools
at the time of this writing.
DO NOT TRY TO USE THEM FROM ANY OTHER MACHINE.
I suggest using the command ssh cse451 to establish
a connection to the cse451 Linux computer. Before doing
this, create a file called .rhosts in your home directory with the
following two lines:
cse.unl.edu login-name
cse451.unl.edu login-name
where login-name is your own login name on cse
(and cse451). This file will let you establish rlogin or
secure shell rlogins. the command ssh cse451 will create a
secure rlogin session and redirect any X (graphic) output to your
terminal.
Downloading, Building, and Using Nachos
- Start by downloading a copy of Nachos.
- cse451 [101]> tar -xzf nachos.tar.gz
- Replace <Name of Nachos Archive> with the name
of the Nachos archive that you downloaded from the
assignment/project page. This extracts the archive in the
current directory. All of the archives create a directory
called "nachos" in the current directory. If you
already have an old version of nachos that you would like to
keep, you should move it out of the way (with mv
nachos nachos-old, for example) first.
- the command is tar -xzf
nachos.tar.gz
-
Remember, if you have an old
nachos directory, you should move it out of the way
first (mv nachos nachos-hw2, for example)
- cse451 [102]> cd nachos
- /users/rhill/nachos
- This is the top level directory of the Nachos source
code. You will always build the Nachos code from here.
- cse451 [103]> make
- This builds the Nachos code. The output from the
build is omitted due to its length.
- cse451 [104]> cd test
- /users/rhill/nachos/test
- This is the directory where the user programs are
located. Starting nachos from this directory will make it
easier to specify user programs to run. The Introduction to
Nachos describes the purpose of each
subdirectory in the Nachos source.
- cse451 [105]> ../userprog/nachos -x exit-prog
- This will run the Nachos simulator with the user
program "exit-prog" (located in the current
directory). The -x flag to nachos tells it what user
program to run when it starts. A description of the user
programs is available on the Nachos introduction
page.
- Exit Program
- Machine halting!
- Ticks: total 1511, idle 1169, system 310, user 32
- Context switches: 13
- Disk I/O: reads 0, writes 0
- Console I/O: reads 0, writes 13
- Paging: faults 6, pageins 8, pageouts 0
- Network I/O: packets received 0, sent 0
- Cleaning up...
- The exit-prog user program prints "Exit
Program" and then issues an Exit() system call. When
the system notices that there are no processes left to run,
it initiates a system shut down (printing "Machine
halting!"). During the shutdown, the statistics
collected while the simulator is running are printed.
- Ticks - the number of "simulated clock
cycles". This is broken down into idle ticks which
were unused processor time, system ticks which are clock
cycles spent in the kernel, and user ticks which are
clock cycles spent in user space.
- Context switches - the number of context switches
that occurred.
- Disk I/O - currently unused as the disk I/O
subsystem is merely a wrapper around the Unix
open/read/write/close system calls.
- Console I/O - the number of reads and writes to the
console (in terms of characters)
- Paging - the number of page faults, pages paged in
and pages paged out.
- Network I/O - currently unused as there is no
network subsystem.
- cse451 [106]> ../userprog/nachos -x shell
- nachos> matmult
- 7220 <---[1]
- Wait returned 1. Exit value = 7220
- The matmult user program performs a matrix
multiplication and prints the result as well as its process
ID ("7220" is the result and "1" is the
PID). The shell, after issuing a Fork() and Exec() waits
for the child process to finish using the Wait() system
call. When Wait() returns, it prints both the PID of the
child that exited and the value that it exited with (as
supplied to the Exit() system call).
- nachos> exit-prog
- Exit Program
- Wait returned 2. Exit value = 0
- nachos> exit
- "exit" is a command built in to the Nachos
shell. It causes the shell to exit. Since the Nachos shell
was the only process running, the machine then shuts down.
- Machine halting!
- Ticks: total 115151387, idle 114433081, system 74950, user 643356
- Context switches: 147
- Disk I/O: reads 0, writes 0
- Console I/O: reads 43, writes 193
- Paging: faults 99, pageins 105, pageouts 0
- Network I/O: packets received 0, sent 0
- Cleaning up...
- For more information on what the Nachos shell can do, see
the Nachos
introduction.
- cse451 [107]>
More Information on Nachos
We have created several documents to introduce you to the
Nachos system:
SmartGDB
At this point, you may want to look
into SmartGDB which is a breakpoint debugger that will help
you examine the Nachos code.
Notes on Modifying Nachos
Whenever you make modifications to the Nachos source code, you
must issue the make command from the top level directory
("nachos") to rebuild Nachos.
If you have any questions or comments, please send them to the
TA
(deng@cse.unl.edu).
Steve Goddard
Last modified: Fri Sep 18 11:30:00 CDT 1998