[vlc-devel] [vlc-commits] threads: fix race in vlc_cond_wait()

Rémi Denis-Courmont remi at remlab.net
Thu Jun 9 19:10:27 CEST 2016


Le 2016-06-09 18:11, Steve Lhomme a écrit :
> On Thu, Jun 2, 2016 at 8:14 AM, Rémi Denis-Courmont 
> <git at videolan.org> wrote:
>> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed 
>> Jun  1 21:47:38 2016 +0300| [b269f60e182c9a26f046518cb52439f88b4a3c05] 
>> | committer: Rémi Denis-Courmont
>>
>> threads: fix race in vlc_cond_wait()
>>
>> Could lose wake-up if vlc_cond_wait() in one thread, then
>> vlc_cond_signal() in anotherthread, then vlc_cond_wait() in a third
>> thread.
>
> There's still some issues with 3 threads scenario.
>
> During the first wait, between the time the time you
> vlc_mutex_unlock(mutex) and vlc_wait_addr() there's time for a thread
> to vlc_cond_signal() (will increment to the next odd value) and
> another thread to vlc_cond_wait() (will increment to the next even
> value). So the first thread will be not be waiting because the value
> it will tried to match to wait has already changed. Is that the
> expected behaviour ? In this case the vlc_cond_signal() will allow 2
> condition waits to pass.

Spurious wake-ups are allowed. Signal losses are not allowed.

-- 
Rémi Denis-Courmont
http://www.remlab.net/


More information about the vlc-devel mailing list