Просмотр исходного кода

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
xutao 5 лет назад
Родитель
Сommit
61807f6e52
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      components/pthread/pthread.c

+ 9 - 0
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);