From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YL8n3-0004hf-D3 for qemu-devel@nongnu.org; Tue, 10 Feb 2015 06:15:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YL8mz-0005b6-71 for qemu-devel@nongnu.org; Tue, 10 Feb 2015 06:15:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YL8my-0005b0-Uo for qemu-devel@nongnu.org; Tue, 10 Feb 2015 06:15:33 -0500 Message-ID: <54D9E84A.9030204@redhat.com> Date: Tue, 10 Feb 2015 12:15:22 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1423564888-14933-1-git-send-email-kwolf@redhat.com> <1423564888-14933-3-git-send-email-kwolf@redhat.com> <54D9E3BF.1090109@redhat.com> <20150210110907.GD5202@noname.str.redhat.com> In-Reply-To: <20150210110907.GD5202@noname.str.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 2/3] coroutine: Clean up qemu_coroutine_enter() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: wu.wubin@huawei.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On 10/02/2015 12:09, Kevin Wolf wrote: >> > >> > 4 mutex->locked = false; >> > qemu_co_queue_next(&mutex->queue); >> > '--> qemu_co_queue_do_restart(queue, true); >> > '--> QTAILQ_REMOVE(&queue->entries, next, co_queue_next); >> > QTAILQ_INSERT_TAIL(&self->co_queue_wakeup, next, co_queue_next); >> > >> > 5 coroutine_swap(co1, leader, COROUTINE_YIELD); >> > >> > And co2 is never reentered until co1 terminates. Right? > No, co2 will be reentered during the yield in line 5. However, it's not > the yielding coroutine that reenters it but the parent, which is resumed > at exactly the line of code that you quoted above. So: 5 coroutine_swap(co1, leader, COROUTINE_YIELD); '--> jumps back to qemu_coroutine_switch '--> returns to qemu_coroutine_enter qemu_co_queue_run_restart(co); '--> QTAILQ_REMOVE(&co->co_queue_wakeup, next, co_queue_next); qemu_coroutine_enter(next, NULL); Thanks for the explanation. Series: Reviewed-by: Paolo Bonzini