CS 162 Nachos Tutorial and Source Code
Total Page:16
File Type:pdf, Size:1020Kb
!∀# ! " # $ % & ' ' " ( )$ " # $ % * " ( $ # $ # $ " " " ! % % ,2 " ,2 !33'1 % % +, " . /0 ' ,2 % !-& % " . /0 1 % ) % # $ # 4-$ " # & ! " 4- 55 ) && $ " 4- 6 % 7 " , & & ' & !/4-0 " , & " ) ) ' 4- 8 ' " , & ( ( )$ " ! 9) " ;4- ::55/ &0 " 9 ) 4- ) " 9# '-4 % / 0 2 ' ; % / 0 " < - % )/2 *0 " =4-&>( % / ) -0 % ' '6 ' % /2 0 &' ) % /2 0 4- % -/2 ?0 9 " # ' , " , @ - 6 '',2 ' ' " 2 " A ) / !0 , B " , " C ) " C ) ' - " -E' ) - - " ) ) % , /0 % ! ) 1 ,2 % , /0 % ) 6& % , /0 " )' ) % , )D)/0 ' " - - ' / 0 " ' & " - " (- % /0) ' & -GFF ) / 1 0 % )/0) & / F ) 0 " % )>/0- ) % &/0 % /0 ) % &/0 % (/0 " - 6 7 " 2 - ! (>- " 4- " > ) " % >7) 8 4- 55' % 9/0 &/ 60 7 % 9/0) & " )D) % ( /0 % '& )& - % < 2 * " & ' ) % . && & % -- ) H- ) C " & C " ( ) " " % @/0@ )' B C / & 0 % /0 / &0 " C % /0 / 0 % '='='9 )'3 % /0A - - " ;-C " ; 2 - C & 9 " &4- = " 8- =&/0') " & C ' )/0 " ;1 " I &8 1 " > = = & " ! " 3 " " C @ # $%& $ % C' % && ! $ ! % " > 8 " # C $ " # $ - ( $ " ,2 " 3 6J2 K " " 2 6 " < - " 2 6, " 1 " 2 ?6 +, " . ) " 2 *6 ) > & ;1H;& " /) 0 % 2 8 % 3 " /0 *2 2 " 2 " GLC 8 " 2 , " GL +& / 0 " 2 ? H+, " FL " 2 * ) H> & " FL " ?GL2 " GL= () = & @ " A ! , ) 2 , " & " ?FL3 " 9 ' ' ' ' ' ' ' ' " " GL, % , " 2 E " ?FL ' ( ') ' ( " GLD 2 ? H+, 2 * ) " ?FL D9'-& " MGL ) " *FL2- ' ' % 3 / 0 " GL " ?FLD@ % D)= % > 7 ( " # ) /0 - " A & " >- ) " > ) " 2 8 " = =;>,;') % ; D 1 8 ) 8!C 2 " % ) - 3 , " ! A& ) " =;>,; ' " 3 ' &' " #&2 ' ! 6; & ) ' " = B. 1 &- + &- " ) " = -& ) 6& " # - * ! ) * ! ) * ! ) " ; 2-& * ! ) * * ! ) 09/02/06 19:43:58 nachos/README 1 Nachos for Java README Compiling Nachos: Welcome to Nachos for Java. We believe that working in Java rather than You should now have a directory called nachos, containing a Makefile, C++ will greatly simplify the development process by preventing bugs this README, and a number of subdirectories. arising from memory management errors, and improving debugging support. First, put the ’nachos/bin’ directory on your PATH. This directory Getting Nachos: contains the script ’nachos’, which simply runs the Nachos code. Download nachos-java.tar.gz from the Projects section of the class To compile Nachos, go to the subdirectory for the project you wish homepage at: to compile (I will assume ’proj1/’ for Project 1 in my examples), and run: http://www-inst.EECS.Berkeley.EDU/˜cs162/ gmake Unpack it with these commands: This will compile those portions of Nachos which are relevant to the gunzip -c nachos-java.tar.gz | tar xf - project, and place the compiled .class files in the proj1/nachos directory. Additional software: You can now test Nachos from the proj1/ directory with: Nachos requires the Java Devlopment Kit, version 1.5 or later. This is installed on all instructional machines in: nachos /usr/sww/lang/jdk-1.5.0_05 To use this version of the JDK, be sure that You should see output resembling the following: /usr/sww/lang/jdk-1.5.0_05/bin is on your PATH. (This should be the case for all class accounts nachos 5.0j initializing... config interrupt timer elevators user-check grader already.) *** thread 0 looped 0 times *** thread 1 looped 0 times If you are working at home, you will need to download the JDK. *** thread 0 looped 1 times It is available from: *** thread 1 looped 1 times http://java.sun.com/j2se/1.5/ *** thread 0 looped 2 times Please DO NOT DOWNLOAD the JDK into your class account! Use the *** thread 1 looped 2 times preinstalled version instead. *** thread 0 looped 3 times *** thread 1 looped 3 times The build process for Nachos relies on GNU make. If you are running on *** thread 0 looped 4 times one of the instructional machines, be sure you run ’gmake’, as ’make’ *** thread 1 looped 4 times does not support all the features used. If you are running Linux, the Machine halting! two are equivalent. If you are running Windows, you will need to download and install a port. The most popular is the Cygnus toolkit, Ticks: total 24750, kernel 24750, user 0 available at: Disk I/O: reads 0, writes 0 Console I/O: reads 0, writes 0 http://sources.redhat.com/cygwin/mirrors.html Paging: page faults 0, TLB misses 0 Network I/O: received 0, sent 0 The Cygnus package includes ports of most common GNU utilities to Windows. This is the correct output for the "bare bones" Nachos, without any of the features you will add during the projects. For project 2, you will need a MIPS cross compiler, which is a specially compiled GCC which will run on one architecture (e.g. If you are working on a project which runs user programs (projects 2-4), Sparc) and produce files for the MIPS processor. These compilers you will also need to compile the MIPS test programs with: are already installed on the instructional machines, and are available in the directory specified by the $ARCHDIR environment gmake test variable. Command Line Arguments: If you are working at home, you will need to get a cross-compiler for yourself. Cross-compilers for Linux and Win32 will be available For a summary of the command line arguments, run: from the CS162 Projects web page. Download the cross compiler distribution and unpack it with the following command: nachos -h gunzip -c mips-x86-linux-xgcc.tar.gz | tar xf - The commands are: (Substitute the appropriate file name for mips-x86.linux-xgcc in the -d <debug flags> above command.) You need to add the mips-x86.linux-xgcc directory to Enable some debug flags, e.g. -d ti your PATH, and set an environment variable ARCHDIR to point to this directory. (Again, this has already been done for you on the -h instructional machines.) Print this help message. 09/02/06 19:43:58 nachos/README 2 -s <seed> ElevatorBank.allowElevatorGUI: Specify the seed for the random number generator Normally true. When we grade, this will be false, to prevent malicious students from running a GUI during grading. -x <program> Specify a program that UserKernel.run() should execute, NachosSecurityManager.fullySecure: instead of the value of the configuration variable Normally false. When we grade, this will be true, to enable Kernel.shellProgram additional security checks. -z Kernel.kernel: print the copyright message Specifies what kernel class to dynmically load. For proj1, this is nachos.threads.ThreadedKernel. For proj2, this should be -- <grader class> nachos.userprog.UserKernel. For proj3, nachos.vm.VMKernel. For Specify an autograder class to use, instead of proj4, nachos.network.NetKernel. nachos.ag.AutoGrader Processor.usingTLB: -# <grader arguments> Specifies whether the MIPS processor provides a page table Specify the argument string to pass to the autograder. interface or a TLB interface. In page table mode (proj2), the processor accesses an arbitrarily large kernel data structure to do -[] <config file> address translation. In TLB mode (proj3 and proj4), the processor Specifiy a config file to use, instead of nachos.conf maintains a small TLB (4 entries). Processor.numPhysPages: Nachos offers the following debug flags: The number of pages of physical memory. Each page is 1K. This is normally 64, but we can lower it in proj3 to see whether projects c: COFF loader info thrash or crash. i: HW interrupt controller info p: processor info Documentation: m: disassembly M: more disassembly The JDK provides a command to create a set of HTML pages showing all t: thread info classes and methods in program. We will make these pages available on a: process info (formerly "address space", hence a) the webpage, but you can create your own for your home machine by doing the following (from the nachos/ directory): To use multiple debug flags, clump them all together. For example, to monitor coff info and process info, run: mkdir ../doc gmake doc nachos -d ac Troubleshooting: nachos.conf: If you receive an error about "class not found exception", it may be When Nachos starts, it reads in nachos.conf from the current because you have not set the CLASSPATH environment variable. Add the directory. It contains a bunch of keys and values, in the simple following to your .cshrc: format "key = value" with one key/value pair per line. To change the default scheduler, default shell program, to change the amount of setenv CLASSPATH . memory the simulator provides, or to reduce network reliability, modify this file. Credits: Machine.stubFileSystem: Nachos was originally written by Wayne A. Christopher, Steven J. Specifies whether the machine should provide a stub file system. A Procter, and Thomas E. Anderson. It incorporates the SPIM simulator stub file system just provides direct access to the test directory. written by John Ousterhout. Nachos was rewritten in Java by Daniel Since we’re not doing the file system project, this should always Hettena. be true. Copyright: Machine.processor: Specifies whether the machine