[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 21/21] add Win32 IPI service
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] Re: [PATCH 21/21] add Win32 IPI service |
Date: |
Mon, 21 Feb 2011 13:00:36 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
On 2011-02-21 09:43, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> cpus.c | 23 ++++++++++++++++++++---
> qemu-thread-posix.c | 9 ---------
> qemu-thread-posix.h | 1 -
> 3 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index fd791a3..869ed1a 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -854,13 +854,30 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
> return NULL;
> }
>
> +static void qemu_thread_kick(QemuThread *thread)
> +{
> +#ifndef _WIN32
> + int err;
> +
> + err = pthread_kill(thread->thread, SIG_IPI);
> + if (err) {
> + fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
> + exit(1);
> + }
> +#else /* _WIN32 */
> + SuspendThread(thread->thread);
> + cpu_signal(0);
> + ResumeThread(thread->thread);
> +#endif
> +}
> +
qemu_thread_* services do not truly belong here.
What about defining SIG_IPI as QEMU_SIG_KICK which would be provided by
qemu-thread-posix.h? Then the qemu-thread-posix.c could implement
qemu_thread_kick() again.
> void qemu_cpu_kick(void *_env)
> {
> CPUState *env = _env;
>
> qemu_cond_broadcast(env->halt_cond);
> if (!env->thread_kicked) {
> - qemu_thread_signal(env->thread, SIG_IPI);
> + qemu_thread_kick(env->thread);
> env->thread_kicked = true;
> }
> }
> @@ -871,7 +888,7 @@ void qemu_cpu_kick_self(void)
> assert(cpu_single_env);
>
> if (!cpu_single_env->thread_kicked) {
> - qemu_thread_signal(cpu_single_env->thread, SIG_IPI);
> + qemu_thread_kick(cpu_single_env->thread);
> cpu_single_env->thread_kicked = true;
> }
> #else
> @@ -893,7 +910,7 @@ void qemu_mutex_lock_iothread(void)
> } else {
> qemu_mutex_lock(&qemu_fair_mutex);
> if (qemu_mutex_trylock(&qemu_global_mutex)) {
> - qemu_thread_signal(tcg_cpu_thread, SIG_IPI);
> + qemu_thread_kick(tcg_cpu_thread);
> qemu_mutex_lock(&qemu_global_mutex);
> }
> qemu_mutex_unlock(&qemu_fair_mutex);
> diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c
> index 2176f81..5fdf16b 100644
> --- a/qemu-thread-posix.c
> +++ b/qemu-thread-posix.c
> @@ -190,15 +190,6 @@ void qemu_thread_create(QemuThread *thread,
> pthread_sigmask(SIG_SETMASK, &oldset, NULL);
> }
>
> -void qemu_thread_signal(QemuThread *thread, int sig)
> -{
> - int err;
> -
> - err = pthread_kill(thread->thread, sig);
> - if (err)
> - error_exit(err, __func__);
> -}
> -
> void qemu_thread_self(QemuThread *thread)
> {
> thread->thread = pthread_self();
> diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h
> index 11978db..35e0a8b 100644
> --- a/qemu-thread-posix.h
> +++ b/qemu-thread-posix.h
> @@ -15,5 +15,4 @@ struct QemuThread {
> pthread_t thread;
> };
>
> -void qemu_thread_signal(QemuThread *thread, int sig);
> #endif
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH uq/master 00/21] Win32 iothread support, Anthony Liguori, 2011/02/22