Nachos Introduction CS Operating System 2005
What is Nachos? Nachos Not Another Completely Heuristic Operating System Developed by Tom Anderson and his students at UC Berkley 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 The Nachos kernel runs inside a process The simulator runs alongside the kernel inside a process The user program runs inside the simulator Machine (hardware) OS kernel User programs Simulated Nachos hardware Nachos kernel Nachos user program System calls Nachos system call
How to install Nachos? Copy files to your home directory cp /tmp/nachos/nachos_4.0.tar.gz./ Extract files tar -zxvf nachos_4.0.tar.gz Change directory 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 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 ~/nachos- 4.0/code/userprog directory Nachos executes two programs: ~/nachos- 4.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 userprog/userkernel.cc void UserProgKernel::Run() In this project, you can only modify the following code segments (you may not need to modify all of them): 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 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 main.html main.html A quick introduction to C++ written by Tom Anderson mple/c++.ps mple/c++.ps