The following classes accessing memory segments are available:
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.
The class MemoryBridge (cf. figure images/sharedsegment1.jpg) interfaces to actual shared memory. 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).
The class MemoryPos(3bobcat) monitors position information in the shared memory segments managed by MemoryBridge objects. MemoryPos only has a default constructor, but offers a reset member receiving at construction time a pointer to a MemoryBridge object.
The class MemoryMemory(3bobcat) offers the standard interface to shared memory, defining members like read, get, write and put. It interfaces to a MemoryBridge object, and uses a MemoryPos object to keep track of the MemoryMemory's offsets.
A MemoryMemory object itself resides in a program's working memory, and not in the computer's shared memory area. At any time the MemoryMemory object only loads at most one actual block of the shared memory block managed by MemoryBridge. The current position in the shared memory managed by MemoryBridge is monitored by the MemoryMemory's MemoryAccess d_pos member.
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.
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 MemoryMemory object, as well as a member to (re)associate a MemoryBuf object with a MemoryMemory object.
These stream classes offer stream-facilities operating on shared memory maintained by a MemoryMemory object. The MemoryStream class uses the MemoryMemory's seek member for both seekp and seekg, and uses MemoryMemory's offset member for both tellp and tellg. All shared stream objects, including IMemoryStream, offer a member to initialize a MemoryCondition
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).
Debian Bobcat project files: