All Packages  This Package  Class Hierarchy  Class Search  Index

Class utah.npm.core.Lock
java.lang.Object
   |
   +----utah.npm.core.Debuggable
           |
           +----utah.npm.core.Lock

  Summary

class  Lock
     extends utah.npm.core.Debuggable
{
          // Fields 2
     private boolean locked_;
     private Thread owner_;

          // Constructors 1
     public Lock();

          // Methods 7
     public void assertLocked();
     public void assertUnlocked();
     public boolean isLocked();
     public synchronized void lock();
     public native String toString();
     public synchronized boolean trylock();
     public synchronized void unlock();
}

Implment a "kernel"-internal mutex object. Through the magic of a pre-processor there are two versions of this class. The optimized version is entirely implemented with native methods, the unoptimized version is implemented entirely in Java.

Version:
NPMJava 0.5.0 April, 1998
Author:
Patrick Tullmann tullmann@cs.utah.edu




  Fields

· locked_

Summary  |  Top

   private boolean locked_

Flag if the lock is locked or not.


· owner_

Summary  |  Top
   private Thread owner_

Record the owning thread of this lock. This is used for debugging (to make sure a thread does not try to lock a lock it owns, and will be used for CPU Inheritance Scheduling.


  Constructors

· Lock

Summary  |  Top

   public Lock() 


  Methods

· isLocked

Summary  |  Top
   public boolean isLocked() 

Return true if this lock is already held.

Returns:
true if the lock is held, false if not.

See Also: trylock



· assertLocked

Summary  |  Top
   public void assertLocked() 

Assert that this lock is locked.



· assertUnlocked

Summary  |  Top
   public void assertUnlocked() 

Assert that the current thread doesn't own this lock. (Some other thread certainly might, and that's just peachy.)

Calls panic() if the lock is already held by the current thread.



· lock

Summary  |  Top
   public synchronized void lock() 

Acquire this lock.



· unlock

Summary  |  Top
   public synchronized void unlock() 

Release this lock. The current thread must own the lock.



· trylock

Summary  |  Top
   public synchronized boolean trylock() 

Try to acquire this lock. The current thread should not already own this lock.

Returns:
true if the lock was acquired, false if it is already owned.


· toString

Summary  |  Top
   public native String toString() 

Convert this lock to a string representation. This is native because we want to avoid dependencies on java.lang.* classes that may not be loaded into the space. (Specifically: java.lang.Integer, java.lang.Double, etc. for printing the name of the owner thread and the hash code.)

Overrides:
toString in class Object


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7