Platform API Reference
Platform portability layer
IotSemaphore_Create

Create a new counting semaphore.

bool IotSemaphore_Create( IotSemaphore_t * pNewSemaphore,
uint32_t initialValue,
uint32_t maxValue );

This function creates a new counting semaphore with a given intial and maximum value. It must be called on an uninitialized IotSemaphore_t. This function must not be called on an already-initialized IotSemaphore_t.

Parameters
[in]pNewSemaphorePointer to the memory that will hold the new semaphore.
[in]initialValueThe semaphore should be initialized with this value.
[in]maxValueThe maximum value the semaphore will reach.
Returns
true if semaphore creation succeeds; false otherwise.
See also
IotSemaphore_Destroy

Example

// Create a locked binary semaphore.
if( IotSemaphore_Create( &sem, 0, 1 ) == true )
{
// Unlock the semaphore.
// Destroy the semaphore when it's no longer needed.
}
IotSemaphore_Destroy
void IotSemaphore_Destroy(IotSemaphore_t *pSemaphore)
Free resources used by a semaphore.
IotSemaphore_t
_IotSystemSemaphore_t IotSemaphore_t
The type used to represent semaphores, configured with the type _IotSystemSemaphore_t.
Definition: iot_platform_types.h:97
IotSemaphore_Post
void IotSemaphore_Post(IotSemaphore_t *pSemaphore)
Post to (unlock) a semaphore. This function should only return when the semaphore post succeeds; it i...
IotSemaphore_Create
bool IotSemaphore_Create(IotSemaphore_t *pNewSemaphore, uint32_t initialValue, uint32_t maxValue)
Create a new counting semaphore.