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

feat(freertos): make num of task notifications configurable

Closes https://github.com/espressif/esp-idf/issues/9349
Jakob Hasse 3 лет назад
Родитель
Сommit
73d9d83a2f

+ 1 - 1
components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/include/freertos/FreeRTOSConfig_smp.h

@@ -129,7 +129,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
 #define configUSE_QUEUE_SETS                            1
 #define configQUEUE_REGISTRY_SIZE                       CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
 #define configUSE_TASK_NOTIFICATIONS                    1
-#define configTASK_NOTIFICATION_ARRAY_ENTRIES           1
+#define configTASK_NOTIFICATION_ARRAY_ENTRIES           CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
 
 // ----------------------- System --------------------------
 

+ 1 - 1
components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/include/freertos/FreeRTOSConfig_smp.h

@@ -158,7 +158,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
 #define configUSE_QUEUE_SETS                            1
 #define configQUEUE_REGISTRY_SIZE                       CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
 #define configUSE_TASK_NOTIFICATIONS                    1
-#define configTASK_NOTIFICATION_ARRAY_ENTRIES           1
+#define configTASK_NOTIFICATION_ARRAY_ENTRIES           CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
 
 // ----------------------- System --------------------------
 

+ 10 - 0
components/freertos/Kconfig

@@ -190,6 +190,16 @@ menu "FreeRTOS"
 
                 Note: A value of 0 will disable queue registry functionality
 
+        config FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
+            int "configTASK_NOTIFICATION_ARRAY_ENTRIES"
+            range 1 32
+            default 1
+            help
+                Set the size of the task notification array of each task. When increasing this value, keep in
+                mind that this means additional memory for each and every task on the system.
+                However, task notifications in general are more light weight compared to alternatives
+                such as semaphores.
+
         config FREERTOS_USE_TRACE_FACILITY
             bool "configUSE_TRACE_FACILITY"
             default n

+ 1 - 1
components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h

@@ -126,7 +126,7 @@ This file get's pulled into assembly sources. Therefore, some includes need to b
 #define configUSE_QUEUE_SETS                            1
 #define configQUEUE_REGISTRY_SIZE                       CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
 #define configUSE_TASK_NOTIFICATIONS                    1
-#define configTASK_NOTIFICATION_ARRAY_ENTRIES           1
+#define configTASK_NOTIFICATION_ARRAY_ENTRIES           CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
 
 // ----------------------- System --------------------------
 

+ 41 - 0
components/freertos/test_apps/freertos/kernel/tasks/test_freertos_task_notify.c

@@ -196,3 +196,44 @@ TEST_CASE("Test Task_Notify", "[freertos]")
         TEST_ESP_OK(gptimer_del_timer(gptimers[i]));
     }
 }
+
+TEST_CASE("Notify too high index fails", "[ignore]")
+{
+    uint32_t notification_value = 47;
+    xTaskNotifyIndexed(xTaskGetCurrentTaskHandle(), 2, notification_value, eNoAction);
+}
+
+TEST_CASE("Notify Wait too high index fails", "[ignore]")
+{
+    uint32_t notification_value;
+    xTaskNotifyWaitIndexed(2, 0, 0, &notification_value, pdMS_TO_TICKS(10));
+}
+
+#if CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES > 1
+const uint32_t NOTIFICATION_VALUE_0 = 47;
+const uint32_t NOTIFICATION_VALUE_1 = 48;
+
+void notify(void *arg)
+{
+    TaskHandle_t main_task = (TaskHandle_t) arg;
+    xTaskNotifyIndexed(main_task, 0, NOTIFICATION_VALUE_0, eSetValueWithOverwrite);
+    xTaskNotifyIndexed(main_task, 1, NOTIFICATION_VALUE_1, eSetValueWithOverwrite);
+    vTaskDelete(NULL);
+}
+static TaskHandle_t notificator_task;
+
+TEST_CASE("Notify to different indexes works", "[freertos]")
+{
+    uint32_t notification_value_0 = 0;
+    uint32_t notification_value_1 = 0;
+
+    TaskHandle_t main_task = xTaskGetCurrentTaskHandle();
+    xTaskCreate(notify, "notificator", 2048, main_task, 2, &notificator_task);
+
+    xTaskNotifyWaitIndexed(0, 0, 0xFFFFFFFF, &notification_value_0, pdMS_TO_TICKS(10));
+    xTaskNotifyWaitIndexed(1, 0, 0xFFFFFFFF, &notification_value_1, pdMS_TO_TICKS(10));
+
+    TEST_ASSERT_EQUAL(notification_value_0, NOTIFICATION_VALUE_0);
+    TEST_ASSERT_EQUAL(notification_value_1, NOTIFICATION_VALUE_1);
+}
+#endif

+ 22 - 0
components/freertos/test_apps/freertos/pytest_freertos.py

@@ -21,3 +21,25 @@ def test_freertos(dut: Dut) -> None:
     dut.write('![ignore]')
     # All of the FreeRTOS tests combined take > 60s to run. So we use a 120s timeout
     dut.expect_unity_test_output(timeout=120)
+
+
+@pytest.mark.supported_targets
+@pytest.mark.generic
+@pytest.mark.parametrize('config', ['freertos_options'], indirect=True)
+def test_task_notify_too_high_index_fails(dut: Dut) -> None:
+    dut.expect_exact('Press ENTER to see the list of tests.')
+    dut.write('\"Notify too high index fails\"')
+    dut.expect('assert failed: xTaskGenericNotify', timeout=5)
+    dut.expect('uxIndexToNotify < [0-9]+')
+    dut.expect_exact('Rebooting...')
+
+
+@pytest.mark.supported_targets
+@pytest.mark.generic
+@pytest.mark.parametrize('config', ['freertos_options'], indirect=True)
+def test_task_notify_wait_too_high_index_fails(dut: Dut) -> None:
+    dut.expect_exact('Press ENTER to see the list of tests.')
+    dut.write('\"Notify Wait too high index fails\"')
+    dut.expect('assert failed: xTaskGenericNotifyWait', timeout=5)
+    dut.expect('uxIndexToWait < [0-9]+', timeout=5)
+    dut.expect_exact('Rebooting...')

+ 1 - 0
components/freertos/test_apps/freertos/sdkconfig.ci.freertos_options

@@ -16,3 +16,4 @@ CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y
 CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
 CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
 CONFIG_FREERTOS_FPU_IN_ISR=y
+CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=2

+ 10 - 0
tools/mocks/freertos/Kconfig

@@ -18,5 +18,15 @@ menu "FreeRTOS"
                 more details).
 
                 Note: For most uses, the default of 16 characters is sufficient.
+
+        config FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES
+            int "configTASK_NOTIFICATION_ARRAY_ENTRIES"
+            range 1 32
+            default 1
+            help
+                Set the size of the task notification array of each task. When increasing this value, keep in
+                mind that this means additional memory for each and every task on the system.
+                However, task notifications in general are more light weight compared to alternatives
+                such as semaphores.
     endmenu
 endmenu