From: Marc-Aurel Zent mzent@codeweavers.com
--- server/mach.c | 2 +- server/process.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- server/process.h | 4 ++-- 3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/server/mach.c b/server/mach.c index 50d21e2810a..19737fceef8 100644 --- a/server/mach.c +++ b/server/mach.c @@ -157,7 +157,7 @@ void init_process_tracing( struct process *process ) } /* On Mach thread priorities depend on having the process port available, so * reapply all thread priorities here after process tracing is initialized */ - set_process_priority( process, process->priority ); + set_process_base_priority( process, process->base_priority ); }
/* terminate the per-process tracing mechanism */ diff --git a/server/process.c b/server/process.c index b161e3394ba..4f6e429551a 100644 --- a/server/process.c +++ b/server/process.c @@ -55,6 +55,7 @@ #include "ntstatus.h" #define WIN32_NO_STATUS #include "winternl.h" +#include "ddk/wdm.h"
#include "file.h" #include "handle.h" @@ -662,6 +663,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla process->exit_code = STILL_ACTIVE; process->running_threads = 0; process->priority = PROCESS_PRIOCLASS_NORMAL; + process->base_priority = 8; process->suspend = 0; process->is_system = 0; process->debug_children = 1; @@ -1512,7 +1514,7 @@ DECL_HANDLER(get_process_info) reply->ppid = process->parent_id; reply->exit_code = process->exit_code; reply->priority = process->priority; - reply->base_priority = priority_from_class_and_level( process->priority, THREAD_PRIORITY_NORMAL ); + reply->base_priority = process->base_priority; reply->affinity = process->affinity; reply->peb = process->peb; reply->start_time = process->start_time; @@ -1634,11 +1636,17 @@ DECL_HANDLER(get_process_vm_counters) release_object( process ); }
-void set_process_priority( struct process *process, int priority ) +void set_process_base_priority( struct process *process, int base_priority ) { struct thread *thread;
- process->priority = priority; + if (base_priority < LOW_PRIORITY + 1 || base_priority > HIGH_PRIORITY) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } + + process->base_priority = base_priority;
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) { @@ -1646,6 +1654,39 @@ void set_process_priority( struct process *process, int priority ) } }
+static void set_process_priority( struct process *process, int priority ) +{ + int base_priority; + + process->priority = priority; + + switch (priority) + { + case PROCESS_PRIOCLASS_IDLE: + base_priority = 4; + break; + case PROCESS_PRIOCLASS_BELOW_NORMAL: + base_priority = 6; + break; + case PROCESS_PRIOCLASS_NORMAL: + base_priority = 8; + break; + case PROCESS_PRIOCLASS_ABOVE_NORMAL: + base_priority = 10; + break; + case PROCESS_PRIOCLASS_HIGH: + base_priority = 13; + break; + case PROCESS_PRIOCLASS_REALTIME: + base_priority = 24; + break; + default: + base_priority = 8; + } + + set_process_base_priority( process, base_priority ); +} + static void set_process_affinity( struct process *process, affinity_t affinity ) { struct thread *thread; diff --git a/server/process.h b/server/process.h index e49529b06fa..1648e46fe98 100644 --- a/server/process.h +++ b/server/process.h @@ -56,6 +56,7 @@ struct process timeout_t end_time; /* absolute time at process end */ affinity_t affinity; /* process affinity mask */ int priority; /* priority class */ + int base_priority; /* base priority to calculate thread priority */ int suspend; /* global process suspend count */ unsigned int is_system:1; /* is it a system process? */ unsigned int debug_children:1;/* also debug all child processes */ @@ -116,8 +117,7 @@ extern void kill_process( struct process *process, int violent_death ); extern void kill_console_processes( struct thread *renderer, int exit_code ); extern void detach_debugged_processes( struct debug_obj *debug_obj, int exit_code ); extern void enum_processes( int (*cb)(struct process*, void*), void *user); -extern int priority_from_class_and_level( int priority_class, int priority_level ); -extern void set_process_priority( struct process *process, int priority ); +extern void set_process_base_priority( struct process *process, int base_priority );
/* console functions */ extern struct thread *console_get_renderer( struct console *console );