While posix-threads.cc/_JvCondWait() will return (_JV_NOT_OWNER,_JV_INTERRUPTED, 0), which are exactly the return codes that java::lang::Object::wait() checks on, win32-threads.cc/_JvCondWait(), will return (GetLastError(),ETIMEOUT, 0). It may be the reason why java.lang.Object.wait() doesn't work properly on win32. In the test case attached, at line 20, mWorkerLock.wait(), will only wait one time. From there on, it won't wait any longer, when invoked. Release: unknown How-To-Repeat: See example.
Fix: The return codes for win32 must be mapped: (GetLastError(),ETIMEOUT, 0) to the tuple: (_JV_NOT_OWNER,_JV_INTERRUPTED, 0)
From: tromey@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: java/9254 Date: 28 Jan 2003 22:23:08 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: tromey@gcc.gnu.org 2003-01-28 22:23:08 Modified files: libjava : ChangeLog win32-threads.cc libjava/include: win32-threads.h Log message: 2003-01-28 Ranjit Mathew <rmathew@hotmail.com> Fixes PR java/9254: * include/win32-threads.h (_Jv_Mutex_t): Convert to a struct additionally containing id of the owner thread as well as the number of nested times the thread has acquired the mutex. (_Jv_MutexInit): Initialise owner thread id and refcount to 0. (_Jv_MutexDestroy): Reset owner thread id and refcount to 0. (_Jv_MutexUnlock): Check if really the owner thread, reset owner thread id to 0 before leaving, if leaving for the last time. (_Jv_MutexLock): Set owner thread id in the mutex and increment refcount. (_Jv_ThreadYield): Yield using a call to Sleep(0). * win32-threads.cc (_Jv_CondWait): Check if really owner of the passed mutex. Pass handle of the broadcast event, instead of a pointer to it in Win32 ResetEvent( ) call. Remove incorrect return values. (_Jv_CondDestroy): Close both event handles and delete critical section. (_Jv_CondNotify): Check if really the owner thread. (_Jv_CondNotifyAll): Check if really the owner thread. (_Jv_InitThreads): Change daemon_cond to a manual-reset event. (really_start): Use SetEvent( ) to signal daemon_cond. (_Jv_ThreadWait): Remove SignalObjectAndWait( ) and use WaitForSingleObject( ) instead to wait for daemon_cond to be signalled. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1594.2.48&r2=1.1594.2.49 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/win32-threads.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.8&r2=1.8.34.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/include/win32-threads.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.6&r2=1.6.4.1
From: tromey@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: java/9254 Date: 28 Jan 2003 22:23:36 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: tromey@gcc.gnu.org 2003-01-28 22:23:36 Modified files: libjava : ChangeLog win32-threads.cc libjava/include: win32-threads.h Log message: 2003-01-28 Ranjit Mathew <rmathew@hotmail.com> Fixes PR java/9254: * include/win32-threads.h (_Jv_Mutex_t): Convert to a struct additionally containing id of the owner thread as well as the number of nested times the thread has acquired the mutex. (_Jv_MutexInit): Initialise owner thread id and refcount to 0. (_Jv_MutexDestroy): Reset owner thread id and refcount to 0. (_Jv_MutexUnlock): Check if really the owner thread, reset owner thread id to 0 before leaving, if leaving for the last time. (_Jv_MutexLock): Set owner thread id in the mutex and increment refcount. (_Jv_ThreadYield): Yield using a call to Sleep(0). * win32-threads.cc (_Jv_CondWait): Check if really owner of the passed mutex. Pass handle of the broadcast event, instead of a pointer to it in Win32 ResetEvent( ) call. Remove incorrect return values. (_Jv_CondDestroy): Close both event handles and delete critical section. (_Jv_CondNotify): Check if really the owner thread. (_Jv_CondNotifyAll): Check if really the owner thread. (_Jv_InitThreads): Change daemon_cond to a manual-reset event. (really_start): Use SetEvent( ) to signal daemon_cond. (_Jv_ThreadWait): Remove SignalObjectAndWait( ) and use WaitForSingleObject( ) instead to wait for daemon_cond to be signalled. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.1645&r2=1.1646 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/win32-threads.cc.diff?cvsroot=gcc&r1=1.8&r2=1.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/include/win32-threads.h.diff?cvsroot=gcc&r1=1.6&r2=1.7
Responsible-Changed-From-To: unassigned->tromey Responsible-Changed-Why: I'm handling the administrivia
State-Changed-From-To: open->closed State-Changed-Why: I've checked in the fix. It will appear in 3.3