next up previous contents
Next: Machine Components Up: A Road Map Through Previous: Introduction to Nachos

Nachos Machine

  Nachos simulates a machine that roughly approximates the MIPS architecture. The machine has registers, memory and a cpu. In addition, an event-driven simulated clock provides a mechanism to schedule interrupts and execute them at a later time. The simulated MIPS machine can execute arbitrary programs. One simply loads instructions into the machine's memory, initializes registers (including the program counter PCReg) and then tells the machine to start executing instructions. The machine then fetches the instruction PCReg points at, decodes it, and executes it. The process is repeated indefinitely, until an illegal operation is performed or a hardware interrupt is generated. When a trap or interrupt takes place, execution of MIPS instructions is suspended, and a Nachos interrupt service routine is invoked to deal with the condition.

Conceptually, Nachos has two modes of execution, one of which is the MIPS simulator. Nachos executes user-level processes by loading them into the simulator's memory, initializing the simulator's registers and then running the simulator. User-programs can only access the memory associated with the simulated machine. The second mode corresponds to the Nachos ``kernel.'' The kernel executes when Nachos first starts up, or when a user-program executes an instruction that causes a hardware trap (e.g., illegal instruction, page fault, system call, etc.). In ``kernel mode'', Nachos executes the way normal Unix processes execute. That is, the statements corresponding to the Nachos source code are executed, and the memory accessed corresponds to the memory assigned to Nachos variables.

Nachos does not have to execute user-level programs in order to perform useful things. Nachos supports kernel threads, allowing multiple threads to execute concurrently. In this context, Nachos behaves in a manner analogous to other thread packages. Indeed, user-level processes are executed by having a kernel thread invoke the simulator. Thus, multiprogramming makes use of multiple threads; each user-level process has a Nachos kernel thread associated with it to provide a context for executing the MIPS simulator.




next up previous contents
Next: Machine Components Up: A Road Map Through Previous: Introduction to Nachos

Thomas Narten
Mon Feb 3 15:00:27 EST 1997