ck_pflock (3) - Linux Manuals

NAME

ck_pflock_init ck_pflock_write_lock ck_pflock_write_unlock ck_pflock_read_lock ck_pflock_read_unlock - centralized phase-fair reader-writer locks

LIBRARY

Concurrency Kit (libck, -lck)

SYNOPSIS

In ck_pflock.h

ck_pflock_t lock = CK_PFLOCK_INITIALIZER;

Ft void Fn ck_pflock_init ck_pflock_t *lock Ft void Fn ck_pflock_write_lock ck_pflock_t *lock Ft void Fn ck_pflock_write_unlock ck_pflock_t *lock Ft void Fn ck_pflock_read_lock ck_pflock_t *lock Ft void Fn ck_pflock_read_unlock ck_pflock_t *lock

DESCRIPTION

This is a centralized phase-fair reader-writer lock. It requires little space overhead and has a low latency fast path.

EXAMPLE

#include <ck_pflock.h>

static ck_pflock_t lock = CK_TFLOCK_INITIALIZER;

static void
reader(void)
{

        for (;;) {
                ck_pflock_read_lock(&lock);
                /* Read-side critical section. */
                ck_pflock_read_unlock(&lock);
        }

        return;
}

static void
writer(void)
{

        for (;;) {
                ck_pflock_write_lock(&lock);
                /* Write-side critical section. */
                ck_pflock_write_unlock(&lock);
        }

        return;
}

SEE ALSO

ck_brlock3, ck_rwlock3, ck_tflock3, ck_swlock3

Additional information available at http://concurrencykit.org/