Re: gthread-win32.c

> On NT, we could use SignalObjectAndWait:
> g_cond_wait(cond, mutex)
> 1. lock cond->mutex
> 2. add this thread to cond->queue
> 3. release cond->mutex
> 4. SignalObjectAndWait(mutex, this_thread->event, INFINITE,
> 5. lock mutex
> There is a race condition between 4 and 5, but looking at the SUSv2, it
> looks like a non-guaranteed area.

I don't think the re-lock needs to be atomically paired with the wakeup as
long as you permit spurious wakeups (which are certainly allowed with
pthreads, so pthreads apps already handle this case).

In fact checking the sources for glibc 2.2.2 reveals that the last statement
in pthread_cond_wait() is indeed plain old pthread_mutex_lock() =)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]