javax.realtime.DSS
Class Resource

java.lang.Object
  extended byjavax.realtime.DSS.Resource
Direct Known Subclasses:
FIFOResource, PreemptableResource, PriorityCeilingResource, PriorityInheritanceResource, PriorityResource

public abstract class Resource
extends java.lang.Object

Super class for all unit resources, i.e., object contended for by

Field Summary
protected  RelativeTime busyTimeThusFar
           
protected  int count
          The re-entrancy count of this Resource; zero when not held by any RealtimeThread;
protected  AbsoluteTime creationTime
           
 RealtimeThread holderThread
          The current holder of this Resource; if null, the resource is not currently held.
protected  AbsoluteTime lastGrant
           
protected  AbsoluteTime lastRelease
           
 java.lang.String name
          The name of this Resource.
protected  boolean signalPriorityInversion
           
protected  WaiterSet waiters
          The waiter set of this resource, used to implement the scheduling policy of this resource.
 
Constructor Summary
Resource(java.lang.String name, boolean signalPriorityInversion)
          Constructor
 
Method Summary
abstract  void adjustPriority(RealtimeThread thread)
          Adjust the priority of this RealtimeThread, according to resources currently held.
 double dutyCycle()
           
 void finalize()
           
static java.util.Set getExtent()
          To support backtracking
protected  void giveResourceTo(RealtimeThread thread)
          Give this Resource to the given thread.
 int maxWaiterPriority()
          Test whether this resource is currently experiencing priority inversion, i.e., is held by a RealtimeThread with a priority later than that of a waiting thread.
static void printAllStatistics()
           
 void printStatistics()
           
abstract  void release()
          Release this resource.
 void releaseIfHeld()
          Release this Resource if held.
abstract  void seize()
          Seize this resource, waiting if necessary.
 void seize(Resource second)
          Conjunctive seize, i.e., seize both this and the given resource.
 void seizeIfNotHeld()
          Seize this Resource if not already held.
static void setExtent(java.util.Set newExtent)
           
 java.lang.String toString()
          Construct a printable representation of this Resource
 java.util.Iterator waiterIterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public java.lang.String name
The name of this Resource.


creationTime

protected AbsoluteTime creationTime

lastGrant

protected AbsoluteTime lastGrant

lastRelease

protected AbsoluteTime lastRelease

busyTimeThusFar

protected RelativeTime busyTimeThusFar

holderThread

public RealtimeThread holderThread
The current holder of this Resource; if null, the resource is not currently held.


count

protected int count
The re-entrancy count of this Resource; zero when not held by any RealtimeThread;


signalPriorityInversion

protected boolean signalPriorityInversion

waiters

protected WaiterSet waiters
The waiter set of this resource, used to implement the scheduling policy of this resource.

Constructor Detail

Resource

public Resource(java.lang.String name,
                boolean signalPriorityInversion)
Constructor

Parameters:
name - the name of this resource
Method Detail

finalize

public void finalize()

seize

public abstract void seize()
                    throws java.lang.InterruptedException,
                           ThreadTerminatedException
Seize this resource, waiting if necessary.

Throws:
java.lang.InterruptedException
ThreadTerminatedException

seize

public void seize(Resource second)
           throws java.lang.InterruptedException,
                  ThreadTerminatedException
Conjunctive seize, i.e., seize both this and the given resource. If one (or more is not free, wait until they are both free)

Parameters:
second - The second Resource to seize, in addition to this Resource
Throws:
java.lang.InterruptedException - Thrown if the seizing RealtimeThread is shut down while waiting for a Resource
ThreadTerminatedException

seizeIfNotHeld

public void seizeIfNotHeld()
                    throws java.lang.InterruptedException,
                           ThreadTerminatedException
Seize this Resource if not already held. This method can be useful after hold method calls where it is unknown upon return whether the resource is still held or was stolen away, e.g., by a higher priority thread.

Throws:
java.lang.InterruptedException
ThreadTerminatedException

release

public abstract void release()
                      throws ThreadTerminatedException
Release this resource.

Throws:
ThreadTerminatedException

releaseIfHeld

public void releaseIfHeld()
                   throws ThreadTerminatedException
Release this Resource if held. This method can be useful after hold method calls where it is unknown upon return whether the resource is still held or was stolen away, e.g., by a higher priority thread.

Throws:
ThreadTerminatedException

giveResourceTo

protected void giveResourceTo(RealtimeThread thread)
                       throws ThreadTerminatedException
Give this Resource to the given thread. This maintains all the resource possession invariants on the new thread and the holder thread, each of which may be null, indicating that the resource is not held by any thread. Implementation note: this method must be called by seize and release methods in subclasses, in order for resource utilization statistics to be properly logged.

Parameters:
thread - the thread to be given the Resource; may be null
Throws:
ThreadTerminatedException

waiterIterator

public java.util.Iterator waiterIterator()

dutyCycle

public double dutyCycle()

adjustPriority

public abstract void adjustPriority(RealtimeThread thread)
Adjust the priority of this RealtimeThread, according to resources currently held.


toString

public java.lang.String toString()
Construct a printable representation of this Resource

Returns:
the printable representation

maxWaiterPriority

public int maxWaiterPriority()
Test whether this resource is currently experiencing priority inversion, i.e., is held by a RealtimeThread with a priority later than that of a waiting thread.

Returns:
true iff this resource is experiencing priority inversion

printAllStatistics

public static void printAllStatistics()

printStatistics

public void printStatistics()

getExtent

public static java.util.Set getExtent()
To support backtracking

Returns:
the extent set for

setExtent

public static void setExtent(java.util.Set newExtent)