cyg_semaphore_init | |
Name: | cyg_semaphore_init ( ) - initialize a counting semaphore |
---|---|
Synopsis: | void cyg_semaphore_init ( cyg_sem_t *sem, /* semaphore to initialize */ cyg_count32 val /* initial semaphore count */ ) |
Description: | This initializes a counting semaphore for use. |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | nothing |
See Also: | cyg_semaphore_destroy |
cyg_semaphore_destroy | |
Name: | cyg_semaphore_destroy ( ) - destroy (invalidate) a semaphore |
---|---|
Synopsis: | void cyg_semaphore_destroy ( cyg_sem_t *sem /* semaphore to invalidate */ ) |
Description: | This invalidates a semaphore for further use. Be certain that no other threads are waiting on or otherwise using the semaphore or you will risk deadlocking the system. |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | nothing |
See Also: | cyg_semaphore_init |
cyg_semaphore_wait | |
Name: | cyg_semaphore_wait ( ) - wait on a counting semaphore |
---|---|
Synopsis: | cyg_bool_t cyg_semaphore_wait ( cyg_sem_t *sem /* semaphore to wait on */ ) |
Description: | This requests a semaphore. If the semaphore count is set to 0, it will block the calling thread until the semphore count is incremented. If several threads are waiting on the same semaphore, the scheduler will determine which task gets the semaphore first. Generally, it will be the thread with the highest priority. If the thread is awaken for some other reason, this function may return false without actually acquiring the semaphore. |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | "true" if the semaphore was acquired, "false" otherwise. |
See Also: | cyg_semaphore_timed_wait, cyg_semaphore_trywait, cyg_semaphore_post, cyg_semaphore_peek |
cyg_semaphore_timed_wait | |
Name: | cyg_semaphore_timed_wait ( ) - wait on a semaphore with timeout |
---|---|
Synopsis: | cyg_bool_t cyg_semaphore_timed_wait ( cyg_sem_t *sem, /* semaphore to wait on */ cyg_tick_count_t abstime /* absolute timeout value */ ) |
Description: | This requests a semaphore. If the semaphore count is set to 0, it will block the calling thread until the semaphore count is incremented or the system time reaches (or surpasses) "abstime". If several threads are waiting on the same semaphore, the scheduler will determine which task gets the semaphore first. Generally, it will be the thread with the highest priority. You can get the current system time by calling cyg_current_time. |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | "true" if the semaphore was acquired, "false" otherwise. |
See Also: | cyg_semaphore_wait, cyg_semaphore_trywait, cyg_semaphore_post, cyg_semaphore_peek |
cyg_semaphore_trywait | |
Name: | cyg_semaphore_trywait ( ) - get a semaphore if available |
---|---|
Synopsis: | int cyg_semaphore_trywait ( cyg_sem_t *sem /* semaphore to get */ ) |
Description: | This requests a semaphore. If the semaphore count is set to 0, it will not block the calling thread, but will indicate an error. |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | "true" if the semaphore was acquired, "false" otherwise. |
See Also: | cyg_semaphore_wait, cyg_semaphore_timed_wait, cyg_semaphore_post, cyg_semaphore_peek |
cyg_semaphore_post | |
Name: | cyg_semaphore_post ( ) - increment semaphore count |
---|---|
Synopsis: | void cyg_semaphore_post ( cyg_sem_t *sem /* semaphore to increment count of */ ) |
Description: | Increment the count of the given semaphore. |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | nothing |
See Also: | cyg_semaphore_wait, cyg_semaphore_timed_wait, cyg_semaphore_trywait, cyg_semaphore_peek |
cyg_semaphore_peek | |
Name: | cyg_semaphore_peek ( ) - get current semaphore count |
---|---|
Synopsis: | void cyg_semaphore_peek ( cyg_sem_t *sem, /* semaphore to get count of */ cyg_count32 *val /* pointer to receive count */ ) |
Description: | This gets the current count of a counting semaphore through a pointer to "val" (the second argument). |
Include: | #include <cyg/kernel/kapi.h> |
Returns: | nothing |
See Also: | cyg_semaphore_wait, cyg_semaphore_timed_wait, cyg_semaphore_trywait, cyg_semaphore_post |