nachos.userprog
Class UThread

java.lang.Object
  extended by nachos.threads.KThread
      extended by nachos.userprog.UThread

public class UThread
extends KThread

A UThread is KThread that can execute user program code inside a user process, in addition to Nachos kernel code.


Field Summary
 UserProcess process
          The process to which this thread belongs.
 int[] userRegisters
          Storage for the user register set.
 
Fields inherited from class nachos.threads.KThread
schedulingState
 
Constructor Summary
UThread(UserProcess process)
          Allocate a new UThread.
 
Method Summary
protected  void restoreState()
          Restore state before receiving the processor again.
protected  void saveState()
          Save state before giving up the processor to another thread.
 
Methods inherited from class nachos.threads.KThread
compareTo, currentThread, finish, fork, getName, join, ready, selfTest, setName, setTarget, sleep, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

userRegisters

public int[] userRegisters
Storage for the user register set.

A thread capable of running user code actually has two sets of CPU registers: one for its state while executing user code, and one for its state while executing kernel code. While this thread is not running, its user state is stored here.


process

public UserProcess process
The process to which this thread belongs.

Constructor Detail

UThread

public UThread(UserProcess process)
Allocate a new UThread.

Method Detail

saveState

protected void saveState()
Save state before giving up the processor to another thread.

Overrides:
saveState in class KThread

restoreState

protected void restoreState()
Restore state before receiving the processor again.

Overrides:
restoreState in class KThread