From a05c032678f1ab4aa7cc08f00a0d963e751850be Mon Sep 17 00:00:00 2001 From: Maurilio Longo Date: Fri, 13 Feb 2009 10:18:28 +0000 Subject: [PATCH] 2009-02-13 11:15 UTC+0100 Maurilio Longo (maurilio.longo@libero.it) * harbour/include/hbthread.h * harbour/source/vm/thread.c ! fixed a bug on OS/2 MT implementation adding a new function, _hb_cond_timed_wait() because when a semaphore gets posted it has to be reset, otherwise it does not stop new threads entering it in a wait. --- harbour/ChangeLog | 7 +++++++ harbour/include/hbthread.h | 4 ++-- harbour/source/vm/thread.c | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5956e12310..201cd4d027 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-13 11:15 UTC+0100 Maurilio Longo (maurilio.longo@libero.it) + * harbour/include/hbthread.h + * harbour/source/vm/thread.c + ! fixed a bug on OS/2 MT implementation adding a new function, + _hb_cond_timed_wait() because when a semaphore gets posted it has + to be reset, otherwise it does not stop new threads entering it in a wait. + 2009-02-13 11:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbpp.h * harbour/source/pp/hbpp.c diff --git a/harbour/include/hbthread.h b/harbour/include/hbthread.h index a3528fa2c9..0ee49da84d 100644 --- a/harbour/include/hbthread.h +++ b/harbour/include/hbthread.h @@ -193,8 +193,8 @@ HB_EXTERN_BEGIN # define HB_COND_DESTROY(v) DosCloseEventSem( v ) # define HB_COND_SIGNAL(v) DosPostEventSem( v ) # define HB_COND_SIGNALN(v,n) do { int i = (n); while( --i >= 0 ) DosPostEventSem( v ); } while(0) -# define HB_COND_WAIT(v) ( DosWaitEventSem( (v), SEM_INDEFINITE_WAIT ) == NO_ERROR ) -# define HB_COND_TIMEDWAIT(v,n) ( DosWaitEventSem( (v), (n) ) == NO_ERROR ) +# define HB_COND_WAIT(v) _hb_cond_timed_wait( (v), SEM_INDEFINITE_WAIT ) +# define HB_COND_TIMEDWAIT(v,n) _hb_cond_timed_wait( (v), (n) ) # undef HB_COND_OS_SUPPORT # define HB_CRITICAL_NEED_INIT diff --git a/harbour/source/vm/thread.c b/harbour/source/vm/thread.c index 1be6d6803c..4018ae923b 100644 --- a/harbour/source/vm/thread.c +++ b/harbour/source/vm/thread.c @@ -185,6 +185,18 @@ void hb_threadExit( void ) } #if defined( HB_OS_OS2 ) +BOOL _hb_cond_timed_wait( HEV v, ULONG n ) +{ + ULONG ulPostCount = 0; + APIRET rc; + + rc = DosWaitEventSem( v, n ); + DosResetEventSem( v, &ulPostCount ); + + return rc == NO_ERROR; +} + + ULONG _hb_gettid( void ) { ULONG tid = 0;