[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v7 2/4] coroutine: implement coroutines using gt
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v7 2/4] coroutine: implement coroutines using gthread |
Date: |
Tue, 26 Jul 2011 10:22:18 +0100 |
On Mon, Jul 25, 2011 at 9:38 PM, Anthony Liguori <address@hidden> wrote:
> On 07/25/2011 03:04 PM, Stefan Hajnoczi wrote:
>>
>> From: "Aneesh Kumar K.V"<address@hidden>
>>
>> On platforms that don't support makecontext(3) use gthread based
>> coroutine implementation.
>>
>> Darwin has makecontext(3) but getcontext(3) is stubbed out to return
>> ENOTSUP. Andreas Färber<address@hidden> debugged this and
>> contributed the ./configure test which solves the issue for Darwin/ppc64
>> (and ppc) v10.5.
>>
>> [Original patch by Aneesh, made consistent with coroutine-ucontext.c and
>> switched to GStaticPrivate by Stefan. Tested on Linux and OpenBSD.]
>>
>> Signed-off-by: Aneesh Kumar K.V<address@hidden>
>> Signed-off-by: Stefan Hajnoczi<address@hidden>
>> ---
>> Makefile.objs | 4 ++
>> configure | 18 +++++++
>> coroutine-gthread.c | 131
>> +++++++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 153 insertions(+), 0 deletions(-)
>> create mode 100644 coroutine-gthread.c
>>
>> diff --git a/Makefile.objs b/Makefile.objs
>> index 28e1762..5679e1f 100644
>> --- a/Makefile.objs
>> +++ b/Makefile.objs
>> @@ -13,7 +13,11 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o
>> qemu-thread-posix.o
>> #######################################################################
>> # coroutines
>> coroutine-obj-y = qemu-coroutine.o
>> +ifeq ($(CONFIG_UCONTEXT_COROUTINE),y)
>> coroutine-obj-$(CONFIG_POSIX) += coroutine-ucontext.o
>> +else
>> +coroutine-obj-$(CONFIG_POSIX) += coroutine-gthread.o
>> +endif
>> coroutine-obj-$(CONFIG_WIN32) += coroutine-win32.o
>>
>> #######################################################################
>> diff --git a/configure b/configure
>> index 600da9b..1b6ad87 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2499,6 +2499,20 @@ if test "$trace_backend" = "dtrace"; then
>> fi
>>
>> ##########################################
>> +# check if we have makecontext
>> +
>> +ucontext_coroutine=no
>> +if test "$darwin" != "yes"; then
>> + cat> $TMPC<< EOF
>> +#include<ucontext.h>
>> +int main(void) { makecontext(0, 0, 0); }
>> +EOF
>> + if compile_prog "" "" ; then
>> + ucontext_coroutine=yes
>> + fi
>> +fi
>> +
>
> Doesn't this make the build non-bisectable on platforms that don't have
> makecontext? I think the gthread patch needs to come first and then the
> ucontext version can be used on platforms that we detect it's there.
You are correct. I have sent a new version that first introduces
gthread, and then ucontext and fibers.
Stefan