2.5 Execution

The typical work flow of Nachos projects is given in Figure 19. Most of Nachos projects require modification of Java codes. For the purpose of testing, you may either write and use Java classes derived from the AutoGrader class, or run user programs compiled as COFF binary.

pict

Figure 19: The workflow for Nachos projects

2.5.1 Nachos configure file

When Nachos starts, it reads the default configure file nachos.conf from the current directory (You can explicitly specify a different configure file by nachos -[]). It contains a list of key-value pairs, in the format “key = value” with one pair per line. One can modify the configure file to change the default scheduler, default shell program, to change the amount of memory the simulator provides, or to reduce network reliability. An exmaple configure file is given in Figure 20. In different projects, the students may be required to change the settings in nachos.conf. For example, for thread related projects, Kernel.kernel should be set to nachos.threads.ThreadedKernel. The detailed options in the configure file are discussed in Table 6.

PIC

Figure 20: An example configure file




Machine.stubFileSystem

Specifies whether the machine should provide a stub file system. This option should be enabled when reading and writing files on a local disk (e.g., for user programs)



Machine.processor

Specifies whether the machine should provide a MIPS processor.



Machine.console

Specifies whether the machine should provide a console. This option should be set true if users need to interact with Nachos through a console (as required by some user programs)



Machine.disk

Specifies whether the machine should provide a simulated disk. False by default



ElevatorBank.allowElevatorGUI

True by default.



NachosSecurityManager.fullySecure

False by default. When we grade, this will be true, to enable additional security checks.



Kernel.kernel

Specifies what kernel class to dynmically load. The options are nachos.threads.ThreadedKernel, nachos.userprog.UserKernel, nachos.vm.VMKernel, and nachos.network.NetKernel.



Processor.usingTLB

Specifies whether the MIPS processor provides a page table interface or a TLB interface.



Processor.numPhysPages

The number of pages of physical memory. Each page is 1KB. The default number of pages is 64.



ThreadedKernel.scheduler

The type of CPU scheduler to use. Options include nachos.threads.RoundRobinScheduler and nachos.threads.PriorityScheduler




Table 6: Nachos configuration options

2.5.2 Makefile

The Makefile of Nachos allows compiling Nachos in command line. If you are using Eclipse or Netbeans as IDE, you will not make use of Makefile. Two Makefiles are relevant to your project. The first one is under a project directory, e.g, nachos/proj1 and the second one is in the root directory of Nachos.

The Makefile under the project directory is usually very simple. An example is given below:

1  DIR = XXX XXX
2  include ../Makefile

In first line, variable DIRS specifies the packages to be compiled. The second line includes the main Makefile for Nachos. Generally, writing Makefile is rather complicated. A full description of Make and Makefile can be found here. Fortunately, the main Nachos Makefile has been provided to you already under the root Nachos directory. Generally, there is no need to modify this file UNLESS new classes shall be included in Nachos projects. For example, to use customized AutoGrader-derived classes, you can modify the corresponding line in the Makefile:

1  ag = AutoGrader BoatGrader BasicTestGrader.java ThreadGrader1.java

2.5.3 Command line options

To debug and test Nachos project, you can flexibly use Nachos command line arguments. Running nachos -h gives the collection of Nachos command line options summarized in Table 7.


Table 7: The detailed Nachos command arguments and their functions


-d

Enable some debug flags(see Table 8), e.g. -d ti



-h

Print this help message



-s

Specify the seed for the random number generator



-x

Specify a user program that UserKernel.run() should execute, instead of the default Kernel.shellProgram, e.g. nachos -x halt.coff



Specify an autograder class to use, instead of the default nachos.ag.AutoGrader



-#

Specify the argument string to pass to the autograder



-[]

Specifiy a config file to use, instead of the default nachos.conf





Table 8: Nachos debug flags. To use multiple debug flags, clump them all together. For example, to monitor COFF info and process info, run nachos -d ac


c

COFF loader info



i

HW interrupt controller info



p

processor info



m

disassembly



M

more disassembly



t

thread info



a

process info (formerly “address space”), hence a




Various debug options can also be specified in command line as summarized in Table 8. One can specify new debug flags and corresponding outputs by including them in the Java programs. For example, flag “a” is currently defined in nachos/userprog/UserProcess.java as,

  Lib.debug(dbgProcess, "pageTable is not initialized");
  ...
  private static final char dbgProcess = 'a';

It is highly advisable for you to make use of the debug options during development.