1ck_pflock(3)             BSD Library Functions Manual             ck_pflock(3)
2

NAME

4     ck_pflock_init, ck_pflock_write_lock, ck_pflock_write_unlock,
5     ck_pflock_read_lock, ck_pflock_read_unlock, — centralized phase-fair
6     reader-writer locks
7

LIBRARY

9     Concurrency Kit (libck, -lck)
10

SYNOPSIS

12     #include <ck_pflock.h>
13
14     ck_pflock_t lock = CK_PFLOCK_INITIALIZER;
15
16     void
17     ck_pflock_init(ck_pflock_t *lock);
18
19     void
20     ck_pflock_write_lock(ck_pflock_t *lock);
21
22     void
23     ck_pflock_write_unlock(ck_pflock_t *lock);
24
25     void
26     ck_pflock_read_lock(ck_pflock_t *lock);
27
28     void
29     ck_pflock_read_unlock(ck_pflock_t *lock);
30

DESCRIPTION

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

EXAMPLE

36           #include <ck_pflock.h>
37
38           static ck_pflock_t lock = CK_TFLOCK_INITIALIZER;
39
40           static void
41           reader(void)
42           {
43
44                   for (;;) {
45                           ck_pflock_read_lock(&lock);
46                           /* Read-side critical section. */
47                           ck_pflock_read_unlock(&lock);
48                   }
49
50                   return;
51           }
52
53           static void
54           writer(void)
55           {
56
57                   for (;;) {
58                           ck_pflock_write_lock(&lock);
59                           /* Write-side critical section. */
60                           ck_pflock_write_unlock(&lock);
61                   }
62
63                   return;
64           }
65

SEE ALSO

67     ck_brlock(3), ck_rwlock(3), ck_tflock(3), ck_swlock(3)
68
69     Additional information available at http://concurrencykit.org/
70
71                                April 22, 2014.
Impressum