(Mis)using threads (solution found)

Alexandre Julliard julliard at winehq.com
Thu Mar 13 12:35:09 CST 2003

"Florian Schirmer" <jolt at tuxbox.org> writes:

> I haven't looked deeper into what has caused this trouble, but i suspect
> some sleeping/waiting trouble. The new thread proc (for both the clone and
> the CreateThread thread) does nothing except registering an alsa async
> callback handler and then sleeping (using linux native nanosleep) all the
> time. The old thread handler (which works pretty well on win32) probably
> calls in some sort if message handling loop. Using the native win32 Sleep()
> call instead of linux native nanosleep will break things again. So wine is
> unable to waste time in the proper way ;-)

Yes, it's a known issue, our Sleep() wastes a bit too much CPU for
short waits. Something like this may help:

Index: scheduler/synchro.c
RCS file: /opt/cvs-commit/wine/scheduler/synchro.c,v
retrieving revision 1.45
diff -u -r1.45 synchro.c
--- scheduler/synchro.c	26 Aug 2002 21:53:26 -0000	1.45
+++ scheduler/synchro.c	13 Mar 2003 18:05:47 -0000
@@ -184,6 +184,7 @@
 VOID WINAPI Sleep( DWORD timeout )
     WaitForMultipleObjectsEx( 0, NULL, FALSE, timeout, FALSE );
+    if (timeout <= 1) sched_yield();

Alexandre Julliard
julliard at winehq.com

More information about the wine-devel mailing list