[kernel] 增加rt_mutex_trytake
This commit is contained in:
parent
06927af8f1
commit
8b82b83482
|
@ -322,6 +322,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag);
|
||||||
rt_err_t rt_mutex_delete(rt_mutex_t mutex);
|
rt_err_t rt_mutex_delete(rt_mutex_t mutex);
|
||||||
|
|
||||||
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time);
|
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time);
|
||||||
|
rt_err_t rt_mutex_trytake(rt_mutex_t mutex);
|
||||||
rt_err_t rt_mutex_release(rt_mutex_t mutex);
|
rt_err_t rt_mutex_release(rt_mutex_t mutex);
|
||||||
rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg);
|
rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
18
src/ipc.c
18
src/ipc.c
|
@ -37,7 +37,8 @@
|
||||||
* 2020-07-29 Meco Man fix thread->event_set/event_info when received an
|
* 2020-07-29 Meco Man fix thread->event_set/event_info when received an
|
||||||
* event without pending
|
* event without pending
|
||||||
* 2020-10-11 Meco Man add value overflow-check code
|
* 2020-10-11 Meco Man add value overflow-check code
|
||||||
* 2021-01-03 Meco Man add rt_mb_urgent()
|
* 2021-01-03 Meco Man implement rt_mb_urgent()
|
||||||
|
* 2021-05-30 Meco Man implement rt_mutex_trytake()
|
||||||
* 2021-01-20 hupu fix priority inversion bug of mutex
|
* 2021-01-20 hupu fix priority inversion bug of mutex
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -452,7 +453,7 @@ RTM_EXPORT(rt_sem_take);
|
||||||
*/
|
*/
|
||||||
rt_err_t rt_sem_trytake(rt_sem_t sem)
|
rt_err_t rt_sem_trytake(rt_sem_t sem)
|
||||||
{
|
{
|
||||||
return rt_sem_take(sem, 0);
|
return rt_sem_take(sem, RT_WAITING_NO);
|
||||||
}
|
}
|
||||||
RTM_EXPORT(rt_sem_trytake);
|
RTM_EXPORT(rt_sem_trytake);
|
||||||
|
|
||||||
|
@ -843,6 +844,19 @@ __again:
|
||||||
}
|
}
|
||||||
RTM_EXPORT(rt_mutex_take);
|
RTM_EXPORT(rt_mutex_take);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will try to take a mutex and immediately return
|
||||||
|
*
|
||||||
|
* @param mutex the mutex object
|
||||||
|
*
|
||||||
|
* @return the error code
|
||||||
|
*/
|
||||||
|
rt_err_t rt_mutex_trytake(rt_mutex_t mutex)
|
||||||
|
{
|
||||||
|
return rt_mutex_take(mutex, RT_WAITING_NO);
|
||||||
|
}
|
||||||
|
RTM_EXPORT(rt_mutex_trytake);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will release a mutex, if there are threads suspended on mutex,
|
* This function will release a mutex, if there are threads suspended on mutex,
|
||||||
* it will be waked up.
|
* it will be waked up.
|
||||||
|
|
Loading…
Reference in New Issue