paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Enumerations | Functions
ipc.h File Reference

inter process communication and shared memory routines More...

Enumerations

enum  shm_attach_mode { ATTACH_RO, ATTACH_RW }
 possible values for shm_attach() More...
 

Functions

int mutex_new (void)
 Define a new mutex. More...
 
int mutex_destroy (int id)
 Destroy a mutex. More...
 
void mutex_lock (int id)
 Lock the given mutex. More...
 
void mutex_unlock (int id)
 Unlock a mutex. More...
 
int shm_new (size_t size)
 Create a new shared memory area of given size. More...
 
int shm_attach (int id, enum shm_attach_mode mode, void **result)
 Attach a shared memory segment. More...
 
int shm_detach (void *addr)
 Detach a shared memory segment. More...
 
int shm_destroy (int id)
 Destroy the given shared memory area. More...
 
int shm_size (int id, size_t *result)
 Get the size of a shared memory segment. More...
 
size_t shm_get_shmmax (void)
 Get the maximal size of a shared memory area. More...
 

Detailed Description

inter process communication and shared memory routines

Enumeration Type Documentation

◆ shm_attach_mode

possible values for shm_attach()

Enumerator
ATTACH_RO 
ATTACH_RW 

Function Documentation

◆ mutex_new()

int mutex_new ( void  )

Define a new mutex.

Returns
The identifier for the new mutex on success, a negative error code on errors.
See also
semget(2).

References ERRNO_TO_PARA_ERROR.

◆ mutex_destroy()

int mutex_destroy ( int  id)

Destroy a mutex.

Parameters
idThe identifier of the mutex to be destroyed.
Returns
Standard.
See also
semctl(2)

References ERRNO_TO_PARA_ERROR.

◆ mutex_lock()

void mutex_lock ( int  id)

Lock the given mutex.

Parameters
idThe identifier of the shared memory area to lock.

This function either succeeds or aborts.

See also
semop(2), struct misc_meta_data.

◆ mutex_unlock()

void mutex_unlock ( int  id)

Unlock a mutex.

Parameters
idThe identifier of the mutex.

This function either succeeds or aborts.

See also
semop(2), struct misc_meta_data.

◆ shm_new()

int shm_new ( size_t  size)

Create a new shared memory area of given size.

Parameters
sizeThe size of the shared memory area to create.
Returns
The id of the shared memory array on success, a negative error code on errors.
See also
shmget(2).

References ERRNO_TO_PARA_ERROR.

Referenced by pass_buffer_as_shm(), and send_callback_request().

◆ shm_attach()

int shm_attach ( int  id,
enum shm_attach_mode  mode,
void **  result 
)

Attach a shared memory segment.

Parameters
idThe identifier of the shared memory segment to attach.
modeEither ATTACH_RO (read only) or ATTACH_RW (read/write).
resultPoints to the attached area just attached on success.
Returns
Standard.
See also
shmat(2).

References ATTACH_RW, and ERRNO_TO_PARA_ERROR.

Referenced by load_afd(), pass_buffer_as_shm(), and send_callback_request().

◆ shm_detach()

int shm_detach ( void *  addr)

Detach a shared memory segment.

Parameters
addrThe address of the attached segment.
Returns
Standard.
See also
shmdt(2).

References ERRNO_TO_PARA_ERROR.

Referenced by pass_buffer_as_shm(), and send_callback_request().

◆ shm_destroy()

int shm_destroy ( int  id)

Destroy the given shared memory area.

Parameters
idThe shared memory identifier.
Returns
The return value of the underlying shmctl() call on success, a negative error code on errors.
See also
shmctl(2).

References ERRNO_TO_PARA_ERROR.

Referenced by pass_buffer_as_shm().

◆ shm_size()

int shm_size ( int  id,
size_t *  result 
)

Get the size of a shared memory segment.

Parameters
idThe shared memory segment identifier.
resultSize in bytes is returned here, zero on errors.
Returns
Standard.
See also
shmctl(2).

References ERRNO_TO_PARA_ERROR.

Referenced by load_afd().

◆ shm_get_shmmax()

size_t shm_get_shmmax ( void  )

Get the maximal size of a shared memory area.

The value is only computed once when the function is called for the first time. Subsequent calls return the number which was computed during the first call.

Returns
A number suitable as an argument to shm_new().

References PARA_INFO_LOG, and PARA_WARNING_LOG.