From d2173ba1e87abc89cd22106c381d6a48b1b06b84 Mon Sep 17 00:00:00 2001 From: xutao Date: Tue, 17 Nov 2020 14:33:19 +0800 Subject: [PATCH] pthread: fix the priority inheritance When `pthread_mutex_destroy` is used to release mutex, `pthread_mutex_lock_internal` is used, which results in the increase of `uxmutexehold` and no recovery base priority --- components/pthread/pthread.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index ce0c064ce3..a2cfd980b5 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -593,6 +593,15 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) return EBUSY; } + if (mux->type == PTHREAD_MUTEX_RECURSIVE) { + res = xSemaphoreGiveRecursive(mux->sem); + } else { + res = xSemaphoreGive(mux->sem); + } + if (res != pdTRUE) { + assert(false && "Failed to release mutex!"); + } + vSemaphoreDelete(mux->sem); free(mux);