Complete the code to set the priority of a FreeRTOS task.
vTaskPrioritySet([1], 3);
The function vTaskPrioritySet() requires the task handle as the first argument. Here, taskHandle is the correct variable representing the task.
Complete the code to increase the priority of a task by 1.
vTaskPrioritySet(taskHandle, [1] + 1);
The function uxTaskPriorityGet() returns the current priority of the task. Adding 1 increases the priority by one level.
Fix the error in setting the task priority dynamically.
int newPriority = [1];
vTaskPrioritySet(taskHandle, newPriority);To set a new priority, you must get the current priority using uxTaskPriorityGet() and then add 1. Other options use undefined variables or functions.
Fill both blanks to create a dictionary of task names and their priorities for tasks with priority greater than 2.
taskPriorities = { [1]: uxTaskPriorityGet([2]) for [1] in taskList if uxTaskPriorityGet([1]) > 2 }The variable task is used as the loop variable representing each task handle in taskList. We use it to get the priority and as the key in the dictionary.
Fill all three blanks to create a dictionary mapping task names to their priorities for tasks with priority above 1.
taskPriorityDict = { [1]: [2] for [3] in tasks if [2] > 1 }We loop over task in tasks. The key is task.name and the value is the priority obtained by uxTaskPriorityGet(task). The condition checks if priority is greater than 1.