FBB::SharedMutex(3bobcat) | Shared Memory Mutex | FBB::SharedMutex(3bobcat) |
FBB::SharedMutex - Mutex for shared memory
#include <bobcat/sharedmutex>
Linking option: -lpthread, -lbobcat
Shared memory may be used by multiple processes. To synchronize access to shared memory an FBB::SharedMutex may be defined inside a shared memory segment. SharedMutex objects allows clients to lock a shared memory segment before reading or writing its contents. E.g., the Bobcat class FBB::SharedSegment defines a SharedMutex in its shared memory segment.
The SharedMutex class uses the facilities offered by the PThread library to implement (non recursive) shared memory locking. To force unlocking a (possibly) locked shared memory segment, its destructor can be called.
SharedMutex mutexes are non-recursive, resulting in deadlocks if their lock member is called twice from the same thread of execution without an intermediate call to unlock the mutex. If this causes concern, a variable can be defined indicating whether the lock has already been obtained.
FBB
All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace FBB.
-
Caveat: when using placement new to initialize a SharedMutex make sure that the SharedMutex fits inside a block (i.e., shared.blockOffset() + sizeof(SharedMemory) < shared.dataSegmentSize()). If not, use seek to switch to an offset where this equality holds true, or simply use SharedMemory::create like this:
new (d_shared) FBB::SharedMutex;
FBB::SharedMemory::create<FBB::SharedMutex>();
d_sharedMutex->~SharedMutex();(assuming SharedMutex *d_sharedMutex points to the location where placement new has previously initialized the FBB::SharedMutex object.)
See the sharedstream(3bobcat) man page.
bobcat/sharedmutex - defines the class interface
bobcat(7) isharedstream(3bobcat), osharedstream(3bobcat), sharedblock(3bobcat), sharedcondition(3bobcat), sharedmemory(3bobcat), (e.g.,) pthread_mutex_init(3posix), sharedpos(3bobcat), sharedreadme(7bobcat), sharedsegment(3bobcat), sharedstream(3bobcat), sharedstreambuf(3bobcat)
None Reported.
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
This is free software, distributed under the terms of the GNU General Public License (GPL).
Frank B. Brokken (f.b.brokken@rug.nl).
2005-2018 | libbobcat-dev_4.08.06-x.tar.gz |