Re: [Patch] Fix error path of pthread_cond_timedwait
Dinakar Guniguntala <[email protected]> Tue, 17 Feb 2004 13:55:51 +0530
| Newsgroups | gmane.comp.lib.phil |
|---|---|
| Message-ID | <OF6C34C2F4.A18E886A-ON65256E3D.002CDF82-65256E3D.002E090C@in.ibm.com> |
Ulrich,
I had come up with the same fix that you have now in CVS but I found
that it can lead to the following sequence of events
---------------------------------------------------------------------------------------------
Thread A Thread B
take condvar lock
inc total_seq
release condvar lock
take condvar lock
enable_async if (total_seq >
wakeup_seq)
gettimeofday inc wakeup_seq
TIMEOUT futex_wake
release condvar lock
take condvar lock
inc wakeup_seq
inc woken_seq
release condvar lock
return
-------------------------------------------------------------------------------------------
As you can see this leads to the counters getting corrupted and again leads
to
the next pthread_cond_signal getting lost
The patch that I sent takes care of this scenario as well
Please apply
Regards,
Dinakar
Ulrich Drepper
<[email protected] To: Dinakar Guniguntala/India/IBM@IBMIN
om> cc: [email protected]
Subject: Re: [Patch] Fix error path of pthread_cond_timedwait
02/17/2004 11:55
AM
Dinakar Guniguntala wrote:
> After debugging I found that on i386, there is an error path
> for the pthread_cond_timedwait call (on TIMEOUT) that updates the
sequence
> counters without holding a lock.
I've added last Friday a more efficient fix for this problem. You can
test the current CVS sources. I have added the one little optimization,
though. Thanks,
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖