Concurrency Support API#

The following structures and functions are used to initialize a multiple reader single writer lock instance.

enum mrsw_lock_type_t#

Values:

enumerator MRSW_READER_PREFERRED#
enumerator MRSW_WRITER_PREFERRED#
enumerator MRSW_COUNT#
typedef struct mrsw_lock mrsw_lock_t#

Struct representing an MRSW instance.

The members in this struct should not be accessed directly.

typedef struct read_pref_mrsw_lock read_pref_mrsw_lock_t#

Struct representing an reader preferred MRSW

The members in this struct should not be accessed directly.

typedef struct write_pref_mrsw_lock write_pref_mrsw_lock_t#

Struct representing an writer preferred MRSW

The members in this struct should not be accessed directly.

rtos_osal_status_t mrsw_lock_create(mrsw_lock_t *ctx, char *name, mrsw_lock_type_t type)#

Create a MRSW lock

Parameters:
  • ctx – A pointer to an uninitialized lock context

  • name – An optional ASCII name

  • type – The type of lock

Returns:

RTOS_OSAL_SUCCESS on success

rtos_osal_status_t mrsw_lock_delete(mrsw_lock_t *ctx)#

Destroy a MRSW lock

Note: This does not check if it is safe to delete locks

Parameters:
  • ctx – A pointer to the associated lock context

Returns:

RTOS_OSAL_SUCCESS on success RTOS_OSAL_ERROR otherwise

struct mrsw_lock#
#include <mrsw_lock.h>

Struct representing an MRSW instance.

The members in this struct should not be accessed directly.

struct read_pref_mrsw_lock#
#include <mrsw_lock.h>

Struct representing an reader preferred MRSW

The members in this struct should not be accessed directly.

struct write_pref_mrsw_lock#
#include <mrsw_lock.h>

Struct representing an writer preferred MRSW

The members in this struct should not be accessed directly.

The following functions are used to use a multiple reader single writer lock instance as a reader.

rtos_osal_status_t mrsw_lock_reader_get(mrsw_lock_t *ctx, unsigned timeout)#

Attempt to acquire a lock as a reader.

Parameters:
  • ctx – A pointer to the associated lock context

  • timeout – A timeout before giving up

Returns:

RTOS_OSAL_SUCCESS on success RTOS_OSAL_TIMEOUT on timeout RTOS_OSAL_ERROR otherwise

rtos_osal_status_t mrsw_lock_reader_put(mrsw_lock_t *ctx)#

Give an acquired lock as a reader.

Note: User must not give a lock they do not own.

Parameters:
  • ctx – A pointer to the associated lock context

Returns:

RTOS_OSAL_SUCCESS on success RTOS_OSAL_ERROR otherwise

The following functions are used to use a multiple reader single writer lock instance as a writer.

rtos_osal_status_t mrsw_lock_writer_get(mrsw_lock_t *ctx, unsigned timeout)#

Attempt to acquire a lock as a writer.

Parameters:
  • ctx – A pointer to the associated lock context

  • timeout – A timeout before giving up

Returns:

RTOS_OSAL_SUCCESS on success RTOS_OSAL_TIMEOUT on timeout RTOS_OSAL_ERROR otherwise

rtos_osal_status_t mrsw_lock_writer_put(mrsw_lock_t *ctx)#

Give an acquired lock as a writer.

Note: User must not give a lock they do not own.

Parameters:
  • ctx – A pointer to the associated lock context

Returns:

RTOS_OSAL_SUCCESS on success RTOS_OSAL_ERROR otherwise