[vlc-devel] [PATCH 5/7] win32/window: simplify using semaphore
Alexandre Janniaux
ajanni at videolabs.io
Tue Feb 4 09:45:44 CET 2020
Hi,
On Tue, Feb 04, 2020 at 09:22:58AM +0100, Steve Lhomme wrote:
> Is this cancelable as it used to be ? If not we may end up in a state in
> which we can never leave the Open code.
If you depend on this in the code, it might be a good idea
to check whether it's possible to enforce the note:
```
/**
* Waits on a semaphore.
*
* This function atomically waits for the semaphore to become non-zero then
* decrements it, and returns. If the semaphore is non-zero on entry, it is
* immediately decremented.
*
* \note This function may be a point of cancellation.
*/
VLC_API void vlc_sem_wait(vlc_sem_t *);
```
But it seems that cancellation is never used here, isn't it?
> Isn't a semaphore heavier to handle than a condition variable ?
Semaphore is more suitable for signalling (producer,
consumer basically), especially when this is only a
single token consumption once, and mutex are simpler
when it comes to synchronization and using the same
resource. In both case, cost is probably low as they
could both use futex.
See article from RĂ©mi [1] and man 7 futex for more
details on that matter.
[1] https://www.remlab.net/op/futex-misc.shtml
Regards,
--
Alexandre Janniaux
Videolabs
More information about the vlc-devel
mailing list