server: implement thread priorities
commitfa9ce4e7cf2a8a1c6256ab7f105e9126f39b0873
authorJan Zerebecki <jan.wine@zerebecki.de>
Sat, 9 Aug 2008 12:52:38 +0000 (9 14:52 +0200)
committerJan Zerebecki <jan.wine@zerebecki.de>
Sat, 9 Aug 2008 12:52:38 +0000 (9 14:52 +0200)
tree3e0d6b1b6af3cef36c12102c51b57363a4b6a513
parent75be2c99d34164c261a4041ddcd52a7a01526192
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