Rtos API example
Semaphore Class Reference
[Semaphore class]
The Semaphore class is used to manage and protect access to a set of shared resources. More...
#include <Semaphore.h>
Inherits NonCopyable< Semaphore >.
Public Member Functions | |
Semaphore (int32_t count=0) | |
Create and Initialize a Semaphore object used for managing resources. | |
Semaphore (int32_t count, uint16_t max_count) | |
Create and Initialize a Semaphore object used for managing resources. | |
int32_t | wait (uint32_t millisec=osWaitForever) |
Wait until a Semaphore resource becomes available. | |
osStatus | release (void) |
Release a Semaphore resource that was obtain with Semaphore::wait. | |
Private Member Functions | |
MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &) | |
NonCopyable copy constructor. | |
MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator | |
NonCopyable copy assignment operator. |
Detailed Description
The Semaphore class is used to manage and protect access to a set of shared resources.
- Note:
- Memory considerations: The semaphore control structures will be created on current thread's stack, both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
Definition at line 45 of file Semaphore.h.
Constructor & Destructor Documentation
Semaphore | ( | int32_t | count = 0 ) |
Create and Initialize a Semaphore object used for managing resources.
- Parameters:
-
count number of available resources; maximum index value is (count-1). (default: 0).
Definition at line 29 of file Semaphore.cpp.
Semaphore | ( | int32_t | count, |
uint16_t | max_count | ||
) |
Create and Initialize a Semaphore object used for managing resources.
- Parameters:
-
count number of available resources max_count maximum number of available resources
Definition at line 33 of file Semaphore.cpp.
Member Function Documentation
osStatus release | ( | void | ) |
Release a Semaphore resource that was obtain with Semaphore::wait.
- Returns:
- status code that indicates the execution status of the function: osOK the token has been correctly released. osErrorResource the maximum token count has been reached. osErrorParameter internal error.
Definition at line 60 of file Semaphore.cpp.
int32_t wait | ( | uint32_t | millisec = osWaitForever ) |
Wait until a Semaphore resource becomes available.
- Parameters:
-
millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
- Returns:
- number of available tokens, before taking one; or -1 in case of incorrect parameters
Definition at line 46 of file Semaphore.cpp.
Generated on Sun Jul 17 2022 08:25:44 by 1.7.2