nachos.kernel.userprog
Class UserThread

java.lang.Object
  extended by nachos.machine.NachosThread
      extended by nachos.kernel.userprog.UserThread

public class UserThread
extends nachos.machine.NachosThread

A UserThread is a NachosThread extended with the capability of executing user code. It is kept separate from AddrSpace to provide for the possibility of having multiple UserThreads running in a single AddrSpace.


Field Summary
 AddrSpace space
          The context in which this thread will execute.
private  int[] userRegisters
          User-level CPU register state.
 
Fields inherited from class nachos.machine.NachosThread
BLOCKED, JUST_CREATED, READY, RUNNING, TERMINATED
 
Constructor Summary
UserThread(java.lang.String name, java.lang.Runnable runObj, AddrSpace addrSpace)
          Initialize a new user thread.
 
Method Summary
 void restoreState()
          Restore the CPU state of a user program on a context switch.
 void saveState()
          Save the CPU state of a user program on a context switch.
 
Methods inherited from class nachos.machine.NachosThread
getName, getStatus, setRunnable, setStatus, switchTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

space

public final AddrSpace space
The context in which this thread will execute.


userRegisters

private int[] userRegisters
User-level CPU register state.

Constructor Detail

UserThread

public UserThread(java.lang.String name,
                  java.lang.Runnable runObj,
                  AddrSpace addrSpace)
Initialize a new user thread.

Parameters:
name - An arbitrary name, useful for debugging.
runObj - Execution of the thread will begin with the run() method of this object.
addrSpace - The context to be installed when this thread is executing in user mode.
Method Detail

saveState

public void saveState()
Save the CPU state of a user program on a context switch.

Overrides:
saveState in class nachos.machine.NachosThread

restoreState

public void restoreState()
Restore the CPU state of a user program on a context switch.

Overrides:
restoreState in class nachos.machine.NachosThread