freertos/test: fix overflow on accumulator used on scheduling time test

pull/5345/head
Felipe Neves 2020-04-03 16:57:57 -03:00 zatwierdzone przez bot
rodzic c5c026557e
commit 5847e0afd2
2 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -11,6 +11,8 @@
#include "soc/cpu.h"
#include "test_utils.h"
#define NUMBER_OF_ITERATIONS 10
typedef struct {
SemaphoreHandle_t end_sema;
uint32_t before_sched;
@ -31,14 +33,18 @@ static void test_task_1(void *arg) {
static void test_task_2(void *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);
vPortYield();
}
context->cycles_to_sched = accumulator / 10000;
context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS;
vTaskDelete(context->t1_handle);
xSemaphoreGive(context->end_sema);
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_2, "test2" , 4096, &context, 1, NULL,1);
#else
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle,0);
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, 1, NULL,0);
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, &context.t1_handle,0);
xTaskCreatePinnedToCore(test_task_2, "test2" , 4096, &context, CONFIG_UNITY_FREERTOS_PRIORITY - 1, NULL,0);
#endif
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);

Wyświetl plik

@ -92,5 +92,5 @@
//time to perform the task selection plus context switch (from task)
#ifndef IDF_PERFORMANCE_MAX_SCHEDULING_TIME
#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 1500
#define IDF_PERFORMANCE_MAX_SCHEDULING_TIME 2000
#endif