提交 e5bc201d 编写于 作者: G Glauber Costa 提交者: Anthony Liguori

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: NGlauber Costa <glommer@mothafucka.localdomain>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 47cbc7aa
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册