mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'bugfix/scheduling_time_test_overflow' into 'master'
bugfix/freertos: Fix accumulator overflow on scheduling time test See merge request espressif/esp-idf!8261
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
#include "soc/cpu.h"
|
#include "soc/cpu.h"
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
|
|
||||||
|
#define NUMBER_OF_ITERATIONS 10
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SemaphoreHandle_t end_sema;
|
SemaphoreHandle_t end_sema;
|
||||||
uint32_t before_sched;
|
uint32_t before_sched;
|
||||||
@@ -31,14 +33,18 @@ static void test_task_1(void *arg) {
|
|||||||
|
|
||||||
static void test_task_2(void *arg) {
|
static void test_task_2(void *arg) {
|
||||||
test_context_t *context = (test_context_t *)arg;
|
test_context_t *context = (test_context_t *)arg;
|
||||||
uint32_t accumulator = 0;
|
uint64_t accumulator = 0;
|
||||||
|
|
||||||
for(int i = 0; i < 10000; i++) {
|
vTaskPrioritySet(NULL, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
|
||||||
|
vTaskPrioritySet(context->t1_handle, CONFIG_UNITY_FREERTOS_PRIORITY + 1);
|
||||||
|
vPortYield();
|
||||||
|
|
||||||
|
for(int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
|
||||||
accumulator += (portGET_RUN_TIME_COUNTER_VALUE() - context->before_sched);
|
accumulator += (portGET_RUN_TIME_COUNTER_VALUE() - context->before_sched);
|
||||||
vPortYield();
|
vPortYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
context->cycles_to_sched = accumulator / 10000;
|
context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS;
|
||||||
vTaskDelete(context->t1_handle);
|
vTaskDelete(context->t1_handle);
|
||||||
xSemaphoreGive(context->end_sema);
|
xSemaphoreGive(context->end_sema);
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
@@ -55,8 +61,8 @@ TEST_CASE("scheduling time test", "[freertos]")
|
|||||||
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,1);
|
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,1);
|
||||||
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,1);
|
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,1);
|
||||||
#else
|
#else
|
||||||
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,0);
|
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle,0);
|
||||||
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,0);
|
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL,0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);
|
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);
|
||||||
|
@@ -92,5 +92,5 @@
|
|||||||
|
|
||||||
//time to perform the task selection plus context switch (from task)
|
//time to perform the task selection plus context switch (from task)
|
||||||
#ifndef IDF_PERFORMANCE_MAX_SCHEDULING_TIME
|
#ifndef IDF_PERFORMANCE_MAX_SCHEDULING_TIME
|
||||||
#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 1500
|
#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 2000
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user