|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.scheduler.Monitor
public class Monitor
Implementation of a heavy lock and condition variable implemented using the primitives available from the operating system. Currently we use a pthread_mutex_t and pthread_cond_it. When instantiated, the mutex and cond are allocated. There is currently no way to destroy either (thus, pool and reuse accordingly).
It is perfectly safe to use this throughout the VM for locking. It is meant to provide roughly the same functionality as Java monitors, except:
Field Summary | |
---|---|
int |
acquireCount
|
(package private) int |
holderSlot
|
(package private) Word |
monitor
|
(package private) int |
recCount
|
Constructor Summary | |
---|---|
Monitor()
Allocate a heavy condition variable and lock. |
Method Summary | |
---|---|
void |
broadcast()
Send a broadcast, which should awaken anyone who is currently blocked in any of the wait methods. |
void |
lockedBroadcastNoHandshake()
Send a broadcast after first acquiring the lock. |
void |
lockNoHandshake()
Wait until it is possible to acquire the lock and then acquire it. |
static boolean |
lockNoHandshake(Monitor l)
|
void |
lockWithHandshake()
Wait until it is possible to acquire the lock and then acquire it. |
static void |
lockWithHandshake(Monitor m1,
Word priority1,
Monitor m2,
Word priority2)
|
private void |
lockWithHandshakeNoRec()
|
private void |
lockWithHandshakeNoRecImpl()
|
void |
relockNoHandshake(int recCount)
Relock the mutex after using unlockCompletely. |
void |
relockWithHandshake(int recCount)
Relock the mutex after using unlockCompletely, but do so "nicely". |
private void |
relockWithHandshakeImpl(int recCount)
|
void |
timedWaitAbsoluteNoHandshake(long whenWakeupNanos)
Wait until someone calls broadcast, or until the clock reaches the given time. |
void |
timedWaitAbsoluteWithHandshake(long whenWakeupNanos)
Wait until someone calls broadcast, or until the clock reaches the given time. |
private void |
timedWaitAbsoluteWithHandshakeImpl(long whenWakeupNanos)
|
void |
timedWaitRelativeNoHandshake(long delayNanos)
Wait until someone calls broadcast, or until at least the given number of nanoseconds pass. |
void |
timedWaitRelativeWithHandshake(long delayNanos)
Wait until someone calls broadcast, or until at least the given number of nanoseconds pass. |
private void |
timedWaitRelativeWithHandshakeImpl(long delayNanos)
|
void |
unlock()
Release the lock. |
static void |
unlock(boolean b,
Monitor l)
|
int |
unlockCompletely()
Completely release the lock, ignoring recursion. |
void |
waitNoHandshake()
Wait until someone calls broadcast. |
void |
waitWithHandshake()
Wait until someone calls broadcast. |
private void |
waitWithHandshakeImpl()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
Word monitor
int holderSlot
int recCount
public int acquireCount
Constructor Detail |
---|
public Monitor()
Method Detail |
---|
public void lockNoHandshake()
This blocking method method does not notify the threading subsystem that it is blocking. Thus, if someone (like, say, the GC) requests that the thread is blocked then their request will block until this method unblocks. If this sounds like it might be undesirable, call lockNicely instead.
public void relockNoHandshake(int recCount)
public void lockWithHandshake()
This blocking method method notifies the threading subsystem that it is blocking. Thus, it may be safer than calling lock. But, its reliance on threading subsystem accounting methods may mean that it cannot be used in certain contexts (say, the threading subsystem itself).
This method will ensure that if it blocks, it does so with the mutex not held. This is useful for cases where the subsystem that requested you to block needs to acquire the lock you were trying to acquire when the blocking request came.
It is usually not necessary to call this method instead of lock(), since most VM locks are held for short periods of time.
private void lockWithHandshakeNoRec()
private void lockWithHandshakeNoRecImpl()
public void relockWithHandshake(int recCount)
private void relockWithHandshakeImpl(int recCount)
public void unlock()
public int unlockCompletely()
public void waitNoHandshake()
This blocking method method does not notify the threading subsystem that it is blocking. Thus, if someone (like, say, the GC) requests that the thread is blocked then their request will block until this method unblocks. If this sounds like it might be undesirable, call waitNicely instead.
public void timedWaitAbsoluteNoHandshake(long whenWakeupNanos)
This blocking method method does not notify the threading subsystem that it is blocking. Thus, if someone (like, say, the GC) requests that the thread is blocked then their request will block until this method unblocks. If this sounds like it might be undesirable, call timedWaitAbsoluteNicely instead.
public void timedWaitRelativeNoHandshake(long delayNanos)
This blocking method method does not notify the threading subsystem that it is blocking. Thus, if someone (like, say, the GC) requests that the thread is blocked then their request will block until this method unblocks. If this sounds like it might be undesirable, call timedWaitRelativeNicely instead.
public void waitWithHandshake()
This blocking method notifies the threading subsystem that it is blocking. Thus, it is generally safer than calling wait. But, its reliance on threading subsystem accounting methods may mean that it cannot be used in certain contexts (say, the threading subsystem itself).
This method will ensure that if it blocks, it does so with the mutex not held. This is useful for cases where the subsystem that requested you to block needs to acquire the lock you were trying to acquire when the blocking request came.
private void waitWithHandshakeImpl()
public void timedWaitAbsoluteWithHandshake(long whenWakeupNanos)
This blocking method method notifies the threading subsystem that it is blocking. Thus, it is generally safer than calling timedWaitAbsolute. But, its reliance on threading subsystem accounting methods may mean that it cannot be used in certain contexts (say, the threading subsystem itself).
This method will ensure that if it blocks, it does so with the mutex not held. This is useful for cases where the subsystem that requested you to block needs to acquire the lock you were trying to acquire when the blocking request came.
private void timedWaitAbsoluteWithHandshakeImpl(long whenWakeupNanos)
public void timedWaitRelativeWithHandshake(long delayNanos)
This blocking method method notifies the threading subsystem that it is blocking. Thus, it is generally safer than calling timedWaitRelative. But, its reliance on threading subsystem accounting methods may mean that it cannot be used in certain contexts (say, the threading subsystem itself).
This method will ensure that if it blocks, it does so with the mutex not held. This is useful for cases where the subsystem that requested you to block needs to acquire the lock you were trying to acquire when the blocking request came.
private void timedWaitRelativeWithHandshakeImpl(long delayNanos)
public void broadcast()
public void lockedBroadcastNoHandshake()
broadcast
.
public static boolean lockNoHandshake(Monitor l)
public static void unlock(boolean b, Monitor l)
public static void lockWithHandshake(Monitor m1, Word priority1, Monitor m2, Word priority2)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |