<html><head></head><body>Hi,<br><br>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.<br><br>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.<br><br><div class="gmail_quote">Le 4 février 2020 11:32:58 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Personally I don't understand why the runtime would reorder <br>multithreading calls.<br><br>But it seems more logical to do the unlock after the signal. Either it <br>worked by accident or supposedly because the runtime would reorder calls <br>? More info would be welcome.<br><br>On 2020-02-04 10:11, Thomas Guillem wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Indeed, OK for 2 and 3.<br><br>On Mon, Feb 3, 2020, at 22:13, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> This is the 21st century. The C run-time threading subsystem knows better<br> than you how to optimise condition variables.<hr>   modules/video_output/win32/inhibit.c | 2 +-<br>   1 file changed, 1 insertion(+), 1 deletion(-)<br><br> diff --git a/modules/video_output/win32/inhibit.c<br> b/modules/video_output/win32/inhibit.c<br> index d23dcc33e4..566b311189 100644<br> --- a/modules/video_output/win32/inhibit.c<br> +++ b/modules/video_output/win32/inhibit.c<br> @@ -42,8 +42,8 @@ static void Inhibit (vlc_inhibit_t *ih, unsigned mask)<br>       vlc_inhibit_sys_t *sys = ih->p_sys;<br>       vlc_mutex_lock(&sys->mutex);<br>       sys->mask = mask;<br> -    vlc_mutex_unlock(&sys->mutex);<br>       vlc_cond_signal(&sys->cond);<br> +    vlc_mutex_unlock(&sys->mutex);<br>   }<br>   <br>   static void RestoreStateOnCancel( void* p_opaque )<br> -- <br> 2.25.0<hr> vlc-devel mailing list<br> To unsubscribe or modify your subscription options:<br> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>