server: implement thread prioritiesmaster/threadpriority
commit66a2297527c8cdca01d201ebfe9c7257f23f3265
authorJan Zerebecki <jan.wine@zerebecki.de>
Sat, 25 Oct 2008 11:58:38 +0000 (25 13:58 +0200)
committerJan Zerebecki <jan.wine@zerebecki.de>
Sat, 25 Oct 2008 11:58:38 +0000 (25 13:58 +0200)
treec1d02efd0a234412f5c69f812ea7c1d07e343b36
parent1bbd4a483c172972aa226cba7a35c65d26962b23
server: implement thread priorities

Based on a patch from
http://wiki.winehq.org/Implement_SetThreadPriority by Mike Hearn.
The capability dropping from that patch is not contained in this
one. You should not run wine (any part of it) as root or setuid
root!

Using this patch and having a rtprio rlimit higher than 0 gives
wine-threads that use SetThreadPriority with
THREAD_PRIORITY_TIME_CRITICAL the ability to starve out all other
tasks on your system effectively dead-locking it (this is the
same on native MS Windows).

To get a rtprio rlimit of at least 1 (the rtprio used by this
patch) you should either configure pam to give it to you on login
(never did that myself, so don't ask me how) or use set_rlimit.
set_rlimit from http://www.physics.adelaide.edu.au/~jwoithe/ is a
setuid root binary that can increase certain rlimits for
configurable users. After having it configured in
/etc/set_rlimits.conf , you can then call wine like "set_rlimit
wine ...". There are other ways to get this rlimit as user, but
these are probably the least problematic ones.

To counter the problem of rtprio threads starving out the system
one can use das_watchdog from http://www.notam02.no/arkiv/src/ .
The un-rt sysreq key-combo ( alt+print-screen+n ) has a
similar effect.

TODO: Under certain conditions (like an application locking on
trying to use dsound capture with winealsa) it can really lock up
the system (i.e. not only cpu starving it) so only sysreq-b for
hard reboot works. I guess this is a kernel bug. The problem
might be related to blocking on IO in the rt task.

TODO: It may be useful to also mimic other thread priorities
(e.g. idle has a corresponding scheduler on linux).
server/thread.c