GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CK_BRLOCK (3)

NAME

ck_brlock_init, ck_brlock_write_lock, ck_brlock_write_unlock, ck_brlock_write_trylock, ck_brlock_read_register, ck_brlock_read_unregister, ck_brlock_read_lock, ck_brlock_read_trylock, ck_brlock_read_unlock - big-reader locks

CONTENTS

Library
Synopsis
Description
Example
See Also

LIBRARY

Concurrency Kit (libck, -lck)

SYNOPSIS


.In ck_brlock.h

ck_brlock_t brlock = CK_BRLOCK_INITIALIZER;

ck_brlock_reader_t reader = CK_BRLOCK_READER_INITIALIZER;

void ck_brlock_init ck_brlock_t *br void ck_brlock_write_lock ck_brlock_t *br void ck_brlock_write_unlock ck_brlock_t *br bool ck_brlock_write_trylock ck_brlock_t *br unsigned int factor void ck_brlock_read_register ck_brlock_t *br ck_brlock_reader_t *reader void ck_brlock_read_unregister ck_brlock_t *br ck_brlock_reader_t *reader void ck_brlock_read_lock ck_brlock_t *br ck_brlock_reader_t *reader bool ck_brlock_read_trylock ck_brlock_t *br ck_brlock_reader_t *reader "unsigned int factor" void ck_brlock_read_unlock ck_brlock_reader_t *reader

DESCRIPTION

Big reader locks are distributed reader-writer locks with low latency constant time reader acquisition (with respect to number of concurrent readers). On the other hand, writer acquisitions are a relatively expensive O(n) operation. This is a write-biased lock.

EXAMPLE

static ck_brlock_t lock = CK_BRLOCK_INITIALIZER;
static __thread ck_brlock_reader_t reader;

static void reader(void) {

        /* Add our thread as a lock participant. */         ck_brlock_read_register(&lock, &reader);

        for (;;) {                 ck_brlock_read_lock(&lock, &reader);                 /* Read-side critical section. */                 ck_brlock_read_unlock(&reader);

                if (ck_brlock_read_trylock(&lock, &reader, 1) == true) {                         /* Read-side critical section. */                         ck_brlock_read_unlock(&reader);                 }         }

        return; }

static void writer(void) {

        for (;;) {                 ck_brlock_write_lock(&lock);                 /* Write-side critical section. */                 ck_brlock_write_unlock(&lock);

                if (ck_brlock_write_trylock(&lock, 1) == true) {                         /* Write-side critical section. */                         ck_brlock_write_unlock(&lock);                 }         }

        return; }

SEE ALSO

ck_bytelock(3), ck_rwlock(3)

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

Search for    or go to Top of page |  Section 3 |  Main Index


Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.