The State Machine Rman Interface uses a shared memory mechanism and a supporting daemon (incorporated into Norman) to manage the different memory resources available on the State Machine Stream Processor. The shared memory segments created and accessed using this mechanism are used to specify aggregate parameter types (including processor state) as arguments to functions running on the State Machine processors. Internal to Norman, this same mechanism is used for allocating temporary buffers for stream input and output.
This shared memory mechanism has a programming interface similar
to that of the UNIX shared memory library. Segments must first be
created,
usually by the application, which obtains a unique shared memory ID
for the segment. This ID is then passed to other processes that need
to access that memory structure, taking the place of the pointer used
to identify "normal" memory data structures. Before using, a shared
segment must be attached, which dereferences the ID into a pointer
in the process's address space. A shared segment is aware of the
number of threads currently attached (which includes references to it
in queues currently waiting for execution.) When a process is
finished with a memory segment, it is detached. A segment is either
destroyed by its application, or garbage-collected when all
processes have detached.
When creating memory, the storage class must be specified. Three
different storage classes are provided, corresponding to read-only static,
read/write static, and read/write dynamic data classes :
The SMEM_VAR class bears a little more description.
These are shared memory segments whose contents may modified. When a
process attaches to these segments, it locks out all other processes.
If another process is currently attached to this class of segment, an
RmanAttach operation will return an error value
indicating this condition.
The Norman resource manager will not schedule a pipeline for execution
until all the shared memory segments in a function's parameter list have successfully been attached.
The process of attaching to a shared memory segment may require that the
current version of the segment be copied into the address space of the
requesting processor, and invalidated. The copy is then marked as the
current version and a pointer to it returned. The current version of a
variable segment may remain on a stream processor until it is either
attached by a process running on the P2 local processor or flushed due
to a shortage of stream processor memory. The resource manager takes
the current location of shared memory segments into account when assigning
stream processors to pipelines.
A typical usage for a Constant class segment is :
A typical usage for a Variable class segment is :
Here are the C declarations for the shared memory interface.
These defines and data structures, as well as prototypes for the functions,
are automatically included into <cheops_rman.h>, and are
actually defined in <sys/params.h>.
This function creates a shared memory object, and returns an ID for it.
This ID can be translated into a physical pointer to a local memory
object which a processor can directly read or write using the
RmanAttach() function.
This function takes a shared memory ID and returns a pointer to
block of memory local to the processor calling this function. When
a processor is through accessing the shared memory, it should call
RmanDetach().
In case the segment could not be attached (when another process has
it locked, in the case of Variable class segments),
the pointer returned is equal to zero (NULL).
This function takes a shared memory ID and deallocates any local
resources it is using, but does not force the destruction of the
actual shared memory object and the data stored in it.
This function takes a shared memory ID and forces the destruction of
the actual shared memory object and the data stored in it.
Please send comments regarding this proposal to
wad@media.mit.edu
Memory Classes
Typical Usage
C Declarations
#define SMEM_ID_ERROR 0 /* not valid id - indicates error in create */
#define SMEM_PARAM( num ) ( 1 << (num)) /* shared mem parameter bit field */
typedef int smem_id;
typedef enum {
SMEM_CONST, /* written once and not modified */
SMEM_VAR, /* A changing variable, whose coherence must be maintained. */
SMEM_LOCAL, /* localbuffer - not init'ed by normal means, and temporary */
} smem_class;
RmanCreate
Arguments
Returns smem_id - A shared memory ID for the
new block of memory.
RmanAttach
Arguments
Returns void * - A pointer, in the physical address
space of the processor making the call, to the
shared block of memory.
RmanDetach
Arguments
Returns void
RmanDestroy
Arguments
Returns void
Jump to State Machine Software Overview
Jump to the State Machine Stream Processor
Jump to the Cheops Homepage
wad@media.mit.edu 7/31/96
This is a "fix it yourself" page, located at
${CHEOPS_BASE}/WWW/statemac/software/smem.html