On Fri, 13 Feb 2009, Maurilio Longo wrote: Hi Maurilio,
> do you think my change can conflict in any way with current MT implementation > on OS/2? I don't think, but I'd like to hear from you on this issue. > > * 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. Looks that I haven't read OS2 API documentation carefully. Thanks for fix. Though I have few questions because looks that current code have to be updated. Your modification suggests that DosPostEventSem() sends broadcast message and wake up _ALL_ threads which where blocked by event semaphore by DosWaitEventSem() and not only one. DosWaitEventSem() blocks calling thread on event semaphore only if this semaphore was not posted after last call to DosResetEventSem() so it's necessary to call DosResetEventSem() to clear all posted events and make event semaphore blocking. I guess that DosResetEventSem() is atomic operation and when two or more threads call this function simultaneously then only one will receive non 0 value if semaphore was posted. If I'm right then I see few potential problems. 1-st we do not need separate macros for HB_COND_SIGNAL() and HB_COND_SIGNALN() in OS2 builds because all works like HB_COND_BROADCAST() and wake up all waiting threads. 2-nd we should change all places where HB_COND_TIMEDWAIT() is used and check timeout parameter ourselves just like in hb_threadWait() function. In summary I should implement it at beginning because it pacifies also other potential though minor problem on MS-Win builds. But there is also other problem much more critical. DosResetEventSem() is not atomic to DosWaitEventSem() and we have nothing to sync well number of posted signals with number of waiting threads to be sure that all threads will be woken up. To resolve this problem we have to move DosResetEventSem() changing the code in OS2 builds. But before I'll make deeper modifications I would like to confirm that I correctly described how DosWaitEventSem(), DosPostEventSem() and DosResetEventSem() work. I do not have precise OS2 documentation and I have to guess some things. best regards, Przemek _______________________________________________ Harbour mailing list [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
