From 28ca70cce50ae7823c0fbaad3e887814e3fe21b7 Mon Sep 17 00:00:00 2001 From: xutao Date: Wed, 19 Aug 2020 17:42:49 +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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index 7be44b2b9b..1d64cddcc3 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -593,6 +593,14 @@ 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);