Determining best CVS host... Using CVSROOT :pserver:cvs@rhlx01.fht-esslingen.de:/home/wine Index: server/thread.c =================================================================== RCS file: /home/wine/wine/server/thread.c,v retrieving revision 1.112 diff -u -r1.112 thread.c --- server/thread.c 24 Apr 2005 17:35:52 -0000 1.112 +++ server/thread.c 15 May 2005 21:29:30 -0000 @@ -35,6 +35,7 @@ #ifdef HAVE_POLL_H #include #endif +#include #include "windef.h" #include "winbase.h" @@ -299,12 +300,66 @@ return NULL; } +static inline void set_thread_priority(struct thread *thread, int priority) +{ + struct sched_param parm; + int unix_priority = 0; + int unix_policy = SCHED_OTHER; + + /* register the windows data... */ + thread->priority = priority; + + /* ...then try to do something useful on the Unix side */ + switch (priority) { + case THREAD_PRIORITY_IDLE: +#ifdef SCHED_BATCH + fprintf(stderr, "setting SCHED_BATCH idle scheduling\n"); + unix_policy = SCHED_BATCH; +#else + fprintf(stderr, "SCHED_BATCH Linux scheduling policy not available - you probably aren't running a Con Kolivas kernel...\n"); +#endif + break; + case THREAD_PRIORITY_TIME_CRITICAL: +#ifdef SCHED_ISO + fprintf(stderr, "setting SCHED_ISO real-time scheduling\n"); + unix_policy = SCHED_ISO; +#else + fprintf(stderr, "SCHED_ISO Linux scheduling policy not available - you probably aren't running a Con Kolivas kernel...\n"); +#endif + break; + default: +#if 0 + if ((priority >= THREAD_PRIORITY_LOWEST) + && (priority <= THREAD_PRIORITY_HIGHEST)) + { + fprintf(stderr, "not sure how to map standard priorities yet, using a best-effort implementation\n"); + /* we can only renice to positive numbers, so... */ + if ((priority >= THREAD_PRIORITY_LOWEST) + && (priority <= 0)) + unix_priority = -priority * 4; /* multiplication might be useful */ + } + else + fprintf(stderr, "strange priority %d, ignoring!\n"); +#else + /* hmm, not sure what to do here, according to + * man sched_setscheduler, the nice level must be set + * via setpriority */ +#endif + break; + } + + parm.sched_priority = unix_priority; + /* FIXME: need to use unix_pid here instead?? */ + if (sched_setscheduler(thread->unix_tid, unix_policy, &parm)) + fprintf(stderr, "sched_setscheduler() failed, errno %d\n", errno); +} + /* set all information about a thread */ static void set_thread_info( struct thread *thread, const struct set_thread_info_request *req ) { if (req->mask & SET_THREAD_INFO_PRIORITY) - thread->priority = req->priority; + set_thread_priority(thread, req->priority); if (req->mask & SET_THREAD_INFO_AFFINITY) { if (req->affinity != 1) set_error( STATUS_INVALID_PARAMETER );