Details on lock-free buffer management » History » Version 1
Details on lock-free buffer management¶
The artdaq shared memory interface uses several flags in the buffer descriptor structure to achieve self-contained, lock-free operation.
- std::atomic<BufferSemaphoreFlags> sem
- The state of the buffer. One of Empty, Writing, Full, or Reading.
- std::atomic<int16_t> sem_id
- The current owner of the buffer. Each instance of SharedMemoryManager takes an ID number (from ShmStruct::std::atomic<int> next_id), and uses this number to indicate that it is the current owner of the buffer. Buffers without owners have sem_id set to -1.
- std::atomic<uint64_t> last_touch_time
- The last time (microseconds, system clock) the buffer was "touched". Buffers should be touched whenever a modifying operation occurs, such as writes or reads, or before the buffer transitions from an inactive state (Empty, Full) to an active state (Writing, Reading).