From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sqjyc-0006mR-JN for qemu-devel@nongnu.org; Mon, 16 Jul 2012 08:00:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqjyT-000523-CR for qemu-devel@nongnu.org; Mon, 16 Jul 2012 08:00:34 -0400 Received: from david.siemens.de ([192.35.17.14]:31655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqjyT-0004zt-17 for qemu-devel@nongnu.org; Mon, 16 Jul 2012 08:00:25 -0400 Message-ID: <50040251.5000700@siemens.com> Date: Mon, 16 Jul 2012 14:00:17 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1342435377-25897-1-git-send-email-pbonzini@redhat.com> <1342435377-25897-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1342435377-25897-8-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, aliguori@linux.vnet.ibm.com, sw@weilnetz.de, qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com On 2012-07-16 12:42, Paolo Bonzini wrote: > The new thread pool will use semaphores instead of condition > variables, because QemuCond does not have qemu_cond_timedwait. I'll post an updated patch (according to last round's review comments) that adds this service for POSIX. I bet you'll find a way to extend it to Win32 if that is required. ;) > (I also like it more this way, since semaphores model well the > producer-consumer problem). Let's not introduce another synchronization mechanism unless there is a real need. Semaphores tend to be misused for things they don't fit, so better keep them out of reach. Also, if you do producer-consumer this way, you need a down() for every entity you dequeue. In contrast, you only interact with condition variables if there the consumer queue is empty - less atomic ops. Jan -- Siemens AG, Corporate Technology, CT RTC ITP SDP-DE Corporate Competence Center Embedded Linux