nachos.ag
Class AutoGrader

java.lang.Object
  extended by nachos.ag.AutoGrader

public class AutoGrader
extends Object

The default autograder. Loads the kernel, and then tests it using Kernel.selfTest().


Constructor Summary
AutoGrader()
          Allocate a new autograder.
 
Method Summary
 boolean canReceivePacket(Privilege privilege)
          Request permission to receive a packet.
 boolean canSendPacket(Privilege privilege)
          Request permission to send a packet.
 Coff createLoader(OpenFile file)
          Notify the autograder that a COFF loader is being constructed for the specified file.
 boolean exceptionHandler(Privilege privilege)
          Notify the autograder that a user program executed a syscall instruction.
 void finishingCurrentThread()
          Notify the autograder that the current thread has finished.
 void readyThread(KThread thread)
          Notify the autograder that the specified thread has moved to the ready state.
 void runningThread(KThread thread)
          Notify the autograder that the specified thread is now running.
 void runProcessor(Privilege privilege)
          Notify the autograder that Processor.run() was invoked.
 void setIdleThread(KThread idleThread)
          Notify the autograder that the specified thread is the idle thread.
 void start(Privilege privilege)
          Start this autograder.
 void timerInterrupt(Privilege privilege, long time)
          Notify the autograder that a timer interrupt occurred and was handled by software if a timer interrupt handler was installed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoGrader

public AutoGrader()
Allocate a new autograder.

Method Detail

start

public void start(Privilege privilege)
Start this autograder. Extract the -# arguments, call init(), load and initialize the kernel, and call run().

Parameters:
privilege - encapsulates privileged access to the Nachos machine.

setIdleThread

public void setIdleThread(KThread idleThread)
Notify the autograder that the specified thread is the idle thread. KThread.createIdleThread() must call this method before forking the idle thread.

Parameters:
idleThread - the idle thread.

readyThread

public void readyThread(KThread thread)
Notify the autograder that the specified thread has moved to the ready state. KThread.ready() must call this method before returning.

Parameters:
thread - the thread that has been added to the ready set.

runningThread

public void runningThread(KThread thread)
Notify the autograder that the specified thread is now running. KThread.restoreState() must call this method before returning.

Parameters:
thread - the thread that is now running.

finishingCurrentThread

public void finishingCurrentThread()
Notify the autograder that the current thread has finished. KThread.finish() must call this method before putting the thread to sleep and scheduling its TCB to be destroyed.


timerInterrupt

public void timerInterrupt(Privilege privilege,
                           long time)
Notify the autograder that a timer interrupt occurred and was handled by software if a timer interrupt handler was installed. Called by the hardware timer.

Parameters:
privilege - proves the authenticity of this call.
time - the actual time at which the timer interrupt was issued.

exceptionHandler

public boolean exceptionHandler(Privilege privilege)
Notify the autograder that a user program executed a syscall instruction.

Parameters:
privilege - proves the authenticity of this call.
Returns:
true if the kernel exception handler should be called.

runProcessor

public void runProcessor(Privilege privilege)
Notify the autograder that Processor.run() was invoked. This can be used to simulate user programs.

Parameters:
privilege - proves the authenticity of this call.

createLoader

public Coff createLoader(OpenFile file)
Notify the autograder that a COFF loader is being constructed for the specified file. The autograder can use this to provide its own COFF loader, or return null to use the default loader.

Parameters:
file - the executable file being loaded.
Returns:
a loader to use in loading the file, or null to use the default.

canSendPacket

public boolean canSendPacket(Privilege privilege)
Request permission to send a packet. The autograder can use this to drop packets very selectively.

Parameters:
privilege - proves the authenticity of this call.
Returns:
true if the packet should be sent.

canReceivePacket

public boolean canReceivePacket(Privilege privilege)
Request permission to receive a packet. The autograder can use this to drop packets very selectively.

Parameters:
privilege - proves the authenticity of this call.
Returns:
true if the packet should be delivered to the kernel.