RTI Connext Micro C++ API Version 4.2.0
Loading...
Searching...
No Matches
OSAPI_SharedMemoryMonitor

A shared memory monitor to provide mutual exclusion between processes and inter-process signaling. More...

Functions

NETIOPSLDllExport RTI_SIZE_T OSAPI_SharedMemoryMonitor_get_size (void)
 Get the amount of memory required to store OSAPI_SharedMemoryMonitor on the current platform.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_initialize (RTI_SIZE_T mem_len, void *mem, struct OSAPI_SharedMemoryMonitor **self_out)
 Initialize a shared memory monitor in a provided memory segment.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_finalize (struct OSAPI_SharedMemoryMonitor *self)
 Finalize a shared memory monitor.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_acquire (struct OSAPI_SharedMemoryMonitor *self, OSAPI_SHMEM_STATUS *status_out)
 Acquire the lock protecting the monitor.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_release (struct OSAPI_SharedMemoryMonitor *self)
 Release the lock protecting the monitor.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_wait (struct OSAPI_SharedMemoryMonitor *self, OSAPI_SHMEM_STATUS *status_out)
 Wait for the monitor to be signaled.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_signal (struct OSAPI_SharedMemoryMonitor *self)
 Signal a thread waiting on a monitor to wake up.
 
NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_mark_consistent (struct OSAPI_SharedMemoryMonitor *self)
 Mark the shared state protected by the monitor as consistent after a process died while holding the lock on the monitor.
 

Detailed Description

A shared memory monitor to provide mutual exclusion between processes and inter-process signaling.

Function Documentation

◆ OSAPI_SharedMemoryMonitor_get_size()

NETIOPSLDllExport RTI_SIZE_T OSAPI_SharedMemoryMonitor_get_size ( void )

Get the amount of memory required to store OSAPI_SharedMemoryMonitor on the current platform.

Returns
The number of bytes required to store a shared memory monitor.

◆ OSAPI_SharedMemoryMonitor_initialize()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_initialize ( RTI_SIZE_T mem_len,
void * mem,
struct OSAPI_SharedMemoryMonitor ** self_out )

Initialize a shared memory monitor in a provided memory segment.

Parameters
[in]mem_lenSize of provided memory.
[in]memMemory segment.
[out]self_outPointer to initialized monitor.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.

◆ OSAPI_SharedMemoryMonitor_finalize()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_finalize ( struct OSAPI_SharedMemoryMonitor * self)

Finalize a shared memory monitor.

Parameters
[in]selfMonitor to finalize.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.

Once this function is called (even if it returns RTI_FALSE) you can no longer use this monitor.

◆ OSAPI_SharedMemoryMonitor_acquire()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_acquire ( struct OSAPI_SharedMemoryMonitor * self,
OSAPI_SHMEM_STATUS * status_out )

Acquire the lock protecting the monitor.


If this function returns RTI_TRUE, the calling thread is guaranteed mutual exclusion by the monitor. No other thread can acquire the lock until the lock is returned with OSAPI_SharedMemoryMonitor_release. This function shall not be called by a thread which currently holds the lock.

If this function returns status_out=OSAPI_SHMEM_STATUS_OWNER_DEAD, then any shared data protected by the monitor may be in an inconsistent state. If the shared data can be restored to a consistent state, then it can be marked as consistent with OSAPI_SharedMemoryMonitor_mark_consistent. Otherwise, any subsequent attempts to acquire or wait on the monitor will fail.

Parameters
[in]selfMonitor to acquire.
[out]status_outIf successful, the status of the protected state.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.

◆ OSAPI_SharedMemoryMonitor_release()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_release ( struct OSAPI_SharedMemoryMonitor * self)

Release the lock protecting the monitor.

Parameters
[in]selfMonitor to release.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.

This function can only be called on a monitor which is currently locked by the calling thread.

◆ OSAPI_SharedMemoryMonitor_wait()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_wait ( struct OSAPI_SharedMemoryMonitor * self,
OSAPI_SHMEM_STATUS * status_out )

Wait for the monitor to be signaled.

Only one thread can wait on a monitor at any one time. This function can only be called on a monitor which is currently locked by the calling thread. The function will return successfully only when another thread has called OSAPI_SharedMemoryMonitor_signal and when the calling thread has acquired the lock.

If this function returns status_out=OSAPI_SHMEM_STATUS_OWNER_DEAD, then any shared data protected by the monitor may be in an inconsistent state. If the shared data can be restored to a consistent state, then it can be marked as consistent with OSAPI_SharedMemoryMonitor_mark_consistent. Otherwise, any subsequent attempts to acquire or wait on the monitor will fail.

Parameters
[in]selfMonitor to wait on.
[out]status_outIf successful, the status of the protected state.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.

◆ OSAPI_SharedMemoryMonitor_signal()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_signal ( struct OSAPI_SharedMemoryMonitor * self)

Signal a thread waiting on a monitor to wake up.

Parameters
[in]selfMonitor to signal.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.

This function can only be called on a monitor which is currently locked by the calling thread.

◆ OSAPI_SharedMemoryMonitor_mark_consistent()

NETIOPSLDllExport RTI_BOOL OSAPI_SharedMemoryMonitor_mark_consistent ( struct OSAPI_SharedMemoryMonitor * self)

Mark the shared state protected by the monitor as consistent after a process died while holding the lock on the monitor.

This function can only be called on a monitor which is currently locked by the calling thread and currently inconsistent. The function shall return the monitor to a consistent state and allow other functions to be called on it. This function may not be supported on all platforms.

Parameters
[in]selfMonitor to mark consistent.
Returns
RTI_TRUE on success. RTI_FALSE if an error occurred.