2.4 Organization of Nachos 5.0j sources

The Nachos API Javadoc can be found HERE. Alternatively, you can produce your own Javadoc by following the instruction in command line or through eclipse. This documentation is very important for you to understand the code structure of Nachos. Nachos 5.0j is composed of 7 main packages as summarized in Table 1.


Table 1: The packages in Nachos


Packages



nachos.ag

Provides classes that can be used to automatically grade Nachos projects.



nachos.machine

Provides classes that implement the Nachos simulated machine. The key components of Nachos machine are implemented here.



nachos.network

Provides classes that allow Nachos processes to communicate over the network.



nachos.security

Provides classes that can be used to protect the host system from malicious Nachos kernels.



nachos.threads

Provides classes that support a multithreaded kernel. The logic of thread scheduling will be implemented here.



nachos.userprog

Provides classes that allow Nachos to load and execute single-threaded user programs in separate address spaces.



nachos.vm

Provides classes that allow Nachos processes to be demand paged, and to use a hardware TLB for address translation.




2.4.1 nachos.machine

Among these packages, nachos.machine is the most important one. The classes in this package implement the simulated machine, important abstract classes and data structures. The main entry point of the Nachos is also contained in this package, more specifically, in nachos.machine.Machine. Next, we will describe some important classes in nachos.machine. For a complete reference of the package, interested reader can check the Nachos Javadoc.


Table 2: Main classes in nachos.machine


Class Summary



ArrayFile

A read-only OpenFile backed by a byte array.



Coff

A COFF (common object file format) loader. This class combining with CoffSection define the internal structures of user program in Nachos.



CoffSection

A CoffSection manages a single section within a COFF executable.



Config

Provides routines to access the Nachos configuration. To understand how Nachos parse configure file, going through this class is a good idea.



Kernel

An OS kernel. This class is the superclass of nachos.threads.ThreadedKernel.



Lib

Provides miscellaneous library routines.



Machine

The master class of the simulated machine. It also contains the main entry of Nachos.



OpenFile

A file that supports reading, writing, and seeking.



StubFileSystem

This class implements a file system that redirects all requests to the host operating system’s file system.



TCB

A TCB simulates the low-level details necessary to create, context-switch, and destroy Nachos threads.



TranslationEntry

A single translation between a virtual page and a physical page. Note that TLB entries are of type TranslationEntry, the same class used for page table entries.




2.4.2 Others

Since nachos.machine implements the simulated Nachos machine, it should remain intact. Modification to Nachos is mostly limited to other packages. For example, the thread related projects will only involve changes to package nachos.threads.

According to the project requirement, you only need to focus on the specific packages. In the programming assignment, we will deal with nachos.threads, nachos.userprog, and nachos.vm. See Table 3– 5 for the classes in each package.


Table 3: The class description in nachos.threads


Class Summary



Alarm

Uses the hardware timer to provide preemption, and to allow threads to sleep until a certain time.



Communicator

A communicator allows threads to synchronously exchange 32-bit messages.



Condition

An implementation of condition variables built upon semaphores.



Condition2

An implementation of condition variables that disables interrupt()s for synchronization.



ElevatorController

A controller for all the elevators in an elevator bank.



KThread

A KThread is a thread that can be used to execute Nachos kernel code.



Lock

A Lock is a synchronization primitive that has two states, busy and free.



LotteryScheduler

A scheduler that chooses threads using a lottery.



PriorityScheduler

A scheduler that chooses threads based on their priorities.



Rider

A single rider.



RoundRobinScheduler

A round-robin scheduler tracks waiting threads in FIFO queues, implemented with linked lists.



Scheduler

Coordinates a group of thread queues of the same kind.



Semaphore

A Semaphore is a synchronization primitive with an unsigned value.



SynchList

A synchronized queue.



ThreadedKernel

A multi-threaded OS kernel.



ThreadQueue

Schedules access to some sort of resource with limited access constraints.





Table 4: The class description of nachos.userprog


Class Summary



SynchConsole

Provides a simple, synchronized interface to the machine’s console.



UserKernel

A kernel that can support multiple user processes.



UserProcess

Encapsulates the state of a user process that is not contained in its user thread (or threads).



UThread

A UThread is KThread that can execute user program code inside a user process, in addition to Nachos kernel code.





Table 5: The class description of nachos.vm


Class Summary



VMKernel

A kernel that can support multiple demand-paging user processes.