Not Another Completely Heuristic Operating System
Not Another Completely Heuristic Operating System, or Nachos, is instructional software for teaching undergraduate, and potentially graduate level operating systems courses. It was developed at the University of California, Berkeley, designed by Thomas Anderson, and is used by numerous schools around the world.
Originally written in C++ for MIPS, Nachos runs as a user-process on a host operating system. A MIPS simulator executes the code for any user programs running on top of the Nachos operating system. Ports of the Nachos code exist for a variety of architectures.
In addition to the Nachos code, a number of assignments are provided with the Nachos system. The goal of Nachos is to introduce students to concepts in operating system design and implementation by requiring them to implement significant pieces of functionality within the Nachos system.
In Nachos' case, Operating System simulator simply means that you can run an OS on top of another one, similar to Bochs/VMware. It features emulation for:
- A CPU
- A hard drive
- An interrupt controller, timer, and misc. other components
Nachos version 3.4 has been the stable, commonly used version of Nachos for many years. Nachos version 4.0 has existed as a beta since approximately 1996.
Implementation
Nachos has various modules implementing the functionality of a basic operating system. The wrapper functions for various system calls of the OS kernel are generally implemented in a manner similar to that of the UNIX system calls. Various parts of the OS are instantiated as objects using the native code. For example, a class
Machineis used as the master class of the simulated machine. It contains various objects, such as FileSystem, Processor, Timer, etc. which are defined to simulate various hardware aspects.Major components
NachOS Machine - Nachos simulates a machine that roughly approximates the MIPS architecture. The machine has registers, memory and a CPU. The Nachos/MIPS machine is implemented by the Machine object, an instance of which is created when Nachos starts up. It contains methods like Run, ReadRegister, WriteRegister, etc. It also defines an interrupt object to handle interrupts. Timer and statistics are also implemented in this.NachOS Threads - In NachOS a thread class is defined. A thread has an associated state with it which may be ready, running, blocked or just created. The thread object has various methods like PutThreadToSleep, YieldCPU, ThreadFork, ThreadStackAllocate, etc. Each thread runs at a virtual address space.
NachOS UserPrograms - Nachos runs user programs in their own private address space. Nachos can run any MIPS binary, assuming that it restricts itself to only making system calls that Nachos understands. In Unix, "a.out" files are stored in "coff" format. Nachos requires that executables be in the simpler "Noff" format. To convert binaries of one format to the other, use the coff2noff program.