mmdevapi: Avoid lock contention after SetEvent.

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Mon Dec 17 09:43:52 CST 2012


Hi,

SetEvent is one of those calls with a high probability that the
Linux scheduler will switch to another thread, e.g. the one receiving
the event.  As the critical section is still hold, it'll prevent the
receiver from invoking mmdevapi, e.g. GetCurrentPadding, without two
more thread switches (forth and back).  We don't need that.

We could have arguments about threading and memory models and whether
SetEvent(This->event) could be taken outside of the critical section
even without my previous "make This->event constant because
SetEventHandle is allowed only once", based on arguments about atomic
updates, but we can avoid the issue by actually making This->event a
constant, by my previous patch.

For correctness, note that this work depends on my former fix to
kernel/ntdll that prevents invocation of timer callbacks past
DeleteTimerQueue.

With that and my lock-less winealsa driver (cf. bug #29531) in place,
the mmdevapi render tests run without any lock contention.

Regards,
	Jörg Höhle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-mmdevapi-Avoid-lock-contention-after-SetEvent.patch
Type: application/octet-stream
Size: 1620 bytes
Desc: 0003-mmdevapi-Avoid-lock-contention-after-SetEvent.patch
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20121217/4e6b8d8b/attachment.obj>


More information about the wine-patches mailing list