Nachos Introduction

Download Report

Transcript Nachos Introduction

Nachos Introduction
CS342301
Operating System 2005
What is Nachos?

Nachos


Not Another Completely Heuristic Operating
System
Developed by Tom Anderson and his students at
UC Berkley


http://www.cs.washington.edu/homes/tom/nachos/
An educational system used to teach kernel
design and implementation
Why Nachos?

Real hardware is difficult to handle
Real kernel is too complicated to maintain

Nachos



Use a MIPS virtual machine
Provide some basic OS elements
Nachos structure

Nachos
program
User user
programs
Nachos system call
System calls
Nachos kernel

Simulated
Nachos
hardware

OS kernel
Machine (hardware)
The Nachos kernel
runs inside a process
The simulator runs
alongside the kernel
inside a process
The user program runs
inside the simulator
How to install Nachos?

Copy files to your home directory


Extract files


tar -zxvf nachos_4.0.tar.gz
Change directory


cp /tmp/nachos/nachos_4.0.tar.gz ./
cd nachos-4.0/code
Make files



make
You can ignore the warning messages
This step takes some time…please be patient
How to execute Nachos?

There are several different directories in
Nachos. You need to execute in different
directories for different homework


cd threads/
./nachos
cd userprog/
./nachos
How to write your program

Coding directly on the course machine

ssh 140.114.78.183




Free ssh tool on Windows: putty (or pputty)
Use vi to read and modify files
Use grep to search in files
Coding in Windows environment

Your familiar editors


AEdiX suite (free) / UltraEdit / VC++
Use ftp to download / upload files
How to debug your program

Use the debug options of Nachos



./nachos –d +
Print all debug messages
In case the output is too many to fit the
screen

./nachos -d + 2>&1 > FileName
How to recompile your program
completely

If you want to recompile the whole programs
completely

cd ~/nachos-4.0/code/
make clean
make
Project 1: Multiprogramming

Please execute the nachos under ~/nachos4.0/code/userprog directory




Nachos executes two programs: ~/nachos4.0/code/test/test1.c and test2.c
For some reasons, execute the two programs concurrently
will cause some errors
Please modify the kernel code such that Nachos can
execute the two programs concurrently
In this project, you don’t really need to make files under
code directory, make file in userprog directory is okay

cd ~/nachos-4.0/code/userprog
make
Project 1: Multiprogramming (cont’)

Please trace the following code to figure out how
Nachos decide which programs to execute


In this project, you can only modify the following
code segments (you may not need to modify all of
them):






userprog/userkernel.cc  void UserProgKernel::Run()
Constructor of AddrSpace in userprog/addrspace.*
Destructor of AddrSpace in userprog/addrspace.*
AddrSpace::Load(char*) in userprog/addrspace.*
Destructor of UserProgKernel in userprog/userkernel.*
UserProgKernel::Initialize() in userprog/userkernel.*
You may need to use “semaphore”, please refer:

thread/synch.*
How to submit your program




Please make a new directory “hw1” in your
home directory
Please copy your addrspace.*, userkernel.*
in this directory
TA will run “build.sh” to compile your program
You can copy build.sh from
/tmp/nachos/build.sh to test if your program
can compile and execute correctly
Some matters needing attention


The source code has been modified by TA. Please
don’t mix them with other versions
Mail the school IDs and names of your group
members (2~3 people) to TA



[email protected]
Please leave a copy of your codes in your own PC.
Course machine is for coding and testing only. We
do NOT guarantee the safety of your codes
TA will provide you something you should know, but
TA will NOT debug for you
Grading



Correctness: 70%
README file: 20%
Programming style: 10%
Reference links

Nachos official site


A road map through Nachos


http://www.cs.washington.edu/homes/tom/nachos/
http://www.cs.duke.edu/~narten/110/nachos/main/
main.html
A quick introduction to C++ written by Tom
Anderson

http://www.cs.washington.edu/homes/tom/c++exa
mple/c++.ps