Failed to change FreeRTOS task priority.
Posted: Wed Jun 27, 2018 12:18 pm
Hey guys,
I've tested the changing task priority during running board.
The expected result is print out "Task1 is running' and "Task2 is running" alternately.
But actual result is print out only "Task1 is running" so it looks to fail to change the priory of task.
Below is my test code that came from FreeRTOS book, please check this code and let me know there is a problem on changing priority.
I've tested the changing task priority during running board.
The expected result is print out "Task1 is running' and "Task2 is running" alternately.
But actual result is print out only "Task1 is running" so it looks to fail to change the priory of task.
Below is my test code that came from FreeRTOS book, please check this code and let me know there is a problem on changing priority.
Code: Select all
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "esp_system.h"
#include "esp_event.h"
static TaskHandle_t task2Handle = NULL;
static void vTask1(void *pvParameters) {
UBaseType_t uxPriority;
uxPriority = uxTaskPriorityGet(NULL);
for (;;) {
printf("Task 1 is running with %d priority\r\n", uxPriority);
printf("\tAbout to raise the Task 2 priority %p\r\n", task2Handle);
vTaskPrioritySet(task2Handle, (uxPriority + 1));
}
}
static void vTask2(void *pvParameters) {
UBaseType_t uxPriority;
uxPriority = uxTaskPriorityGet(NULL);
for (;;) {
printf("Task 2 is running with %d priority\r\n", uxPriority);
printf("\tAbout to lower the Task 2 priority\r\n");
vTaskPrioritySet(NULL, (uxPriority - 2));
}
}
static void Test_Task(void) {
xTaskCreatePinnedToCore(&vTask1, "Task 1", 2048, NULL, 2, NULL, PRO_CPU_NUM);
xTaskCreatePinnedToCore(&vTask2, "Task 2", 2048, NULL, 1, &task2Handle, PRO_CPU_NUM);
vTaskStartScheduler();
}
void app_main(void) {
Test_Task();
}