C API semaphore definitions. More...
Classes | |
| struct | os_semaphore_attr_s |
| Semaphore attributes. More... | |
| struct | os_semaphore_s |
| Semaphore object storage. More... | |
Typedefs | |
| typedef struct os_semaphore_attr_s | os_semaphore_attr_t |
| Semaphore attributes. | |
| typedef int16_t | os_semaphore_count_t |
| Type of variables holding semaphore counts. | |
| typedef struct os_semaphore_s | os_semaphore_t |
| Semaphore object storage. | |
Semaphore Attributes Functions | |
| void | os_semaphore_attr_init (os_semaphore_attr_t *attr) |
| Initialise the counting semaphore attributes. | |
| void | os_semaphore_attr_binary_init (os_semaphore_attr_t *attr, const os_semaphore_count_t initial_value) |
| Initialise the binary semaphore attributes. | |
| void | os_semaphore_attr_counting_init (os_semaphore_attr_t *attr, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value) |
| Initialise the counting semaphore attributes. | |
| const os_semaphore_attr_t * | os_semaphore_attr_get_binary (void) |
| Get a binary semaphore attributes object instance. | |
Semaphore Creation Functions | |
| void | os_semaphore_construct (os_semaphore_t *semaphore, const char *name, const os_semaphore_attr_t *attr) |
| Construct a statically allocated semaphore object instance. | |
| void | os_semaphore_binary_construct (os_semaphore_t *semaphore, const char *name, const os_semaphore_count_t initial_value) |
| Construct a statically allocated binary semaphore object instance. | |
| void | os_semaphore_counting_construct (os_semaphore_t *semaphore, const char *name, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value) |
| Construct a statically allocated counting semaphore object instance. | |
| void | os_semaphore_destruct (os_semaphore_t *semaphore) |
| Destruct the statically allocated semaphore object instance. | |
| os_semaphore_t * | os_semaphore_new (const char *name, const os_semaphore_attr_t *attr) |
| Allocated a semaphore object instance and construct it. | |
| os_semaphore_t * | os_semaphore_binary_new (const char *name, const os_semaphore_count_t initial_value) |
| Allocate a binary semaphore object instance and construct it. | |
| os_semaphore_t * | os_semaphore_counting_new (const char *name, const os_semaphore_count_t max_value, const os_semaphore_count_t initial_value) |
| Allocate a counting semaphore object instance and construct it. | |
| void | os_semaphore_delete (os_semaphore_t *semaphore) |
| Destruct the semaphore object instance. | |
Semaphore Functions | |
| const char * | os_semaphore_get_name (os_semaphore_t *semaphore) |
| Get the semaphore name. | |
| os_result_t | os_semaphore_post (os_semaphore_t *semaphore) |
| Post (unlock) the semaphore. | |
| os_result_t | os_semaphore_wait (os_semaphore_t *semaphore) |
| Lock the semaphore, possibly waiting. | |
| os_result_t | os_semaphore_try_wait (os_semaphore_t *semaphore) |
| Try to lock the semaphore. | |
| os_result_t | os_semaphore_timed_wait (os_semaphore_t *semaphore, os_clock_duration_t timeout) |
| Timed wait to lock the semaphore. | |
| os_semaphore_count_t | os_semaphore_get_value (os_semaphore_t *semaphore) |
| Get the semaphore count value. | |
| os_result_t | os_semaphore_reset (os_semaphore_t *semaphore) |
| Reset the semaphore. | |
| os_semaphore_count_t | os_semaphore_get_initial_value (os_semaphore_t *semaphore) |
| Get the semaphore initial count value. | |
| os_semaphore_count_t | os_semaphore_get_max_value (os_semaphore_t *semaphore) |
| Get the semaphore maximum count value. | |
Compatibility Macros | |
| #define | os_semaphore_create os_semaphore_construct |
| #define | os_semaphore_binary_create os_semaphore_binary_construct |
| #define | os_semaphore_counting_create os_semaphore_counting_construct |
| #define | os_semaphore_destroy os_semaphore_destruct |
C API semaphore definitions.
| #define os_semaphore_binary_create os_semaphore_binary_construct |
Definition at line 1926 of file os-c-api.h.
| #define os_semaphore_counting_create os_semaphore_counting_construct |
Definition at line 1927 of file os-c-api.h.
| #define os_semaphore_create os_semaphore_construct |
Definition at line 1925 of file os-c-api.h.
| #define os_semaphore_destroy os_semaphore_destruct |
Definition at line 1928 of file os-c-api.h.
| typedef struct os_semaphore_attr_s os_semaphore_attr_t |
Semaphore attributes.
Initialise this structure with os_semaphore_attr_init() and then set any of the individual members directly.
| typedef int16_t os_semaphore_count_t |
Type of variables holding semaphore counts.
Definition at line 1088 of file os-c-decls.h.
| typedef struct os_semaphore_s os_semaphore_t |
Semaphore object storage.
This C structure has the same size as the C++ os::rtos::semaphore object and must be initialised with os_semaphore_create().
Later on a pointer to it can be used both in C and C++ to refer to the semaphore object instance.
The members of this structure are hidden and should not be used directly, but only through specific functions.
| void os_semaphore_attr_binary_init | ( | os_semaphore_attr_t * | attr, |
| const os_semaphore_count_t | initial_value | ||
| ) |
Initialise the binary semaphore attributes.
| [in] | attr | Pointer to semaphore attributes object instance. |
| [in] | initial_value | Initial count value. |
Definition at line 1959 of file os-c-wrapper.cpp.
| void os_semaphore_attr_counting_init | ( | os_semaphore_attr_t * | attr, |
| const os_semaphore_count_t | max_value, | ||
| const os_semaphore_count_t | initial_value | ||
| ) |
Initialise the counting semaphore attributes.
| [in] | attr | Pointer to semaphore attributes object instance. |
| [in] | max_value | Maximum count value. |
| [in] | initial_value | Initial count value. |
Definition at line 1974 of file os-c-wrapper.cpp.
| const os_semaphore_attr_t * os_semaphore_attr_get_binary | ( | void | ) |
Get a binary semaphore attributes object instance.
Definition at line 1990 of file os-c-wrapper.cpp.
| void os_semaphore_attr_init | ( | os_semaphore_attr_t * | attr | ) |
Initialise the counting semaphore attributes.
| [in] | attr | Pointer to semaphore attributes object instance. |
Definition at line 1945 of file os-c-wrapper.cpp.
| void os_semaphore_binary_construct | ( | os_semaphore_t * | semaphore, |
| const char * | name, | ||
| const os_semaphore_count_t | initial_value | ||
| ) |
Construct a statically allocated binary semaphore object instance.
| [in] | semaphore | Pointer to semaphore object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | initial_value | Initial count value. |
os_semaphore_destruct().Definition at line 2025 of file os-c-wrapper.cpp.
| os_semaphore_t * os_semaphore_binary_new | ( | const char * | name, |
| const os_semaphore_count_t | initial_value | ||
| ) |
Allocate a binary semaphore object instance and construct it.
| [in] | name | Pointer to name (may be NULL). |
| [in] | initial_value | Initial count value. |
Dynamically allocate the binary semaphore object instance using the RTOS system allocator and construct it.
new semaphore_binary(...). os_semaphore_delete().Definition at line 2105 of file os-c-wrapper.cpp.
| void os_semaphore_construct | ( | os_semaphore_t * | semaphore, |
| const char * | name, | ||
| const os_semaphore_attr_t * | attr | ||
| ) |
Construct a statically allocated semaphore object instance.
| [in] | semaphore | Pointer to semaphore object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
os_semaphore_destruct().Definition at line 2004 of file os-c-wrapper.cpp.
| void os_semaphore_counting_construct | ( | os_semaphore_t * | semaphore, |
| const char * | name, | ||
| const os_semaphore_count_t | max_value, | ||
| const os_semaphore_count_t | initial_value | ||
| ) |
Construct a statically allocated counting semaphore object instance.
| [in] | semaphore | Pointer to semaphore object instance storage. |
| [in] | name | Pointer to name (may be NULL). |
| [in] | max_value | Maximum count value. |
| [in] | initial_value | Initial count value. |
os_semaphore_destruct().Definition at line 2042 of file os-c-wrapper.cpp.
| os_semaphore_t * os_semaphore_counting_new | ( | const char * | name, |
| const os_semaphore_count_t | max_value, | ||
| const os_semaphore_count_t | initial_value | ||
| ) |
Allocate a counting semaphore object instance and construct it.
| [in] | name | Pointer to name (may be NULL). |
| [in] | max_value | Maximum count value. |
| [in] | initial_value | Initial count value. |
Dynamically allocate the counting semaphore object instance using the RTOS system allocator and construct it.
new semaphore_counting(...). os_semaphore_delete().Definition at line 2126 of file os-c-wrapper.cpp.
| void os_semaphore_delete | ( | os_semaphore_t * | semaphore | ) |
Destruct the semaphore object instance.
| [in] | semaphore | Pointer to semaphore object instance. |
Destruct the semaphore and deallocate the dynamically allocated space using the RTOS system allocator.
delete ptr_semaphore. os_semaphore_new() or os_semaphore_binary_new() or os_semaphore_counting_new().Definition at line 2149 of file os-c-wrapper.cpp.
| void os_semaphore_destruct | ( | os_semaphore_t * | semaphore | ) |
Destruct the statically allocated semaphore object instance.
| [in] | semaphore | Pointer to semaphore object instance. |
os_semaphore_construct() or os_semaphore_binary_construct() or os_semaphore_counting_construct().Definition at line 2061 of file os-c-wrapper.cpp.
| os_semaphore_count_t os_semaphore_get_initial_value | ( | os_semaphore_t * | semaphore | ) |
Get the semaphore initial count value.
| [in] | semaphore | Pointer to semaphore object instance. |
Definition at line 2254 of file os-c-wrapper.cpp.
| os_semaphore_count_t os_semaphore_get_max_value | ( | os_semaphore_t * | semaphore | ) |
Get the semaphore maximum count value.
| [in] | semaphore | Pointer to semaphore object instance. |
Definition at line 2267 of file os-c-wrapper.cpp.
| const char * os_semaphore_get_name | ( | os_semaphore_t * | semaphore | ) |
Get the semaphore name.
| [in] | semaphore | Pointer to semaphore object instance. |
Definition at line 2162 of file os-c-wrapper.cpp.
| os_semaphore_count_t os_semaphore_get_value | ( | os_semaphore_t * | semaphore | ) |
Get the semaphore count value.
| [in] | semaphore | Pointer to semaphore object instance. |
Definition at line 2228 of file os-c-wrapper.cpp.
| os_semaphore_t * os_semaphore_new | ( | const char * | name, |
| const os_semaphore_attr_t * | attr | ||
| ) |
Allocated a semaphore object instance and construct it.
| [in] | name | Pointer to name (may be NULL). |
| [in] | attr | Pointer to attributes (may be NULL). |
Dynamically allocate the semaphore object instance using the RTOS system allocator and construct it.
new semaphore(...). os_semaphore_delete().Definition at line 2081 of file os-c-wrapper.cpp.
| os_result_t os_semaphore_post | ( | os_semaphore_t * | semaphore | ) |
Post (unlock) the semaphore.
| [in] | semaphore | Pointer to semaphore object instance. |
| os_ok | The semaphore was posted. |
| EAGAIN | The maximum count value was exceeded. |
| ENOTRECOVERABLE | The semaphore could not be posted (extension to POSIX). |
Definition at line 2175 of file os-c-wrapper.cpp.
| os_result_t os_semaphore_reset | ( | os_semaphore_t * | semaphore | ) |
Reset the semaphore.
| [in] | semaphore | Pointer to semaphore object instance. |
| os_ok | The semaphore was reset. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
Definition at line 2241 of file os-c-wrapper.cpp.
| os_result_t os_semaphore_timed_wait | ( | os_semaphore_t * | semaphore, |
| os_clock_duration_t | timeout | ||
| ) |
Timed wait to lock the semaphore.
| [in] | semaphore | Pointer to semaphore object instance. |
| [in] | timeout | Timeout to wait. |
| os_ok | The calling process successfully performed the semaphore lock operation. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| EINVAL | Invalid timeout (POSIX limits the timeout to 1000 million ns) |
| ETIMEDOUT | The semaphore could not be locked before the specified timeout expired. |
| ENOTRECOVERABLE | Semaphore wait failed (extension to POSIX). |
| EDEADLK | A deadlock condition was detected. |
| EINTR | The operation was interrupted. |
Definition at line 2214 of file os-c-wrapper.cpp.
| os_result_t os_semaphore_try_wait | ( | os_semaphore_t * | semaphore | ) |
Try to lock the semaphore.
| [in] | semaphore | Pointer to semaphore object instance. |
| os_ok | The calling process successfully performed the semaphore lock operation. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| EWOULDBLOCK | The semaphore was already locked. |
| ENOTRECOVERABLE | Semaphore wait failed (extension to POSIX). |
| EDEADLK | A deadlock condition was detected. |
| EINTR | The operation was interrupted. |
Definition at line 2201 of file os-c-wrapper.cpp.
| os_result_t os_semaphore_wait | ( | os_semaphore_t * | semaphore | ) |
Lock the semaphore, possibly waiting.
| [in] | semaphore | Pointer to semaphore object instance. |
| os_ok | The calling process successfully performed the semaphore lock operation. |
| EPERM | Cannot be invoked from an Interrupt Service Routines. |
| ENOTRECOVERABLE | Semaphore wait failed (extension to POSIX). |
| EDEADLK | A deadlock condition was detected. |
| EINTR | The operation was interrupted. |
Definition at line 2188 of file os-c-wrapper.cpp.