From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mj6zn-0001bq-Le for qemu-devel@nongnu.org; Thu, 03 Sep 2009 03:44:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mj6zi-0001a7-RG for qemu-devel@nongnu.org; Thu, 03 Sep 2009 03:44:39 -0400 Received: from [199.232.76.173] (port=52723 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mj6zi-0001a4-MA for qemu-devel@nongnu.org; Thu, 03 Sep 2009 03:44:34 -0400 Received: from mx20.gnu.org ([199.232.41.8]:15974) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mj6zh-0006g3-Di for qemu-devel@nongnu.org; Thu, 03 Sep 2009 03:44:34 -0400 Received: from mail-bw0-f227.google.com ([209.85.218.227]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mj6zf-0007fQ-JI for qemu-devel@nongnu.org; Thu, 03 Sep 2009 03:44:31 -0400 Received: by bwz27 with SMTP id 27so1447002bwz.34 for ; Thu, 03 Sep 2009 00:44:29 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4A9F71E9.3090900@gnu.org> Date: Thu, 03 Sep 2009 09:36:09 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1251939158-17153-1-git-send-email-glommer@redhat.com> In-Reply-To: <1251939158-17153-1-git-send-email-glommer@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [RFC] queue_work proposal List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org > + 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