<< prev | next >> |
From the source file examples/tutorial/atomic_get.c
Using sm_arena_wrlock(), or shm_arena_wrlock() you can make many arena operations inter-process and intra-process thread safe.
The library libshm_arena provides two levels of inter-process shared read-write locks, one outer lock to protect the whole arena file and an optional per segment read-write lock. Both read-write locks are inter-process locks, meaning they do their work between all processes that connect to a particular arena file. The outer arena file read-write lock is required to block all but one process from allocating or freeing segments in the arena any given time.
The functions sm_wrlock(), sm_rdlock(), shm_wrlock(), and shm_rdlock() automatically acquire an arena read lock before acquiring the corrisponding segment lock, if it was not explicitly gotten with sm_arena_wrlock(), sm_arena_rdlock(), shm_arena_wrlock(), or shm_arena_rdlock(). Like-wise the sm_unlock(), and shm_unlock(), automatically release the arena read lock if it was not explicitly gotten with sm_arena_wrlock(), sm_arena_rdlock(), shm_arena_wrlock(), or shm_arena_rdlock().
<< prev | next >> |