What is the main purpose of task priorities in FreeRTOS?
Task priorities determine the order in which tasks are scheduled to run. Higher priority tasks run before lower priority ones, ensuring critical tasks get CPU time first.
Click to reveal answer
beginner
Why should you avoid giving all tasks the same priority in a real application?
If all tasks have the same priority, the scheduler switches between them in a round-robin way, which may cause important tasks to wait too long and miss deadlines.
Click to reveal answer
intermediate
How does priority inversion affect real-time applications?
Priority inversion happens when a low priority task holds a resource needed by a high priority task, causing the high priority task to wait and potentially miss deadlines.
Click to reveal answer
intermediate
What is a common method to prevent priority inversion in FreeRTOS?
FreeRTOS uses priority inheritance, where the low priority task temporarily inherits the higher priority to finish its work and release the resource faster.
Click to reveal answer
beginner
How should you assign priorities when tasks have different timing requirements?
Assign higher priorities to tasks with stricter timing or deadlines, and lower priorities to less critical or background tasks to ensure timely execution.
Click to reveal answer
In FreeRTOS, which task will run first?
AThe task with the longest runtime
BThe task created first
CThe task with the lowest priority
DThe task with the highest priority
✗ Incorrect
FreeRTOS always runs the task with the highest priority that is ready to run.
What happens if two tasks have the same priority in FreeRTOS?
AThey run in round-robin fashion
BThey run simultaneously
COnly one runs forever
DThe system crashes
✗ Incorrect
Tasks with the same priority share CPU time equally using round-robin scheduling.
Which problem occurs when a low priority task blocks a high priority task?
ADeadlock
BRace condition
CPriority inversion
DStarvation
✗ Incorrect
Priority inversion happens when a low priority task holds a resource needed by a high priority task.
How does FreeRTOS handle priority inversion?
ABy priority inheritance
BBy ignoring it
CBy killing the low priority task
DBy increasing system clock speed
✗ Incorrect
FreeRTOS uses priority inheritance to temporarily raise the low priority task's priority.
Which task should get the highest priority?
AThe task with the least work
BThe task with the strictest timing requirements
CThe task that runs longest
DThe task created last
✗ Incorrect
Tasks with strict timing or deadlines should have higher priority to meet real-time constraints.
Explain how to choose task priorities in a real FreeRTOS application.
Think about which tasks need to run first and which can wait.
You got /4 concepts.
Describe what priority inversion is and how FreeRTOS solves it.
Imagine a slow worker holding a tool needed by a fast worker.
You got /4 concepts.
Practice
(1/5)
1. In FreeRTOS, what does a higher task priority number mean?
easy
A. The task runs before lower priority tasks
B. The task uses less memory
C. The task runs slower
D. The task is paused
Solution
Step 1: Understand task priority meaning
In FreeRTOS, task priority determines which task the scheduler runs first.
Step 2: Higher number means higher priority
A higher priority number means the task is more important and runs before lower priority tasks.
Final Answer:
The task runs before lower priority tasks -> Option A
Quick Check:
Higher priority = runs first [OK]
Hint: Higher number means task runs first [OK]
Common Mistakes:
Thinking higher priority means slower task
Confusing priority with memory usage
Assuming priority pauses the task
2. Which of the following is the correct way to set a task priority in FreeRTOS?
easy
A. xTaskCreate(taskFunction, "Task", stackSize, NULL, -1, NULL);
B. xTaskCreate(taskFunction, "Task", stackSize, NULL, "high", NULL);
C. xTaskCreate(taskFunction, "Task", stackSize, NULL, 5, NULL);
D. xTaskCreate(taskFunction, "Task", stackSize, NULL, 0.5, NULL);
Solution
Step 1: Check parameter for priority in xTaskCreate
The fifth parameter in xTaskCreate is the task priority and must be an integer.