mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 17:08:49 +00:00
components/freertos: using the optimized task selection on esp32s2beta
components/freertos: cleaned up multicore option scheduler. components/freertos: more cleanup and test optimization to present realistic results components/freertos: remove unused macros of optimized task selection when multicore is used
This commit is contained in:
@@ -12,16 +12,16 @@
|
||||
#include "test_utils.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t noof_runs;
|
||||
SemaphoreHandle_t end_sema;
|
||||
uint32_t before_sched;
|
||||
uint32_t cycles_to_sched;
|
||||
TaskHandle_t t1_handle;
|
||||
} test_context_t;
|
||||
|
||||
static void test_task_1(void *arg) {
|
||||
test_context_t *context = (test_context_t *)arg;
|
||||
|
||||
for(context->noof_runs = 0 ;context->noof_runs < 10000; ) {
|
||||
for( ;; ) {
|
||||
context->before_sched = portGET_RUN_TIME_COUNTER_VALUE();
|
||||
vPortYield();
|
||||
}
|
||||
@@ -31,13 +31,15 @@ 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;
|
||||
|
||||
for( ; context->noof_runs < 10000; context->noof_runs++) {
|
||||
context->cycles_to_sched += (portGET_RUN_TIME_COUNTER_VALUE() - context->before_sched);
|
||||
for(int i = 0; i < 10000; i++) {
|
||||
accumulator += (portGET_RUN_TIME_COUNTER_VALUE() - context->before_sched);
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
context->cycles_to_sched /= 10000;
|
||||
context->cycles_to_sched = accumulator / 10000;
|
||||
vTaskDelete(context->t1_handle);
|
||||
xSemaphoreGive(context->end_sema);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
@@ -49,8 +51,13 @@ TEST_CASE("scheduling time test", "[freertos]")
|
||||
context.end_sema = xSemaphoreCreateBinary();
|
||||
TEST_ASSERT(context.end_sema != NULL);
|
||||
|
||||
xTaskCreatePinnedToCore(test_task_1, "test1" , 4096, &context, 1, NULL,1);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
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);
|
||||
#endif
|
||||
|
||||
BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY);
|
||||
TEST_ASSERT_EQUAL_HEX32(pdTRUE, result);
|
||||
|
||||
Reference in New Issue
Block a user