seqlock: introduce read-write seqlock
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 25 Sep 2013 06:20:57 +0000 (14:20 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 17 Oct 2013 15:24:15 +0000 (17:24 +0200)
commitea753d81e8b085d679f13e4a6023e003e9854d51
tree072bf3d6c7a3bd8726fe767cbf90470b7172ebce
parentc46860ea53854a96b11af0d6e23b623ce199e95e
seqlock: introduce read-write seqlock

Seqlock implementation for QEMU. Usage idiom

reader:
    do {
        start = seqlock_read_begin(&sl);
        ...
    } while (seqlock_read_retry(&sl, start));

writer:
    seqlock_write_lock(&sl);
    ...
    seqlock_write_unlock(&sl);

initialization:
    seqlock_init(QemuSeqLock *sl, QemuMutex *mutex)

    mutex could be NULL if the caller will provide its own protection
    for concurrent write sides (typically using the BQL).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/seqlock.h [new file with mode: 0644]