qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v2 1/6] rfifolock: add recursive FIFO lock


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC v2 1/6] rfifolock: add recursive FIFO lock
Date: Thu, 20 Feb 2014 13:45:13 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Jan 20, 2014 at 06:22:28PM +0800, Fam Zheng wrote:
> On Fri, 01/10 09:45, Stefan Hajnoczi wrote:
> > QemuMutex does not guarantee fairness and cannot be acquired
> > recursively:
> > 
> > Fairness means each locker gets a turn and the scheduler cannot cause
> > starvation.
> > 
> > Recursive locking is useful for composition, it allows a sequence of
> > locking operations to be invoked atomically by acquiring the lock around
> > them.
> > 
> > This patch adds RFifoLock, a recursive lock that guarantees FIFO order.
> > Its first user is added in the next patch.
> > 
> > RFifoLock has one additional feature: it can be initialized with an
> > optional contention callback.  The callback is invoked whenever a thread
> > must wait for the lock.  For example, it can be used to poke the current
> > owner so that they release the lock soon.
> > 
> 
> Is it better to make the contention callback per-caller than per-lock?
> Considering that different caller may want to do different things depending on
> current code path.

Perhaps it will make sense to change it in the future.  For now it means
callers use the standard lock/unlock function.  They don't have to know
what actions are needed to poke the current lock-holder.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]