HANDLE osOpenCountSem( SYSNAME Name );
The name of the counting semaphore object to be opened.
On success, the return value is a handle to the opened counting semaphore object. On failure, the function returns NULL_HANDLE. Call the osGetLastError function to retrieve extended error information.
This function opens an existing counting semaphore object by its name.
Counting semaphores are utilized to synchronize access to shared resources, ensuring that no more than a specified number of tasks can utilize the resource concurrently.
During the creation of a counting semaphore, an optional name may be assigned. This allows other tasks to obtain a handle to the semaphore via the osOpenCountSem function. When a counting semaphore handle is no longer required, it should be released using the osCloseHandle function. The underlying semaphore object is deleted only after all tasks that opened the handle have closed it. Further details are available in the system objects management section.
If no osOpen* functions are referenced within the application, the system will ignore object names and the internal logic for name management will be excluded from the build. This optimization reduces the final footprint of the output code. For more information regarding object naming and opening, refer to the system objects management section.
For more detailed information regarding the behavior and use of counting semaphores, please refer to the counting semaphore objects section.
This function is available only when the OS_USE_CNT_SEM and OS_OPEN_CNT_SEM_FUNC configuration constants are set to 1. If this function is not required, set OS_OPEN_CNT_SEM_FUNC to 0 to reduce the total code size.
| Version: | 1.0 |
|---|---|
| Header file: | OS_CountSem.h (include OS_API.h) |
| See also: | counting semaphores, HANDLE, NULL_HANDLE, OS_OPEN_CNT_SEM_FUNC, osCloseHandle, osCreateCountSem, osGetLastError, SYSNAME, system objects management |