AWS IoT Device SDK C: Platform
Platform portability layer
Return to main page ↑
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 initial 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.
}