Manual Pages


ck_tflock(3)             BSD Library Functions Manual             ck_tflock(3)

NAME
     ck_tflock_ticket_init, ck_tflock_ticket_write_lock,
     ck_tflock_ticket_write_unlock, ck_tflock_ticket_read_lock,
     ck_tflock_ticket_read_unlock, -- centralized task-fair reader-writer
     locks

LIBRARY
     Concurrency Kit (libck, -lck)

SYNOPSIS
     #include <ck_tflock.h>

     ck_tflock_ticket_t lock = CK_TFLOCK_TICKET_INITIALIZER;

     void
     ck_tflock_ticket_init(ck_tflock_ticket_t *lock);

     void
     ck_tflock_ticket_write_lock(ck_tflock_ticket_t *lock);

     void
     ck_tflock_ticket_write_unlock(ck_tflock_ticket_t *lock);

     void
     ck_tflock_ticket_read_lock(ck_tflock_ticket_t *lock);

     void
     ck_tflock_ticket_read_unlock(ck_tflock_ticket_t *lock);

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

EXAMPLE
           #include <ck_tflock.h>

           static ck_tflock_ticket_t lock = CK_TFLOCK_INITIALIZER;

           static void
           reader(void)
           {

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

                   return;
           }

           static void
           writer(void)
           {

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

                   return;
           }

SEE ALSO
     ck_brlock(3), ck_rwlock(3), ck_pflock(3), ck_swlock(3)

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

                                April 22, 2014.