]> git.proxmox.com Git - mirror_qemu.git/commit - tests/Makefile
rfifolock: add recursive FIFO lock
authorStefan Hajnoczi <stefanha@redhat.com>
Mon, 3 Mar 2014 10:30:03 +0000 (11:30 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 13 Mar 2014 13:42:21 +0000 (14:42 +0100)
commit2da61b671eb89fcaa306738f44eed472977d6587
tree61673e48ab889a6ea113ff4d2be2d48d7108d1a1
parent11f590b1a242492a0108da42f40f0e2b20f0a778
rfifolock: add recursive FIFO lock

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.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
include/qemu/rfifolock.h [new file with mode: 0644]
tests/Makefile
tests/test-rfifolock.c [new file with mode: 0644]
util/Makefile.objs
util/rfifolock.c [new file with mode: 0644]