From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46585 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8OOO-0004d0-Dr for qemu-devel@nongnu.org; Tue, 19 Oct 2010 22:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8OOM-00048a-U4 for qemu-devel@nongnu.org; Tue, 19 Oct 2010 22:27:04 -0400 Received: from e1.ny.us.ibm.com ([32.97.182.141]:48742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8OOM-00048V-Rf for qemu-devel@nongnu.org; Tue, 19 Oct 2010 22:27:02 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e1.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o9K2JnTS015535 for ; Tue, 19 Oct 2010 22:19:49 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9K2R2rP368304 for ; Tue, 19 Oct 2010 22:27:02 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o9K2R1Lx030558 for ; Wed, 20 Oct 2010 00:27:02 -0200 Date: Wed, 20 Oct 2010 07:56:59 +0530 From: Balbir Singh Subject: Re: [Qemu-devel] [PATCH 1/3] Introduce threadlets Message-ID: <20101020022659.GN15844@balbir.in.ibm.com> References: <20101019173946.16514.62027.stgit@localhost6.localdomain6> <20101019174245.16514.14542.stgit@localhost6.localdomain6> <20101019183644.GI15844@balbir.in.ibm.com> <4CBE06E8.5090407@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <4CBE06E8.5090407@linux.vnet.ibm.com> Reply-To: balbir@linux.vnet.ibm.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Venkateswararao Jujjuri (JV)" Cc: Arun R Bharadwaj , qemu-devel@nongnu.org * Venkateswararao Jujjuri (JV) [2010-10-19 14:00:24]: > > > > In the case that we just spawned the threadlet, the cond_signal is > > spurious. If we need predictable scheduling behaviour, > > qemu_cond_signal needs to happen with queue->lock held. > > > > I'd rewrite the function as > > > > /** > > * submit_threadletwork_to_queue: Submit a new task to a private queue to be > > * executed asynchronously. > > * @queue: Per-subsystem private queue to which the new task needs > > * to be submitted. > > * @work: Contains information about the task that needs to be submitted. > > */ > > void submit_threadletwork_to_queue(ThreadletQueue *queue, ThreadletWork *work) > > { > > qemu_mutex_lock(&(queue->lock)); > > if (queue->idle_threads == 0 && (queue->cur_threads < queue->max_threads)) { > > spawn_threadlet(queue); > > } else { > > qemu_cond_signal(&(queue->cond)); > > } > > QTAILQ_INSERT_TAIL(&(queue->request_list), work, node); > > qemu_mutex_unlock(&(queue->lock)); > > } > > > This looks fine to me. may be more cleaner than the previous one..but functionally > not much different. > It potentially does better at avoiding the spurious wakeup problem (reduces the window). In another email I mentioned the man page says "however, if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal()" -- Three Cheers, Balbir