Mutex

nRF5 SDK v10.0.0

nRF51 SDK v10.0.0

An internal module of Peer Manager . This module provides thread-safe mutexes. More...

Macros

#define MUTEX_STORAGE_SIZE (number_of_mutexes)   ((7 + (number_of_mutexes)) >> 3)
Defines the storage size of a specified mutex group. More...

Functions

void pm_mutex_init (uint8_t *p_mutex, uint16_t mutex_size)
Initializes a mutex group. More...
bool pm_mutex_lock (uint8_t *p_mutex, uint16_t mutex_bit_id)
Locks the mutex specified by the bit id. More...
uint16_t pm_mutex_lock_first_available (uint8_t *p_mutex, uint16_t mutex_size)
Locks the first unlocked mutex within the mutex group. More...
void pm_mutex_unlock (uint8_t *p_mutex, uint16_t mutex_bit_id)
Unlocks the mutex specified by the bit id. More...
bool pm_mutex_lock_status_get (uint8_t *p_mutex, uint16_t mutex_bit_id)
Gets the locking status of the specified mutex. More...

Detailed Description

An internal module of Peer Manager . This module provides thread-safe mutexes.

Macro Definition Documentation

#define MUTEX_STORAGE_SIZE ( number_of_mutexes ) ((7 + (number_of_mutexes)) >> 3)

Defines the storage size of a specified mutex group.

Parameters
number_of_mutexes the number of mutexes in the group.

Function Documentation

void pm_mutex_init ( uint8_t * p_mutex ,
uint16_t mutex_size
)

Initializes a mutex group.

Parameters
[in] p_mutex Pointer to the mutex group. See MUTEX_STORAGE_SIZE() .
[in] mutex_size The size of the mutex group in number of mutexes.
bool pm_mutex_lock ( uint8_t * p_mutex ,
uint16_t mutex_bit_id
)

Locks the mutex specified by the bit id.

Parameters
[in,out] p_mutex Pointer to the mutex group.
[in] mutex_bit_id The bit id of the mutex.
Return values
true if it was possible to lock the mutex.
false otherwise.
uint16_t pm_mutex_lock_first_available ( uint8_t * p_mutex ,
uint16_t mutex_size
)

Locks the first unlocked mutex within the mutex group.

Parameters
[in,out] p_mutex Pointer to the mutex group.
[in] mutex_size The size of the mutex group.
Returns
The first unlocked mutex id in the group.
Return values
group-size if there was no unlocked mutex available.
bool pm_mutex_lock_status_get ( uint8_t * p_mutex ,
uint16_t mutex_bit_id
)

Gets the locking status of the specified mutex.

Parameters
[in,out] p_mutex Pointer to the mutex group.
[in] mutex_bit_id The bit id of the mutex.
Return values
true if the mutex was locked.
false otherwise.
void pm_mutex_unlock ( uint8_t * p_mutex ,
uint16_t mutex_bit_id
)

Unlocks the mutex specified by the bit id.

Parameters
[in,out] p_mutex Pointer to the mutex group.
[in] mutex_bit_id The bit id of the mutex.

Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone .