[BUG] vTaskPrioritySet doesn't set event item value according to the inherited priority
Los mantenedores suelen responder en 3 días
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 22/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- c
- Área
- operating-systems
Línea de trabajo
Start in tasks.c at vTaskPrioritySet(), where the event list item value is set from the new priority rather than the inherited one, and compare it with xTaskPriorityInherit() and vTaskPriorityDisinheritAfterTimeout(), which already update it. Pull request #1380 is open against this issue, so check it before starting. Done means the event item value uses the effective priority, and the vTaskPrioritySet() unit tests assert that value.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
I found the code in vTaskPrioritySet() handles inheritance of priority when a task is holding a mutex. But the corresponding event item value is set according to the new priority directly.
In xTaskPriorityInherit() and vTaskPriorityDisinheritAfterTimeout(), the event item value will be set and reset according to the inheritance condition.
If the code use pxTCB->uxPriority to set event item value, it would be correct.
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ) );
Incorrect event item value may cause something like deadlock when a task trying to take multiple mutexes or semaphores as shown in the below test case.
Target
- Development board: Pico W
- Instruction Set Architecture: ARMv6M
- Toolchain and version: Pico SDK 2.2.0
Host
- Host OS: Ubuntu 24.04
To Reproduce
Test Case
Step1. Task1 take mutex1.
Step2. Task3 and task4 try take mutex2 at the same time.
Step3. Task1 inherit task2 priority.
Step4. Task1 set it's own priority =2.
Step5. Task1 take mutex2 and block indefinitely.
Result would be:
Task1 will never be unblocked since the event value is higher then task3 and task4, although task1 has higher priority.
Some snippets from console:
///// task2 try to take mutex1
task2 take mutex1] try
task3 take mutex[1] failed
task3 gave mutex[2]
task4 take mutex[2] success
task4 take mutex[1] try
task3 on core 1, pri=3, base_pri=3, evt_val=29, ct=2
task3 take mutex[2] try
///// task1 inherited priority from task2
task1 on core 0, pri=4, base_pri=1, evt_val=28, ct=1
task4 take mutex[1] failed
task4 gave mutex[2]
task3 take mutex[2] success
task4 on core 1, pri=3, base_pri=3, evt_val=29, ct=2
task1 on core 0, pri=4, base_pri=1, evt_val=28, ct=2
///// set task1 it's own priority = 2
task1 set priority = 2.
task4 take mutex[2] try
task3 take mutex[1] try
///// task1 priority = 4, event value = 30, 4 + 30 = 34 > 32 == configMAX_PRIORITIES
task1 on core 1, pri=4, base_pri=2, evt_val=30, ct=3
///// task1 try to take mutex2
task1 try to take mutex[2] and block indefinitely.
///// task3 and task4 take mutex2 then mutex1 repeatedly
task3 take mutex[1] failed
task3 gave mutex[2]
task4 take mutex[2] success
task3 on core 0, pri=3, base_pri=3, evt_val=29, ct=3
task3 take mutex[2] try
task4 take mutex[1] try
task4 take mutex[1] failed
task4 gave mutex[2]
task3 take mutex[2] success
task3 take mutex[1] try
task4 on core 1, pri=3, base_pri=3, evt_val=29, ct=3
task4 take mutex[2] try
task3 take mutex[1] failed
task3 gave mutex[2]
task4 take mutex[2] success
Expected behavior
The event item value should be set according to the inherited priority of the task.
And the event item of the task would be inserted in waiting list in a correct order when taking a mutex or semaphore.
Additional context
Test code:
FreeRTOS_kernel_test_for_RP2040 at branch vTaskPrioritySet_event_item_value_de
I also checked the unit test for vTaskPrioritySet(). It could be possible to add check for event item value for current test cases.
- Lenguaje dominante
- C
- Estrellas
- 4.6k
- Forks
- 1.6k
- Merge medio
- 2 d 22 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de FreeRTOS/FreeRTOS-Kernel
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
FreeRTOS/FreeRTOS-Kernel#1542 ·
Los mantenedores suelen responder en 3 días
-
[BUG] Release asset FreeRTOS-KernelV11.3.2.zip has the files of main, not of the tag V11.3.2Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
FreeRTOS/FreeRTOS-Kernel#1520 ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
FreeRTOS/FreeRTOS-Kernel#1494 · 3 comentarios ·
Los mantenedores suelen responder en 3 días
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
FreeRTOS/FreeRTOS-Kernel#1554 ·
Los mantenedores suelen responder en 3 días
-
[BUG] event_wait_timed can't return falsePosiblemente ocupada @TedLyngmo la tomó hace 39 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 38/100
FreeRTOS/FreeRTOS-Kernel#1546 ·
Los mantenedores suelen responder en 3 días
Todos los issues de FreeRTOS/FreeRTOS-Kernel
Issues similares
-
RecompLauncher supportAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
shinyquagsire23/OpenJKDF2#540 ·
Los mantenedores suelen responder en 12 días
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or signAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Life-Framework/Life-Framework#5939 ·
Los mantenedores suelen responder en 1 día
-
autoconf failes to find libsodium even when present due to implicit function declarationPosiblemente ocupada @coderjoe la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 13 días
-
SessionInterfaceHandler is throwing a deprecation notice as a warning instead of a deprecationAbiertoBug Status: Needs Triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
enhancement_package: a site operand of another JSON type raises TypeError, not a named refusalAbiertobug python
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
Jstar269/nakagawa-recomp#3521 ·
Los mantenedores suelen responder en 1 día