1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/esp_common/freertos: lock/unlock mutex if scheduling is not active

If module `core_mutex_priority_inheritance` is enabled, the scheduling has to be active to lock/unlock the mutex/rmutex used by FreeRTOS semaphores. If scheduling is not active FreeRTOS semaphore function always succeed.
This commit is contained in:
Gunar Schorcht 2022-09-01 18:26:44 +02:00
parent e1a613ac5c
commit 6386580b8f

View File

@ -66,6 +66,11 @@ BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore)
{
DEBUG("%s mutex=%p\n", __func__, xSemaphore);
/* if scheduler is not running, we must not lock the mutex */
if (thread_getpid() == KERNEL_PID_UNDEF) {
return pdPASS;
}
assert(xSemaphore != NULL);
_sem_t* sem = (_sem_t*)xSemaphore;
@ -91,6 +96,11 @@ BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore,
{
DEBUG("%s mutex=%p wait=%"PRIu32"\n", __func__, xSemaphore, xTicksToWait);
/* if scheduler is not running, we must not lock the mutex */
if (thread_getpid() == KERNEL_PID_UNDEF) {
return pdPASS;
}
assert(xSemaphore != NULL);
_sem_t* sem = (_sem_t*)xSemaphore;
@ -139,6 +149,11 @@ BaseType_t xSemaphoreGiveRecursive(SemaphoreHandle_t xSemaphore)
{
DEBUG("%s rmutex=%p\n", __func__, xSemaphore);
/* if scheduler is not running, we must not lock the mutex */
if (thread_getpid() == KERNEL_PID_UNDEF) {
return pdPASS;
}
_rsem_t* rsem = (_rsem_t*)xSemaphore;
assert(rsem != NULL);
@ -156,6 +171,11 @@ BaseType_t xSemaphoreTakeRecursive(SemaphoreHandle_t xSemaphore,
{
DEBUG("%s rmutex=%p wait=%"PRIu32"\n", __func__, xSemaphore, xTicksToWait);
/* if scheduler is not running, we must not lock the rmutex */
if (thread_getpid() == KERNEL_PID_UNDEF) {
return pdPASS;
}
_rsem_t* rsem = (_rsem_t*)xSemaphore;
assert(rsem != NULL);