summaryrefslogtreecommitdiffstats
path: root/vl.c
diff options
context:
space:
mode:
authorGlauber Costa2009-09-28 20:27:44 +0200
committerAnthony Liguori2009-10-05 16:32:44 +0200
commite5bc201df7e060bc4c2912258a77c53f8901356c (patch)
treed85e3178a7a5d6eebbbca9688ac08886cf8db126 /vl.c
parentbdf: Remove last users of FALSE/TRUE (diff)
downloadqemu-e5bc201df7e060bc4c2912258a77c53f8901356c.tar.gz
qemu-e5bc201df7e060bc4c2912258a77c53f8901356c.tar.xz
qemu-e5bc201df7e060bc4c2912258a77c53f8901356c.zip
do proper cpu_self check
Currently, our check for qemu_cpu_self only checks if there is a cpu currently in execution (represented by cpu_single_env being set). While this might be okay for tcg, it is certainly not okay for kvm, since multiple cpus might be executing. Instead, I propose we use pthread primitives to test if the caller thread is the same as env->thread. For tcg, it will have the same semantics as before, since all CPUStates will point to the same thread, and we'll only have one in execution at a time. Signed-off-by: Glauber Costa <glommer@mothafucka.localdomain> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/vl.c b/vl.c
index 4d9db0145c..19e11b2f70 100644
--- a/vl.c
+++ b/vl.c
@@ -3591,9 +3591,14 @@ void qemu_cpu_kick(void *_env)
qemu_thread_signal(env->thread, SIGUSR1);
}
-int qemu_cpu_self(void *env)
+int qemu_cpu_self(void *_env)
{
- return (cpu_single_env != NULL);
+ CPUState *env = _env;
+ QemuThread this;
+
+ qemu_thread_self(&this);
+
+ return qemu_thread_equal(&this, env->thread);
}
static void cpu_signal(int sig)