Alexandre Julliard : server: Retrieve the Unix thread affinity for the initial thread.
Alexandre Julliard
julliard at winehq.org
Fri Apr 15 10:19:24 CDT 2011
Module: wine
Branch: master
Commit: 500d77245c578acf89328cce36a4d5284d75b524
URL: http://source.winehq.org/git/wine.git/?a=commit;h=500d77245c578acf89328cce36a4d5284d75b524
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 14 20:18:02 2011 +0200
server: Retrieve the Unix thread affinity for the initial thread.
---
server/thread.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/server/thread.c b/server/thread.c
index 05e4121..983ba2d 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -190,7 +190,6 @@ static inline void init_thread_structure( struct thread *thread )
thread->state = RUNNING;
thread->exit_code = 0;
thread->priority = 0;
- thread->affinity = ~0;
thread->suspend = 0;
thread->desktop_users = 0;
thread->token = NULL;
@@ -432,6 +431,24 @@ int set_thread_affinity( struct thread *thread, affinity_t affinity )
return ret;
}
+affinity_t get_thread_affinity( struct thread *thread )
+{
+ affinity_t mask = 0;
+#ifdef HAVE_SCHED_SETAFFINITY
+ if (thread->unix_tid != -1)
+ {
+ cpu_set_t set;
+ unsigned int i;
+
+ if (!sched_getaffinity( thread->unix_tid, sizeof(set), &set ))
+ for (i = 0; i < 8 * sizeof(mask); i++)
+ if (CPU_ISSET( i, &set )) mask |= 1 << i;
+ }
+#endif
+ if (!mask) mask = ~0;
+ return mask;
+}
+
#define THREAD_PRIORITY_REALTIME_HIGHEST 6
#define THREAD_PRIORITY_REALTIME_LOWEST -7
@@ -1157,6 +1174,10 @@ DECL_HANDLER(init_thread)
process->peb = req->entry;
process->cpu = req->cpu;
reply->info_size = init_process( current );
+ if (!process->parent)
+ process->affinity = current->affinity = get_thread_affinity( current );
+ else
+ set_thread_affinity( current, current->affinity );
}
else
{
@@ -1169,9 +1190,9 @@ DECL_HANDLER(init_thread)
process->unix_pid = -1; /* can happen with linuxthreads */
if (current->suspend + process->suspend > 0) stop_thread( current );
generate_debug_event( current, CREATE_THREAD_DEBUG_EVENT, &req->entry );
+ set_thread_affinity( current, current->affinity );
}
debug_level = max( debug_level, req->debug_level );
- set_thread_affinity( current, current->affinity );
reply->pid = get_process_id( process );
reply->tid = get_thread_id( current );
More information about the wine-cvs
mailing list