File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag);
322322rt_err_t rt_mutex_delete (rt_mutex_t mutex );
323323
324324rt_err_t rt_mutex_take (rt_mutex_t mutex , rt_int32_t time );
325+ rt_err_t rt_mutex_trytake (rt_mutex_t mutex );
325326rt_err_t rt_mutex_release (rt_mutex_t mutex );
326327rt_err_t rt_mutex_control (rt_mutex_t mutex , int cmd , void * arg );
327328#endif
Original file line number Diff line number Diff line change 3737 * 2020-07-29 Meco Man fix thread->event_set/event_info when received an
3838 * event without pending
3939 * 2020-10-11 Meco Man add value overflow-check code
40- * 2021-01-03 Meco Man add rt_mb_urgent()
40+ * 2021-01-03 Meco Man implement rt_mb_urgent()
41+ * 2021-05-30 Meco Man implement rt_mutex_trytake()
4142 * 2021-01-20 hupu fix priority inversion bug of mutex
4243 */
4344
@@ -452,7 +453,7 @@ RTM_EXPORT(rt_sem_take);
452453 */
453454rt_err_t rt_sem_trytake (rt_sem_t sem )
454455{
455- return rt_sem_take (sem , 0 );
456+ return rt_sem_take (sem , RT_WAITING_NO );
456457}
457458RTM_EXPORT (rt_sem_trytake );
458459
@@ -843,6 +844,19 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
843844}
844845RTM_EXPORT (rt_mutex_take );
845846
847+ /**
848+ * This function will try to take a mutex and immediately return
849+ *
850+ * @param mutex the mutex object
851+ *
852+ * @return the error code
853+ */
854+ rt_err_t rt_mutex_trytake (rt_mutex_t mutex )
855+ {
856+ return rt_mutex_take (mutex , RT_WAITING_NO );
857+ }
858+ RTM_EXPORT (rt_mutex_trytake );
859+
846860/**
847861 * This function will release a mutex, if there are threads suspended on mutex,
848862 * it will be waked up.
You can’t perform that action at this time.
0 commit comments