File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed 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 semaphore values' overflow-check code
40- * in the function of rt_sem_release
40+ * 2020-10-21 Meco Man add mutex values' overflow-check code
4141 */
4242
4343#include <rtthread.h>
@@ -697,8 +697,16 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
697697
698698 if (mutex -> owner == thread )
699699 {
700- /* it's the same thread */
701- mutex -> hold ++ ;
700+ if (mutex -> hold < 255u )
701+ {
702+ /* it's the same thread */
703+ mutex -> hold ++ ;
704+ }
705+ else
706+ {
707+ rt_hw_interrupt_enable (temp ); /* enable interrupt */
708+ return - RT_EFULL ; /* value overflowed */
709+ }
702710 }
703711 else
704712 {
You can’t perform that action at this time.
0 commit comments