JanosVM v1.0 API

edu.utah.janosvm.sys
Class TeamBackEnd

java.lang.Object
  |
  +--edu.utah.janosvm.sys.Exportable
        |
        +--edu.utah.janosvm.sys.TeamBackEnd
All Implemented Interfaces:
EventHandler

class TeamBackEnd
extends Exportable
implements EventHandler

Kernel class used to represent a team, this is then extended internally with a nativeClass. The class is an Exportable since all instances of TeamBackEnd are allocated in the kernel team. The team they represent has a Team instance associated with the TeamBackEnd.

Author:
Tim Stack, Utah Janos Team
See Also:
Team, TeamHandle

Field Summary
private static int _versionMajor
           
private static int _versionMinor
           
private static java.lang.String _versionName
          Version info.
private  TeamEvent cpuOverdrawEvent
           
private  boolean dying
          Indicates whether or not the team is being terminated.
private  ExportManager em
          The ExportManager for our object.
(package private) static EventQueue eq
          Queue for events handled by the kernel.
(package private) static java.util.Stack eventPool
          Fixed-size pool of pre-allocated TeamEvent objects.
private  ExportManager.ImportEnumerator ie
          The ImportEnumerator for our ExportManager.
private static ExportManager kernelManager
           
static java.lang.String kernelName
           
private static TeamBackEnd kernelTeam
          Reference to the kernel team.
(package private) static Team kernelTeamPeer
           
private  java.lang.String name
           
private  Team peer
          The object local to the team's heap that contains per-team state specific to that team.
 
Fields inherited from class edu.utah.janosvm.sys.Exportable
anonManager, owner
 
Constructor Summary
private TeamBackEnd()
          Constructor used for the kernel team.
(package private) TeamBackEnd(java.lang.String name, ResourceSpec[] specs, kaffe.util.Ptr nativeSpecs)
          Create a user team with the given name and resources.
 
Method Summary
(package private)  boolean addDependency(TeamBackEnd dep)
          Add a dependency to this team.
(package private) static TeamEvent allocEvent()
           
private  void anchorObject(java.lang.Object obj)
          Anchor an object so the collector doesn't free it.
private  void broadcastTeamEvent(TeamEvent te)
          Broadcast a TeamEvent to the list of objects importing this object.
(package private)  void deadTeamEvent()
          Send a TeamEvent.DEAD event.
private  void doTheReap()
          Native function that collects and returns the team's resources to the VM.
(package private)  void event(int event)
          Trigger an event notification for this team.
(package private)  void finishTeamEvent()
          Send a TeamEvent.FINISHED event.
private  void floatObject(java.lang.Object obj)
          Float a previously anchored object.
(package private) static void freeEvent(TeamEvent te)
           
(package private)  java.lang.Object getClassLocal(java.lang.Class cl)
           
(package private) static java.lang.Object getCurrentClassLocal(java.lang.Class cl)
           
(package private) static TeamBackEnd getCurrentTeam()
          Get the TeamBackEnd associated with the current thread.
(package private)  int getDaemonCount()
           
(package private)  ExportManager getExportManager()
           
(package private)  int getID()
          Get the unique integer identifier for this team.
(package private) static TeamBackEnd getKernelTeam()
           
(package private)  java.lang.String getName()
           
(package private) static TeamBackEnd getObjectOwner(java.lang.Object obj)
           
(package private)  Team getPeer()
          Gets the Team peer associated with this TeamBackEnd.
(package private)  int getThreadCount()
           
 void handleEvent(Event ev)
          Handle the Event targeted to this object.
private  void nativeCage()
          Native level cage code.
private  int nativeConstructor(java.lang.String name, ResourceSpec[] specs, kaffe.util.Ptr nativeSpecs)
          Constructs the native part of the class.
private  void nativeTerminating()
          Native level code to mark the start of termination.
(package private)  void notifyOnFinish()
          Set the flag on the team object that indicates that the last non-daemon thread in the team should send out a TeamEvent.FINISHED event.
(package private)  boolean owns(java.lang.Object obj)
          Tests to see if an object is owned by this team.
(package private) static void popReservation(TeamReservation tr)
          Pop the last TeamReservation off the stack.
(package private)  TeamReservation pushReservation()
           
(package private)  TeamReservation pushReservation(int wrapCount)
           
(package private) static void returnFrom()
          End a visit and return to the previous team.
(package private)  void setClassLocal(java.lang.Class cl, java.lang.Object obj)
          Store a per-team class local object.
(package private) static void setCurrentClassLocal(java.lang.Class cl, java.lang.Object obj)
           
(package private)  void setDescription(java.lang.String desc)
           
(package private)  void setExportManager(ExportManager em)
           
(package private) static void staticNativeInit(EventQueue eq, java.lang.Thread th)
           
(package private)  boolean switchTo()
          Basic visit wrapper provided for code that operates directly on TeamBackEnds.
(package private)  boolean switchTo(int wrapCount)
          Start a visit.
(package private)  void terminate()
          Terminate this team, revoke all its exports, kill its threads and return its resources to the system.
 java.lang.String toString()
           
 
Methods inherited from class edu.utah.janosvm.sys.Exportable
getAnonymousManager, pushOwnerReservation, returnFromOwner, setAnonymousManager, switchToOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait, wait0
 

Field Detail

_versionName

private static final java.lang.String _versionName
Version info.

_versionMajor

private static final int _versionMajor

_versionMinor

private static final int _versionMinor

kernelTeam

private static TeamBackEnd kernelTeam
Reference to the kernel team.

kernelTeamPeer

static final Team kernelTeamPeer

kernelManager

private static ExportManager kernelManager

kernelName

public static final java.lang.String kernelName

eq

static final EventQueue eq
Queue for events handled by the kernel.

eventPool

static final java.util.Stack eventPool
Fixed-size pool of pre-allocated TeamEvent objects.

dying

private boolean dying
Indicates whether or not the team is being terminated.

ie

private ExportManager.ImportEnumerator ie
The ImportEnumerator for our ExportManager.

em

private ExportManager em
The ExportManager for our object.

peer

private Team peer
The object local to the team's heap that contains per-team state specific to that team. Specifically, it contains the tables of items exported from the team.

cpuOverdrawEvent

private TeamEvent cpuOverdrawEvent

name

private java.lang.String name
Constructor Detail

TeamBackEnd

private TeamBackEnd()
Constructor used for the kernel team.

TeamBackEnd

TeamBackEnd(java.lang.String name,
            ResourceSpec[] specs,
            kaffe.util.Ptr nativeSpecs)
      throws DuplicateResourceSpecException,
             IndexedResourceSpecException,
             DeadTeamException
Create a user team with the given name and resources. This is the internal version that can be used by the native code to construct a team with native resource specifications.
Parameters:
name - The name of the team.
specs - The specifications required by the team.
nativeSpecs - Native array of resource specifications.
Throws:
DuplicateResourceSpecException - if the specs array contains more than one ResourceSpec for the same resource.
IndexedResourceSpecException - if the one of the ResourceSpec's couldn't be satisfied.
Method Detail

staticNativeInit

static void staticNativeInit(EventQueue eq,
                             java.lang.Thread th)

allocEvent

static TeamEvent allocEvent()
Returns:
An a TeamEvent object from the pool.

freeEvent

static void freeEvent(TeamEvent te)
Parameters:
te - A TeamEvent allocated with allocEvent.

getKernelTeam

static TeamBackEnd getKernelTeam()
Returns:
The kernel TeamBackEnd object.

getPeer

Team getPeer()
Gets the Team peer associated with this TeamBackEnd.
Returns:
The peer object.

getName

java.lang.String getName()
Returns:
The name of the team.

nativeConstructor

private int nativeConstructor(java.lang.String name,
                              ResourceSpec[] specs,
                              kaffe.util.Ptr nativeSpecs)
                       throws DuplicateResourceSpecException
Constructs the native part of the class.
Parameters:
name - The name of this team.
specs - The resources specifications for the team.
Returns:
The index of the ResourceSpec that couldn't be satisfied.

owns

boolean owns(java.lang.Object obj)
Tests to see if an object is owned by this team. (Ownership is defined as paying for the memory used by the object instance.)
Parameters:
obj - The object to test for ownership.
Returns:
True if this TeamBackEnd owns the given object.

getObjectOwner

static TeamBackEnd getObjectOwner(java.lang.Object obj)

switchTo

boolean switchTo(int wrapCount)
           throws TeamEjectionException
Start a visit. A visit is completed with a matching call to returnFrom().
Parameters:
wrapCount - Indicates the number of wrapper functions around this one. This is required so that we can record where visit take place and can properly back out of them if an exception is thrown.
Returns:
Whether the visit was successful or not.
See Also:
returnFrom()

switchTo

boolean switchTo()
           throws TeamEjectionException
Basic visit wrapper provided for code that operates directly on TeamBackEnds.
Returns:
Whether the visit was successful or not.

returnFrom

static void returnFrom()
End a visit and return to the previous team.

XXX this shouldn't be static. Just to make the symmetry a bit more apparent, if nothing else. Also would be a bit easier to add sanity checking code with a this pointer.


getCurrentTeam

static TeamBackEnd getCurrentTeam()
Get the TeamBackEnd associated with the current thread. This returns whatever team the thread is currently executing in (i.e., during a visit), and is not necessairly the home team of the thread.
Returns:
The team that this thread is currently running in.

getID

int getID()
Get the unique integer identifier for this team. Identifiers are unique among currently executing teams, but may be re-used when a team is destroyed. (Analogous to a "PID" in unix.)
Returns:
The unique integer identifier for this team.

getThreadCount

int getThreadCount()
Returns:
The number of threads in this team.

getDaemonCount

int getDaemonCount()
Returns:
The number of daemon threads in this team.

setDescription

void setDescription(java.lang.String desc)
Parameters:
desc - A description of the contents of this team.

anchorObject

private void anchorObject(java.lang.Object obj)
Anchor an object so the collector doesn't free it. The object becomes a "root" in the collector so the collector will never free it. The object must be explicitly un-anchored before it will be freed.
See Also:
floatObject(Object)

floatObject

private void floatObject(java.lang.Object obj)
Float a previously anchored object. The object will be reclaimed when it is unreachable.
See Also:
anchorObject(Object)

doTheReap

private void doTheReap()
Native function that collects and returns the team's resources to the VM.

event

void event(int event)
Trigger an event notification for this team.
Parameters:
event - The TeamEvent number that indicates what event this is.

deadTeamEvent

void deadTeamEvent()
Send a TeamEvent.DEAD event.

finishTeamEvent

void finishTeamEvent()
Send a TeamEvent.FINISHED event.

nativeTerminating

private void nativeTerminating()
Native level code to mark the start of termination.

nativeCage

private void nativeCage()
Native level cage code.

terminate

void terminate()
Terminate this team, revoke all its exports, kill its threads and return its resources to the system.

If the calling thread is part of the team being terminated then this function will not return.

Note that termination is delayed by any active visits from other teams, so to provide quick termination all visits must be "short".


pushReservation

TeamReservation pushReservation(int wrapCount)
                          throws DeadTeamException
Parameters:
wrapCount - Indicates the number of wrapper functions around this one. This is required so that we can record where pushes take place and can properly back out of them if an exception is thrown.
Returns:
A TeamReservation object that reserves this team.

pushReservation

TeamReservation pushReservation()
                          throws DeadTeamException

popReservation

static void popReservation(TeamReservation tr)
Pop the last TeamReservation off the stack. NOTE: the given tr is just used as a sanity check to make sure an intervening reservation hasn't been skipped.

setClassLocal

void setClassLocal(java.lang.Class cl,
                   java.lang.Object obj)
Store a per-team class local object.
Parameters:
cl - The class the object should be stored with.
obj - The object to store with the class.

setCurrentClassLocal

static void setCurrentClassLocal(java.lang.Class cl,
                                 java.lang.Object obj)

getClassLocal

java.lang.Object getClassLocal(java.lang.Class cl)
Parameters:
cl - The class to retrieve the local object for.
Returns:
The Object associated with the class or null.

getCurrentClassLocal

static java.lang.Object getCurrentClassLocal(java.lang.Class cl)

addDependency

boolean addDependency(TeamBackEnd dep)
Add a dependency to this team.
Parameters:
th - The team this one should depend on.
Returns:
True if the addition succeeded, false otherwise.

notifyOnFinish

void notifyOnFinish()
Set the flag on the team object that indicates that the last non-daemon thread in the team should send out a TeamEvent.FINISHED event.

setExportManager

void setExportManager(ExportManager em)
Parameters:
em - The object thats managing this export.

getExportManager

ExportManager getExportManager()
Returns:
The object thats managing this export.

broadcastTeamEvent

private void broadcastTeamEvent(TeamEvent te)
Broadcast a TeamEvent to the list of objects importing this object.
Parameters:
te - The event to broadcast.

handleEvent

public void handleEvent(Event ev)
Description copied from interface: EventHandler
Handle the Event targeted to this object.
Specified by:
handleEvent in interface EventHandler
Following copied from interface: edu.utah.janosvm.sys.EventHandler
Parameters:
ev - The Event to process.
See Also:
Event.setTarget(edu.utah.janosvm.sys.EventHandler)

toString

public java.lang.String toString()
Overrides:
toString in class Exportable

JanosVM v1.0 API

This documentation is Copyright (C) 2000-2003 The University of Utah. All Rights Reserved. See the documentation license for distribution terms and restrictions.
Documentation, software, and mailing lists for the JanosVM can be found at the Janos Project web page: http://www.cs.utah.edu/flux/janos/
Generated on Feb 13, 2003