JanosVM v1.0 API

edu.utah.janosvm.sys
Class TeamReservation

java.lang.Object
  |
  +--edu.utah.janosvm.sys.TeamReservation

public class TeamReservation
extends java.lang.Object

Record a reservation with another team. A TeamReservation is a link between two teams that prevents either from being terminated. A TeamReservation is more flexible than TeamHandle.switchTo(), as the termination-delaying time can be expanded to include more than the context switch to the other team.

While an active reservation delays termination of two teams, there are two conditions that can cause a TeamEjectionException during a visit:

If a thread blocks on Object.wait, that will re-enable termination of the Teams involved. If the team is terminated during a wait, an exception will be thrown to back the thread out of the visit. (Most likely a TeamEjectionException.)

If a thread tries to allocate memory during a visit, and the current Team has reached its memory limits, the allocation will throw a TeamEjectionException. This exception may also occur during a throw statement. In all cases, such an exception implies that the visited Team will be terminated.

XXX need something about inter-Team pointers and how to be careful Object.clone(), etc...

CAUTION: TeamReservation's must be created and popped at the same scope. Ideally, there would be language support for TeamReservations that works like synchronized does for restricting monitor lock/unlock to the same scope. Of course, you should always use visit/leave in pairs, inside the push/pop, and you shouldn't use the TeamReservation after a pop.

Here's an example:

      try {
          TeamReservation resv;
          Object obj;
          resv = otherTeam.pushReservation();
          
          resv.visit();
          // Do things in the context of 'otherTeam'
          obj = lookupSimpleFoo();
          resv.leave();
          
          // Do things in original context, but guarantee that
          // otherTeam will not go away ... Reservation still active. 
          
          Object localObj = new Foo(obj);
          
          // End the Reservation, as we're done with all pointers into otherTeam
          // (Assuming the Foo constructor didn't do anything stupid.)
          resv.pop();
      } catch (DeadTeamException e) {
          // pushReservation failed
      } catch (TeamEjectionException e) {
          // allocation/throw failed during visit
      }
 

Author:
Tim Stack, Utah Janos Team
See Also:
TeamHandle.pushReservation(), Team#popReservation(), TeamHandle.switchTo()

Constructor Summary
private TeamReservation()
          Hide the constructor.
 
Method Summary
static void leave()
          Return to the previous team.
 void pop()
          Pop this TeamReservation off the stack.
 java.lang.String toString()
           
 void visit()
          Switch the current thread to the team encoded in this Reservation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait, wait0
 

Constructor Detail

TeamReservation

private TeamReservation()
Hide the constructor. No one can allocate a TeamReservation, as the JVM manufactures them in special memory in response to a Team.pushReservation().
See Also:
TeamHandle.pushReservation()
Method Detail

visit

public void visit()
           throws TeamEjectionException
Switch the current thread to the team encoded in this Reservation.
See Also:
leave()

leave

public static void leave()
Return to the previous team.
See Also:
visit()

pop

public void pop()
Pop this TeamReservation off the stack. This is no longer a useful object after being popped. NOTE: TeamReservations must be popped in the order they were {@linkplain Team#pushReservation pushed}. More over, they should be popped in the same scope as they were pushed.

toString

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

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