spec

Software for Diffraction

2.3.4.2.4. - Shared Memory Arrays



When created with the shared keyword, the array data and a header structure are stored in shared memory. For each shared memory array, spec creates an immutable global variable named SHMID_var whose value is the shared memory ID associated with the shared memory segment and where where var is the name of the array. This ID is used by other programs that wish to access the shared memory.

spec can connect to an existing shared memory array created by another process running on the same platform, perhaps created by another instance of spec. The syntax is:
extern shared array [spec:[pid:]]arr
where the optional parameter spec is the name of the spec version that created the array, the optional parameter pid is the process ID of the version and arr is the name of the array. The first two arguments can be used in case more than one instance of the shared array exists. Examples include:
extern shared array data
extern shared array fourc:data
extern shared array fourc:1234:data
The shared array segments include a header that describes the array. Two features of the header that are primarily associated with shared arrays that can accessed from spec user level are tags and frames. Shared arrays tags can be manipulated with the array_op() tag and untag options, as described in the next section.

Frame-size and latest-frame header elements allow a shared 2D array to be described as a series of 1D or 2D acquisitions (or frames). The frame size is the number of rows in a single frame. The latest frame is the most recently updated frame number. The latest frame value should allow an auxiliary program that maintains a live display to update the display efficiently. The frame values are also accessed via array_op(). Currently, the frame values are unused by spec in array operations, although specific hardware support may modify frames values.

The structure used for the shared memory data is given in the file SPECD/include/spec_shm.h. A C file containing an API for accessing the spec shared memory arrays is included in the spec distribution and is named sps.c.