SensorTask and LoggerTask with initial priorities 2 and 1 respectively.loggerNewPriority and set it to 3.vTaskPrioritySet() to change LoggerTask priority to loggerNewPriority.SensorTask and LoggerTask with initial priorities 2 and 1 respectively.loggerNewPriority and set it to 3.vTaskPrioritySet() to change LoggerTask priority to loggerNewPriority.SensorTask and LoggerTask with initial priorities 2 and 1 respectively. Use xTaskCreate() to create both tasks and store their handles in variables sensorTaskHandle and loggerTaskHandle.Use xTaskCreate() with the correct task function, name, stack size, parameters, priority, and handle pointer.
loggerNewPriority and set it to 3.Declare int loggerNewPriority = 3; inside main() before starting the scheduler.
vTaskPrioritySet() to change the priority of LoggerTask to the value stored in loggerNewPriority. Place this call inside main() after creating the tasks and before starting the scheduler.Call vTaskPrioritySet(loggerTaskHandle, loggerNewPriority); inside main() after task creation.
uxTaskPriorityGet() to get the priorities of SensorTask and LoggerTask. Then print their priorities using printf(). Place this code inside main() after changing the LoggerTask priority and before starting the scheduler.Use uxTaskPriorityGet() to get priorities and printf() to display them.
What does the FreeRTOS function vTaskPrioritySet() do?
vTaskPrioritySet() is designed to change the priority of an existing task dynamically during runtime.vTaskPrioritySet().Which of the following is the correct syntax to change a task's priority using vTaskPrioritySet()?
TaskHandle_t xTaskHandle; // Change priority to 3 _____;
vTaskPrioritySet(TaskHandle_t xTask, UBaseType_t uxNewPriority), so the task handle comes first, then the new priority.Consider the following code snippet:
TaskHandle_t xTask1;
// Assume xTask1 is created with priority 2
vTaskPrioritySet(xTask1, 5);
UBaseType_t newPriority = uxTaskPriorityGet(xTask1);
printf("%u", newPriority);What will be printed?
vTaskPrioritySet(xTask1, 5) changes the task's priority from 2 to 5.uxTaskPriorityGet(xTask1) returns the current priority, which is now 5.What is wrong with this code snippet?
TaskHandle_t xTask2 = NULL; vTaskPrioritySet(xTask2, 4);
xTask2 is set to NULL, meaning it does not point to a valid task.vTaskPrioritySet() with a NULL handle leads to undefined behavior or runtime error because no valid task exists to change priority.You have two tasks: TaskA with priority 3 and TaskB with priority 5. You want TaskA to temporarily run with higher priority than TaskB during a critical section. Which code snippet correctly achieves this?
TaskHandle_t xTaskA, xTaskB; // Initially priorities: TaskA=3, TaskB=5 // Critical section starts _____; // Critical section ends vTaskPrioritySet(xTaskA, 3);
Pass the test and this pattern moves unknown