diff options
| author | Meco Jianting Man <[email protected]> | 2021-06-05 13:03:45 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-05 13:03:45 +0800 |
| commit | bfd8d21e388befc5d971075db5af0ed561abb4f2 (patch) | |
| tree | d5caabadeb30fc67b3e0efa6dad251617639e096 /src/ipc.c | |
| parent | 02331fd30d1f1ca8c886aac4db6c8c111987913c (diff) | |
| parent | 28847008171ab7423b6b05b7157d3467f1525fda (diff) | |
Merge branch 'master' into mutexrevert
Diffstat (limited to 'src/ipc.c')
| -rwxr-xr-x | src/ipc.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -37,7 +37,9 @@ * 2020-07-29 Meco Man fix thread->event_set/event_info when received an * event without pending * 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 */ #include <rtthread.h> @@ -123,6 +125,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, break; default: + RT_ASSERT(0); break; } @@ -425,7 +428,7 @@ RTM_EXPORT(rt_sem_take); */ 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); @@ -817,6 +820,19 @@ __again: 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, * it will be waked up. * |
