Class Db: implements a simple data buffer in shared memory.
Class Db: implements a simple data buffer in shared memory.The data buffer Db consists of a big chunk of shared memory that is divided into many slots of constant length. Valid data can be put into the slots by simply copying into it. The advantage of this simple approach is that it is very fast getting access to the slot: one simply has to know its offset within the shared memory. Note that we make sure that we allocate memory in chunks of PAGE_SIZE bytes.
A special case happens when one needs a buffer that is bigger than this fixed length slot: in this case we create a volatile buffer of the appropriate size to which we can attach or which we can destroy when it is no longer needed. Note that we cannot allocate memory in this way: therefore the class only allows to create a fixed number of volatile buffers. The ownership (uid) of a volatile buffer can also be set to a desired value in order to allow other processes to delete the volatile buffer once it is no longer used.
A very simple iterator mechanism exists to iterate over the fixed sized slots of the data buffer.
Modifications:
- add check in remove_buffer to make sure that the Db was actually created when we try to remove it.
CW Mar 17, 99
Alphabetic index HTML hierarchy of classes or Java