Nachos Workstation Simulation Overview

The Nachos system includes a simulation of a MIPS-based workstation. The simulation code can be found in code/machine. The machine has the following components:
The timer acts like a periodic alarm clock. Each time the alarm goes off a timer interrupt is generated. See timer.h and for more information. Note that the timer runs in simulation time, not in real time. See interrupt.h for a discussion of how simulation time elapses.
The disk stores persistent data. The simulated disk is a very simple one. It has one recording surface. The surface is divided into tracks, and each track is divided into sectors. The operating system may issue requests to read or to write disk sectors. (Each request reads or writes a single sector.) Read and write requests are asynchronous. When a request is completed, a disk interrupt is generated.

The simulator stores the contents of the simulated disk in a Unix file called DISK_X, where X is the identifier of the simulated machine. (The machine identifier is zero by default, but it can be changed using the -m command line argument to nachos.) See disk.h and for more information.

The console simulates a display and a keyboard. The operating system may issue requests to put characters to the display, or to read characters from the keyboard. The requests are asynchronous. When incoming data is available, or when outgoing data has been sent to the display, interrupts are generated.

By default, the console input is taken from the standard input of the nachos program, and the console output is sent to standard output. Thus, console output should appear on your (real) display, and keystrokes on your (real) keyboard are taken as console input. Console input and output can be redirected to files using nachos command line arguments. See console.h and for more information.

The network provides a means of communication among multiple independent simulated workstations. The operating system can use a simulated network to send and receive small, fixed-length messages. Message delivery is unreliable - messages may be lost. The degree of unreliability can be controlled using a command line parameter. Message sending and receiving is asynchronous. When data has been sent or when data is available to be received, interrupts are generated.

The network simulation is implemented using Unix-domain sockets which have names beginning with SOCKET_. (Because of this implementation, all of the communicating simulations must be running in the same directory on the same real machine.) See network.h and for more information.

MIPS Instruction Processor
The processor is responsible for simulating the execution of user programs. The processor has a set of registers and a small (simulated) physical memory for storing user programs and their data. The contents of the registers and of memory can be read and changed by the operating system. It processor has address translation support assist in translating virtual memory addresses to physical addresses. The address translation hardware includes a optional translation lookaside buffer (TLB). The TLB can be included into the workstation simulation by setting a flag in the Makefile. By default, it is not included.

When the user program executes a system call instruction, or if a program error (such as divide-by-zero) occurs, an exception is generated. See machine.h, mipssim.h, translate.h,,, and for more information.

This component simulates the interrupt and exception mechanism. Each of the other components of the simulated machine may cause interrupts or exceptions to occur. When one occurs, the hardware transfers control to an interrupt handler (or exception handler), a function that is part of the operating system. The operating system must provide a handler for each type of interrupt or exception. See interrupt.h and for more information, and see code/userprog/ for the (rudimentary) exception handler that the operating system starts with.

Although you are encouraged to study the simulation source code, you may not modify it, except as described in code/machine/machine.h. The operating system that you build must work with the simulated workstation as given.