Re: [Qemu-devel] [PATCH 06/11] coroutine-lock: make CoMutex thread-safe

2016-05-17 Thread Paolo Bonzini
On 29/04/2016 08:26, Fam Zheng wrote: > > +if (to_wake) { > > +Coroutine *co = to_wake->co; > > +qemu_coroutine_wake(co->ctx, co); > > +goto out; > > +} > > + > > +/* Some concurrent lock() is in progress (we know this because of > > +

Re: [Qemu-devel] [PATCH 06/11] coroutine-lock: make CoMutex thread-safe

2016-04-28 Thread Fam Zheng
On Fri, 04/15 13:32, Paolo Bonzini wrote: > +/* The wait records are handled with a multiple-producer, single-consumer > + * lock-free queue. There cannot be two concurrent pop_waiter() calls > + * because pop_waiter() can only come when mutex->handoff is zero. This can > + * happen in three case

[Qemu-devel] [PATCH 06/11] coroutine-lock: make CoMutex thread-safe

2016-04-15 Thread Paolo Bonzini
This uses the lock-free mutex described in the paper '"Blocking without Locking", or LFTHREADS: A lock-free thread library' by Gidenstam and Papatriantafilou. The same technique is used in OSv, and in fact the code is essentially a conversion to C of OSv's code. Signed-off-by: Paolo Bonzini ---