From patchwork Thu Nov 3 08:57:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhi Yong Wu X-Patchwork-Id: 123416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B33CCB6F88 for ; Thu, 3 Nov 2011 20:00:51 +1100 (EST) Received: from localhost ([::1]:58758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLtAG-0004xa-Cn for incoming@patchwork.ozlabs.org; Thu, 03 Nov 2011 05:00:48 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLtA6-0004xJ-Sm for qemu-devel@nongnu.org; Thu, 03 Nov 2011 05:00:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLtA5-0000y2-2s for qemu-devel@nongnu.org; Thu, 03 Nov 2011 05:00:38 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:60375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLtA4-0000xt-VN for qemu-devel@nongnu.org; Thu, 03 Nov 2011 05:00:37 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 3 Nov 2011 05:00:36 -0400 Received: from d01relay06.pok.ibm.com ([9.56.227.116]) by e8.ny.us.ibm.com ([192.168.1.108]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 3 Nov 2011 05:00:33 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pA390Wt92551946 for ; Thu, 3 Nov 2011 05:00:32 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pA390UcR011882 for ; Thu, 3 Nov 2011 05:00:32 -0400 Received: from us.ibm.com ([9.115.118.38]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id pA390Qii007146; Thu, 3 Nov 2011 05:00:27 -0400 Received: by us.ibm.com (sSMTP sendmail emulation); Thu, 3 Nov 2011 16:59:27 +0800 From: Zhi Yong Wu To: kwolf@redhat.com Date: Thu, 3 Nov 2011 16:57:26 +0800 Message-Id: <1320310649-7639-3-git-send-email-wuzhy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1320310649-7639-1-git-send-email-wuzhy@linux.vnet.ibm.com> References: <1320310649-7639-1-git-send-email-wuzhy@linux.vnet.ibm.com> x-cbid: 11110309-9360-0000-0000-000000484FA2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.138 Cc: zwu.kernel@gmail.com, ryanh@us.ibm.com, Zhi Yong Wu , qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v12 2/5] CoQueue: introduce qemu_co_queue_wait_insert_head X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi --- qemu-coroutine-lock.c | 8 ++++++++ qemu-coroutine.h | 6 ++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index 6b58160..9549c07 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -61,6 +61,14 @@ void coroutine_fn qemu_co_queue_wait(CoQueue *queue) assert(qemu_in_coroutine()); } +void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue) +{ + Coroutine *self = qemu_coroutine_self(); + QTAILQ_INSERT_HEAD(&queue->entries, self, co_queue_next); + qemu_coroutine_yield(); + assert(qemu_in_coroutine()); +} + bool qemu_co_queue_next(CoQueue *queue) { Coroutine *next; diff --git a/qemu-coroutine.h b/qemu-coroutine.h index b8fc4f4..8a2e5d2 100644 --- a/qemu-coroutine.h +++ b/qemu-coroutine.h @@ -118,6 +118,12 @@ void qemu_co_queue_init(CoQueue *queue); void coroutine_fn qemu_co_queue_wait(CoQueue *queue); /** + * Adds the current coroutine to the head of the CoQueue and transfers control to the + * caller of the coroutine. + */ +void coroutine_fn qemu_co_queue_wait_insert_head(CoQueue *queue); + +/** * Restarts the next coroutine in the CoQueue and removes it from the queue. * * Returns true if a coroutine was restarted, false if the queue is empty.