[vlc-devel] [PATCH 2/7] win32/inhibit: signal while holding the lock
remi at remlab.net
Tue Feb 4 11:25:41 CET 2020
Nominally, signalling should be done with the lock held. It's more logical and it ensures that access to the internal state of the CV is serialised properly.
However some early uniprocessor implementations allegedly were faster if signalling was done after unlocking: the woken thread would preempt the signalling thread and attempt to lock the mutex. Thus it would go immediately back to sleep if the lock was still held by the signalling thread, and get preempt back again.
Le 4 février 2020 11:32:58 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>Personally I don't understand why the runtime would reorder
>But it seems more logical to do the unlock after the signal. Either it
>worked by accident or supposedly because the runtime would reorder
>? More info would be welcome.
>On 2020-02-04 10:11, Thomas Guillem wrote:
>> Indeed, OK for 2 and 3.
>> On Mon, Feb 3, 2020, at 22:13, Rémi Denis-Courmont wrote:
>>> This is the 21st century. The C run-time threading subsystem knows
>>> than you how to optimise condition variables.
>>> modules/video_output/win32/inhibit.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> diff --git a/modules/video_output/win32/inhibit.c
>>> index d23dcc33e4..566b311189 100644
>>> --- a/modules/video_output/win32/inhibit.c
>>> +++ b/modules/video_output/win32/inhibit.c
>>> @@ -42,8 +42,8 @@ static void Inhibit (vlc_inhibit_t *ih, unsigned
>>> vlc_inhibit_sys_t *sys = ih->p_sys;
>>> sys->mask = mask;
>>> - vlc_mutex_unlock(&sys->mutex);
>>> + vlc_mutex_unlock(&sys->mutex);
>>> static void RestoreStateOnCancel( void* p_opaque )
>>> vlc-devel mailing list
>>> To unsubscribe or modify your subscription options:
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vlc-devel