The following classes accessing memory segments are available:
- o
- MemoryAccess(3bobcat)
- The class MemoryAccess(3bobcat) defines an object interfacing to a
shared memory segment (cf. shmget(2)). If offers functionality to
set and retrieve its id, and write and read bytes from its shared
memory segment. MemoryAccess objects are used by
MemoryBridge(3bobcat) objects keeping track of which segments
actually contain the data bytes.
- MemoryAccess objects are used by MemoryBridge and are
normally not directly constructed by user programs.
- o
- MemoryBridge(3bobcat)
- The class MemoryBridge (cf. figure
images/sharedsegment1.jpg) interfaces to shared memory using
MemoryAccess objects. Its main member function is the static member
create, returning a pointer to a newly allocated
MemoryMemory object.
- The member create receives as its input parameters the number of
blocks, the size of the segments allocated by MemoryBridge, and the
segment’s access mode (as used by, e.g., chmod(1)). It
returns a pointer to the allocated MemoryBridge, and its ID (set
using a pointer to an int, passed as its first parameter).
- Although the MemoryBridge class defines an array of a single
MemoryAccess(3bobcat) object, in fact it will contain
d_nAccesss MemoryAccess objects. The member create
first allocates a block of raw memory of the required total size. Next it
initializes the first part of this raw, shared memory, using the
MemoryBridge constructor and placement new. Next, the remaining
amount of raw shared memory is initialized with d_nAccesss - 1
MemoryAccess objects, again using placement new (cf. figure
images/sharedsegment2.jpg in the source distribution).
- Following read/write operations the offset is updated accordingly.
There’s only one offset, which is used by [IO]?MemoryStream
objects when requesting or updating offsets. a MemoryMemory object
offers safeguards against inappropriate use. E.g., if no memory has been
allocated yet it may thow exceptions. Also, offsets can never exceed the
MemoryMemory’s maximum possible offset.
- o
- MemoryBuf(3bobcat)
- The class MemoryBuf implements a std::streambuf
specialization interfacing to a MemoryMemory object. In addition to
a default constructor which is an empty stub the class offers constructors
which immediately interface to a MemoryBridge object.
- o
- MemoryStream(3bobcat)
- The MemoryStream class offers stream-facilities operating on shared
memory maintained by a MemoryBuf object.
An overview of currently defined shared memory segments is shown
by the command ipcs -ma. To erase a defined shared memory segment the
command ipcrm -m <id> can be used, where <id> is
the shared memory segment’s ID.
Images referred to in this man-page are located in the source
distribution in bobcat/documents/images, or they can be found in the
standard location of documentation files in your distribution (e.g., they
are located in /usr/share/doc/libbobcat6/images).
- o
- https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
- o
- libbobcat6: debian package containing the shared library, changelog
and copyright note;
- o
- libbobcat-dev: debian package containing the static library,
headers, manual pages, and developer info;
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).