From: Marc-Aurel Zent mzent@codeweavers.com
--- dlls/ntdll/unix/thread.c | 6 +++--- server/process.c | 6 +++--- server/protocol.def | 14 +++++++------- server/thread.c | 34 +++++++++++++++++----------------- server/thread.h | 4 ++-- 5 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index b64a7dd40af..8a4a53d93a1 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -2371,9 +2371,9 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, if (length != sizeof(DWORD)) return STATUS_INVALID_PARAMETER; SERVER_START_REQ( set_thread_info ) { - req->handle = wine_server_obj_handle( handle ); - req->priority = *pprio; - req->mask = SET_THREAD_INFO_PRIORITY; + req->handle = wine_server_obj_handle( handle ); + req->base_priority = *pprio; + req->mask = SET_THREAD_INFO_BASE_PRIORITY; status = wine_server_call( req ); } SERVER_END_REQ; diff --git a/server/process.c b/server/process.c index d970e01a4cf..b8896a224ff 100644 --- a/server/process.c +++ b/server/process.c @@ -1641,7 +1641,7 @@ void set_process_priority( struct process *process, int priority )
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry ) { - set_thread_priority( thread, thread->priority ); + set_thread_base_priority( thread, thread->base_priority ); } }
@@ -2013,8 +2013,8 @@ DECL_HANDLER(list_processes)
thread_info->start_time = thread->creation_time; thread_info->tid = thread->id; - thread_info->base_priority = thread->priority; - thread_info->current_priority = thread->priority; /* FIXME */ + thread_info->base_priority = thread->base_priority; + thread_info->current_priority = thread->base_priority; /* FIXME */ thread_info->unix_tid = thread->unix_tid; thread_info->entry_point = thread->entry_point; thread_info->teb = thread->teb; diff --git a/server/protocol.def b/server/protocol.def index 4f712b4e4e6..39e74724cb6 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1245,18 +1245,18 @@ struct obj_locator @REQ(set_thread_info) obj_handle_t handle; /* thread handle */ int mask; /* setting mask (see below) */ - int priority; /* priority class */ + int base_priority;/* base priority class */ affinity_t affinity; /* affinity mask */ client_ptr_t entry_point; /* thread entry point */ obj_handle_t token; /* impersonation token */ VARARG(desc,unicode_str); /* description string */ @END -#define SET_THREAD_INFO_PRIORITY 0x01 -#define SET_THREAD_INFO_AFFINITY 0x02 -#define SET_THREAD_INFO_TOKEN 0x04 -#define SET_THREAD_INFO_ENTRYPOINT 0x08 -#define SET_THREAD_INFO_DESCRIPTION 0x10 -#define SET_THREAD_INFO_DBG_HIDDEN 0x20 +#define SET_THREAD_INFO_BASE_PRIORITY 0x01 +#define SET_THREAD_INFO_AFFINITY 0x02 +#define SET_THREAD_INFO_TOKEN 0x04 +#define SET_THREAD_INFO_ENTRYPOINT 0x08 +#define SET_THREAD_INFO_DESCRIPTION 0x10 +#define SET_THREAD_INFO_DBG_HIDDEN 0x20
/* Suspend a thread */ diff --git a/server/thread.c b/server/thread.c index c3bbd98640b..d7a2e35a19d 100644 --- a/server/thread.c +++ b/server/thread.c @@ -298,7 +298,7 @@ static void apply_thread_priority( struct thread *thread, int effective_priority thread_extended_policy.timeshare = effective_priority > 14 ? 0 : 1; thread_precedence_policy.importance = get_mach_importance( effective_priority ); /* adapted from the QoS table at xnu/osfmk/kern/thread_policy.c */ - switch (thread->priority) + switch (thread->base_priority) { case THREAD_PRIORITY_IDLE: /* THREAD_QOS_MAINTENANCE */ case THREAD_PRIORITY_LOWEST: /* THREAD_QOS_BACKGROUND */ @@ -404,7 +404,7 @@ static inline void init_thread_structure( struct thread *thread ) thread->wait_fd = NULL; thread->state = RUNNING; thread->exit_code = 0; - thread->priority = 0; + thread->base_priority = 0; thread->suspend = 0; thread->dbg_hidden = 0; thread->desktop_users = 0; @@ -770,24 +770,24 @@ affinity_t get_thread_affinity( struct thread *thread ) return mask; }
-static int thread_priority_from_class_and_level( int priority_class, int priority ) +static int thread_priority_from_class_and_level( int priority_class, int base_priority ) { /* offsets taken from https://learn.microsoft.com/en-us/windows/win32/procthread/scheduling-priori... */ static const int class_offsets[] = { 4, 8, 13, 24, 6, 10 };
- if (priority == THREAD_PRIORITY_IDLE) + if (base_priority == THREAD_PRIORITY_IDLE) return (priority_class == PROCESS_PRIORITY_CLASS_REALTIME ? LOW_REALTIME_PRIORITY : LOW_PRIORITY + 1); - if (priority == THREAD_PRIORITY_TIME_CRITICAL) + if (base_priority == THREAD_PRIORITY_TIME_CRITICAL) return (priority_class == PROCESS_PRIORITY_CLASS_REALTIME ? HIGH_PRIORITY : LOW_REALTIME_PRIORITY - 1); if (priority_class >= ARRAY_SIZE(class_offsets)) return LOW_REALTIME_PRIORITY / 2; - return class_offsets[priority_class - 1] + priority; + return class_offsets[priority_class - 1] + base_priority; }
#define THREAD_PRIORITY_REALTIME_HIGHEST 6 #define THREAD_PRIORITY_REALTIME_LOWEST -7
-unsigned int set_thread_priority( struct thread *thread, int priority ) +unsigned int set_thread_base_priority( struct thread *thread, int base_priority ) { int priority_class = thread->process->priority; int max = THREAD_PRIORITY_HIGHEST; @@ -798,16 +798,16 @@ unsigned int set_thread_priority( struct thread *thread, int priority ) max = THREAD_PRIORITY_REALTIME_HIGHEST; min = THREAD_PRIORITY_REALTIME_LOWEST; } - if ((priority < min || priority > max) && - priority != THREAD_PRIORITY_IDLE && - priority != THREAD_PRIORITY_TIME_CRITICAL) + if ((base_priority < min || base_priority > max) && + base_priority != THREAD_PRIORITY_IDLE && + base_priority != THREAD_PRIORITY_TIME_CRITICAL) return STATUS_INVALID_PARAMETER;
- thread->priority = priority; + thread->base_priority = base_priority;
/* if thread is gone or hasn't started yet, this will be called again from init_thread with a unix_tid */ if (thread->state == RUNNING && thread->unix_tid != -1) - apply_thread_priority( thread, thread_priority_from_class_and_level( priority_class, priority )); + apply_thread_priority( thread, thread_priority_from_class_and_level( priority_class, base_priority ));
return STATUS_SUCCESS; } @@ -816,9 +816,9 @@ unsigned int set_thread_priority( struct thread *thread, int priority ) static void set_thread_info( struct thread *thread, const struct set_thread_info_request *req ) { - if (req->mask & SET_THREAD_INFO_PRIORITY) + if (req->mask & SET_THREAD_INFO_BASE_PRIORITY) { - unsigned int status = set_thread_priority( thread, req->priority ); + unsigned int status = set_thread_base_priority( thread, req->base_priority ); if (status) set_error( status ); } if (req->mask & SET_THREAD_INFO_AFFINITY) @@ -1615,7 +1615,7 @@ DECL_HANDLER(init_first_thread) else set_thread_affinity( current, current->affinity );
- set_thread_priority( current, current->priority ); + set_thread_base_priority( current, current->base_priority );
debug_level = max( debug_level, req->debug_level );
@@ -1646,7 +1646,7 @@ DECL_HANDLER(init_thread)
init_thread_context( current ); generate_debug_event( current, DbgCreateThreadStateChange, &req->entry ); - set_thread_priority( current, current->priority ); + set_thread_base_priority( current, current->base_priority ); set_thread_affinity( current, current->affinity );
reply->suspend = (current->suspend || current->process->suspend || current->context != NULL); @@ -1695,7 +1695,7 @@ DECL_HANDLER(get_thread_info) reply->teb = thread->teb; reply->entry_point = thread->entry_point; reply->exit_code = (thread->state == TERMINATED) ? thread->exit_code : STATUS_PENDING; - reply->priority = thread->priority; + reply->priority = thread->base_priority; reply->affinity = thread->affinity; reply->last = thread->process->running_threads == 1; reply->suspend_count = thread->suspend; diff --git a/server/thread.h b/server/thread.h index 7549243e88b..419f5987ad4 100644 --- a/server/thread.h +++ b/server/thread.h @@ -81,7 +81,7 @@ struct thread client_ptr_t teb; /* TEB address (in client address space) */ client_ptr_t entry_point; /* entry point (in client address space) */ affinity_t affinity; /* affinity mask */ - int priority; /* priority level */ + int base_priority; /* priority level */ int suspend; /* suspend count */ int dbg_hidden; /* hidden from debugger */ obj_handle_t desktop; /* desktop handle */ @@ -122,7 +122,7 @@ extern void thread_cancel_apc( struct thread *thread, struct object *owner, enum extern int thread_add_inflight_fd( struct thread *thread, int client, int server ); extern int thread_get_inflight_fd( struct thread *thread, int client ); extern struct token *thread_get_impersonation_token( struct thread *thread ); -extern unsigned int set_thread_priority( struct thread *thread, int priority ); +extern unsigned int set_thread_base_priority( struct thread *thread, int base_priority ); extern int set_thread_affinity( struct thread *thread, affinity_t affinity ); extern int suspend_thread( struct thread *thread ); extern int resume_thread( struct thread *thread );