Index: rvm/src/org/jikesrvm/scheduler/RVMThread.java =================================================================== --- rvm/src/org/jikesrvm/scheduler/RVMThread.java (revision 15420) +++ rvm/src/org/jikesrvm/scheduler/RVMThread.java (working copy) @@ -1480,7 +1480,14 @@ this(MemoryManager.newStack((stacksize <= 0) ? STACK_SIZE_NORMAL : (int) stacksize), thread, name, daemon, false, priority); } - final void acknowledgeBlockRequests() { + /** + * Check if the thread has block requests (for example, for suspension and GC). If + * it does, clear the requests and marked the thread as blocked for that request. + * If there were any block requests, do a broadcast() on the thread's monitor(). + * This is an internal method and should only be called from code that implements + * thread blocking. The monitor() lock must be held for this method to work properly. + */ + private void acknowledgeBlockRequests() { boolean hadSome = false; if (VM.VerifyAssertions) VM._assert(blockAdapters != null); @@ -1497,8 +1504,11 @@ } /** - * Checks if the thread is supposed to be blocked. Only call this method when - * already holding the monitor(), for two reasons: + * Checks if the thread system has acknowledged that the thread is supposed + * to be blocked. This will return true if the thread is actually blocking, or + * if the thread is running native code but is guaranteed to block before + * returning to Java. Only call this method when already holding the monitor(), + * for two reasons: *
+ * This method takes care of all bookkeeping and notifications required when a + * a thread that has been requested to block instead decides to run native code. + * Threads enter native code never need to block, since they will not be executing + * any Java code. However, such threads must ensure that any system services (like + * GC) that are waiting for this thread to stop are notified that the thread has + * instead chosen to exit Java. As well, any requests to perform a sot handshake + * must be serviced and acknowledged. + */ private void enterNativeBlockedImpl(boolean jni) { if (traceReallyBlock) VM.sysWriteln("Thread #", threadSlot, " entering native blocked."); @@ -1716,6 +1741,7 @@ nativeEnteredBlocked++; setExecStatus(BLOCKED_IN_NATIVE); } + handleHandshakeRequest(); acknowledgeBlockRequests(); commitSoftRendezvous = softRendezvousCheckAndClear(); monitor().unlock();