VisSharedMemWriter

class VisSharedMemWriter : public kotekan::Stage

Export calibration data out to a shared memory region.

This stage is an improvement upon VisCalWriter. It exports the most recent samples of the calibration data stream to a fixed-length ring-buffer-like shared memory region.

The shared memory region is composed of a Structured Data Region (summarises the structure for the data), an Access Record region (records the writer’s access to the Data region), and the Data region (ring buffer which contains the data and metadata from the frame).

The structure of the shared memory region can be seen in the figure in this issue: https://github.com/kotekan/kotekan/issues/692.

The first section of the structured data region contains 0 if if the stage is gracefully shut down. Otherwise, it will contain the number of writes.

To ensure the ability to read while the stage is continuously writing to the file, readers can inspect the access record to assess the validity of the data. The access record has a 1:1 correlation to the Data region. Every time the Data is modified, the access record will have the timestamp of modification. While data is written, its access record will be set to -1. Acquiring a semaphore, with the same name as the shared memory region is required before reading from or writing to the access record. The Data region is lock free.

This stage writes out the data it receives with minimal processing. Removing certain fields from the output must be done in a prior transformation.

A Valve stage should be added before this buffer process to prevent data backing up during semaphore deadlocks.

To obtain the metadata about the stream received usage of the datasetManager is required.

The dataset ID can be changed in the incoming stream. However, structural parameters that could affect the size of the data cannot be adjusted without triggering a FATAL_ERROR. By default these are input, frequencies, products, stack, eigenvalues, and metadata. This list can be added to using the config variable critical_states. Any state change not considered critical will continue as normal.

Buffers

  • in_buf The buffer streaming data to write

    • Format: VisBuffer structured

    • Metadata: VisMetadata

Metrics

  • dropped_frame_counter The number of times a frame was dropped because it arrived too late.

  • access_record_wait_time_seconds The amount of time the writer spent, in seconds waiting to access the access record.

Author

Anja Boskovic

Param root_path:

String. Location in filesystem containing shared memory and semaphore.

Param name:

Name of shared memory region and semaphore.

Param num_samples:

Number of time samples stored in ring buffer.

Param wait_time:

Maximum time that the writer will wait to unlock a semaphore. If it hits the limit Kotekan will shut down the stage.

Param critical_states:

List of strings. A list of state types to consider critical. That is, if they change in the incoming data stream then Kotekan will shut down.

Public Functions

VisSharedMemWriter(kotekan::Config &config, const std::string &unique_name, kotekan::bufferContainer &buffer_container)
~VisSharedMemWriter()
virtual void main_thread() override