nachos.kernel.userprog
Class ExceptionHandler

java.lang.Object
  extended by nachos.kernel.userprog.ExceptionHandler
All Implemented Interfaces:
nachos.machine.ExceptionHandler

public class ExceptionHandler
extends java.lang.Object
implements nachos.machine.ExceptionHandler

An ExceptionHandler object provides an entry point to the operating system kernel, which can be called by the machine when an exception occurs during execution in user mode. Examples of such exceptions are system call exceptions, in which the user program requests service from the OS, and page fault exceptions, which occur when the user program attempts to access a portion of its address space that currently has no valid virtual-to-physical address mapping defined. The operating system must register an exception handler with the machine before attempting to execute programs in user mode.


Constructor Summary
ExceptionHandler()
           
 
Method Summary
 void handleException(int which)
          Entry point into the Nachos kernel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionHandler

public ExceptionHandler()
Method Detail

handleException

public void handleException(int which)
Entry point into the Nachos kernel. Called when a user program is executing, and either does a syscall, or generates an addressing or arithmetic exception. For system calls, the following is the calling convention: system call code -- r2, arg1 -- r4, arg2 -- r5, arg3 -- r6, arg4 -- r7. The result of the system call, if any, must be put back into r2. And don't forget to increment the pc before returning. (Or else you'll loop making the same system call forever!)

Specified by:
handleException in interface nachos.machine.ExceptionHandler
Parameters:
which - The kind of exception. The list of possible exceptions is in Machine.java.