OS Lock
API 介绍
This section introduces OS lock reference api.
Typedefs
-
typedef void *os_mutex_h
mutex handle definition
-
typedef void *os_sem_h
sempahore handle definition
Functions
-
os_mutex_h os_create_mutex(module_id_t module_id)
This function is to create a mutex.
- 参数:
module_id -- is the module that creates the event.
- 返回:
os_mutex_h NULL — for failure case otherwise — mutex handle
-
void os_acquire_mutex(os_mutex_h mutex)
This function is to acquire a mutex. This function can be called recursively from one task. For each call, a corresponding release call is required to release the mutex. This function can NOT be called in ISR context.
- 参数:
mutex -- is mutex to be acquired
-
bool os_try_acquire_mutex(os_mutex_h mutex)
This function is to try to acquire a mutex. This function is not blocking when called. This function can NOT be called in ISR context.
- 参数:
mutex -- is mutex to be acquired
- 返回:
true — acquire mutex successfully,false — failed.
-
void os_release_mutex(os_mutex_h mutex)
This function is to release a mutex This function can NOT be called in ISR context.
- 参数:
mutex -- is mutex to be released
-
void os_delete_mutex(os_mutex_h mutex)
This function is to delete a mutex.
- 参数:
mutex -- is mutex to be deleted
-
os_sem_h os_create_semaphore(module_id_t module_id, uint32_t max_count, uint32_t init_count)
This function is to create a count semaphore.
- 参数:
module_id -- is the module that creates the semaphore.
max_count -- is max count for this semaphore.
init_count -- is init count for this semaphore.
- 返回:
NULL — for failure case otherwise — semaphore handle
-
bool os_pend_semaphore(os_sem_h semaphore, uint32_t timeout)
This function is to pend to take a semaphore. This function can NOT be called in ISR context.
- 参数:
semaphore -- is semaphore to be take.
timeout -- is timeout time(ms).
- 返回:
bool true — take semaphore successfully, false - timeout.
-
bool os_post_semaphore(os_sem_h semaphore)
This function is to post a semaphore. This function can NOT be called in ISR context.
- 参数:
semaphore -- is semaphore to be posted
- 返回:
bool true — post semaphore successfully, false - failed.
-
bool os_post_semaphore_from_isr(os_sem_h semaphore)
This function is to post a semaphore. This function can only be called in ISR context.
- 参数:
semaphore -- is semaphore to be posted
- 返回:
bool true — post semaphore successfully, false - failed.
-
bool os_post_semaphore_from_critical(os_sem_h semaphore)
This function is to post a semaphore. This function can only be called in critical context.
- 参数:
semaphore -- is semaphore to be posted
- 返回:
bool true — post semaphore successfully, false - failed.
-
void os_delete_semaphore(os_sem_h semaphore)
This function is to delete a semaphore.
- 参数:
semaphore -- is semaphore to be deleted
-
void os_critical_enter(void)
This function is turn off interrupt function.
-
void os_critical_exit(void)
This function is turn on interrupt function.