On Tue, 17 Feb 2009, Alex Strickland wrote:
> Does
> ftp://ftp.netlabs.org/pub/pthreads/
> from
> http://www.netlabs.org
> help?

Have you look at implementation?
pthread_cond_wait() =>
         WaitEventSem((*cond)->c_event,SEM_INDEFINITE_WAIT);
pthread_cond_signal =>
         DosPostEventSem((*cond)->c_event);
pthread_cond_broadcast =>
         while (i--) rc = DosPostEventSem((*cond)->c_event);

and DosRestEventSem() is never executed.
It's exactly what I implemented for Harbour. Looks that I'm not
alone in interpretation of OS2 documentation. Just simply it's
hard to believe that official API cannot be used without race
conditions. This code is wrong because it does not freeze the
thread on even semaphore. It works just like Harbour was working
in OS2 builds but waiting on signal variable is in active loop
which consume CPU and fixing it by simple introducing DosRestEventSem()
without additional synchronization mechanism creates anomalies which may
cause dead lock due to potentially lost signal or starvation effect.
Looks that we have no choice and we will have to implement safe
condition variables ourselves. But I cannot say now how expensive
it will be in user space. AFAIR OS2 has function to suspend/resume
threads and probably I will have to use them.

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to