|
| From: | Paolo Bonzini |
| Subject: | [Qemu-devel] Re: [RFC] queue_work proposal |
| Date: | Thu, 03 Sep 2009 09:36:09 +0200 |
| User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 |
+ env->queued_total++;
+
+ if (env == qemu_get_current_env()) {
+ env->queued_total++;
Why increment twice? (though queued_total is write only and queued_local is unused, so...)
+ func(data);
+ return;
+ }
+
+ wii = qemu_mallocz(sizeof(*wii));
+ wii->func = func;
+ wii->data = data;
+ wii->wait = wait;
+ TAILQ_INSERT_TAIL(&env->queued_work, wii, entry);
+
+ qemu_thread_signal(env->thread, SIGUSR1);
+
+ while (wait&& !wii->done) {
+ qemu_cond_wait(env->work_cond,&qemu_global_mutex);
+ }
You need to lock qemu_global_mutex around this while statement, or to add env->queue_mutex and include the TAILQ_INSERT_TAIL in the mutex.
Paolo
| [Prev in Thread] | Current Thread | [Next in Thread] |