Midas Ring Buffer Functions (rb_xxx)
[The midas.h & midas.c]


Functions

int rb_set_nonblocking ()
int rb_create (int size, int max_event_size, int *handle)
int rb_delete (int handle)
int rb_get_wp (int handle, void **p, int millisec)
int rb_increment_wp (int handle, int size)
int rb_get_rp (int handle, void **p, int millisec)
int rb_increment_rp (int handle, int size)
int rb_get_buffer_level (int handle, int *n_bytes)


Function Documentation

int rb_create ( int  size,
int  max_event_size,
int *  handle 
)

Create a ring buffer with a given size

Provide an inter-thread buffer scheme for handling front-end events. This code allows concurrent data acquisition, calibration and network transfer on a multi-CPU machine. One thread reads out the data, passes it via the ring buffer functions to another thread running on the other CPU, which can then calibrate and/or send the data over the network.

Parameters:
size Size of ring buffer, must be larger than 2*max_event_size
max_event_size Maximum event size to be placed into
*handle Handle to ring buffer
Returns:
DB_SUCCESS, DB_NO_MEMORY, DB_INVALID_PARAM

Definition at line 14004 of file midas.c.

int rb_delete ( int  handle  ) 

Delete a ring buffer

Parameters:
handle Handle of the ring buffer
Returns:
DB_SUCCESS

Definition at line 14058 of file midas.c.

int rb_get_buffer_level ( int  handle,
int *  n_bytes 
)

Return number of bytes in a ring buffer

Parameters:
handle Handle of the buffer to get the info
*n_bytes Number of bytes in buffer
Returns:
DB_SUCCESS, DB_INVALID_HANDLE

Definition at line 14348 of file midas.c.

int rb_get_rp ( int  handle,
void **  p,
int  millisec 
)

Obtain the current read pointer at which new data is available with optional timeout

Parameters:
handle Ring buffer handle
millisec Optional timeout in milliseconds if buffer is full. Zero to not wait at all (non-blocking)
**p Address of pointer pointing to newly available data. If p == NULL, only return status.
Returns:
DB_SUCCESS, DB_TIEMOUT, DB_INVALID_HANDLE

Definition at line 14232 of file midas.c.

Referenced by receive_trigger_event().

int rb_get_wp ( int  handle,
void **  p,
int  millisec 
)

Retrieve write pointer where new data can be written

Parameters:
handle Ring buffer handle
millisec Optional timeout in milliseconds if buffer is full. Zero to not wait at all (non-blocking)
**p Write pointer
Returns:
DB_SUCCESS, DB_TIMEOUT, DB_INVALID_HANDLE

Definition at line 14094 of file midas.c.

Referenced by interrupt_routine(), and readout_thread().

int rb_increment_rp ( int  handle,
int  size 
)

Increment current read pointer, freeing up space for the writing thread.

Parameters:
handle Ring buffer handle
size Number of bytes to free up at current read pointer
Returns:
DB_SUCCESS, DB_INVALID_PARAM

Definition at line 14294 of file midas.c.

Referenced by receive_trigger_event().

int rb_increment_wp ( int  handle,
int  size 
)

rb_increment_wp

Increment current write pointer, making the data at the write pointer available to the receiving thread

Parameters:
handle Ring buffer handle
size Number of bytes placed at the WP
Returns:
DB_SUCCESS, DB_INVALID_PARAM, DB_INVALID_HANDLE

Definition at line 14170 of file midas.c.

Referenced by interrupt_routine(), and readout_thread().

int rb_set_nonblocking (  ) 

Set all rb_get_xx to nonblocking. Needed in multi-thread environments for stopping all theads without deadlock

Returns:
DB_SUCCESS

Definition at line 13963 of file midas.c.

Referenced by main().


Midas DOC Version 2.0.2 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk