ConOpSys V2970
P004.07
ANVILEX control operating system
|
Functions | |
err_t | sys_sem_new (sys_sem_t *sem, u8_t count) |
void | sys_sem_signal (sys_sem_t *sem) |
u32_t | sys_arch_sem_wait (sys_sem_t *sem, u32_t timeout) |
void | sys_sem_free (sys_sem_t *sem) |
int | sys_sem_valid (sys_sem_t *sem) |
void | sys_sem_set_invalid (sys_sem_t *sem) |
Semaphores can be either counting or binary - lwIP works with both kinds. Semaphores are represented by the type "sys_sem_t" which is typedef'd in the sys_arch.h file. Mailboxes are equivalently represented by the type "sys_mbox_t". Mutexes are represented by the type "sys_mutex_t". lwIP does not place any restrictions on how these types are represented internally.
Blocks the thread while waiting for the semaphore to be signaled. If the "timeout" argument is non-zero, the thread should only be blocked for the specified time (measured in milliseconds). If the "timeout" argument is zero, the thread should be blocked until the semaphore is signalled.
The return value is SYS_ARCH_TIMEOUT if the semaphore wasn't signaled within the specified time or any other value if it was signaled (with or without waiting). Notice that lwIP implements a function with a similar name, sys_sem_wait(), that uses the sys_arch_sem_wait() function.
sem | the semaphore to wait for |
timeout | timeout in milliseconds to wait (0 = wait forever) |
Referenced by sys_msleep(), tcpip_api_call(), and tcpip_send_msg_wait_sem().
void sys_sem_free | ( | sys_sem_t * | sem | ) |
Deallocates a semaphore.
sem | semaphore to delete |
Referenced by sys_msleep(), and tcpip_api_call().
Create a new semaphore Creates a new semaphore. The semaphore is allocated to the memory that 'sem' points to (which can be both a pointer or the actual OS structure). The "count" argument specifies the initial state of the semaphore (which is either 0 or 1). If the semaphore has been created, ERR_OK should be returned. Returning any other error will provide a hint what went wrong, but except for assertions, no real error handling is implemented.
sem | pointer to the semaphore to create |
count | initial count of the semaphore |
Referenced by sys_msleep(), and tcpip_api_call().
void sys_sem_set_invalid | ( | sys_sem_t * | sem | ) |
Invalidate a semaphore so that sys_sem_valid() returns 0. ATTENTION: This does NOT mean that the semaphore shall be deallocated: sys_sem_free() is always called before calling this function! This may also be a define, in which case the function is not prototyped.
void sys_sem_signal | ( | sys_sem_t * | sem | ) |
Signals a semaphore
sem | the semaphore to signal |
Referenced by tcpip_thread_handle_msg().
int sys_sem_valid | ( | sys_sem_t * | sem | ) |
Returns 1 if the semaphore is valid, 0 if it is not valid. When using pointers, a simple way is to check the pointer for != NULL. When directly using OS structures, implementing this may be more complex. This may also be a define, in which case the function is not prototyped.
Referenced by tcpip_send_msg_wait_sem().