The tick timer generates regular interrupts at a fixed frequency. These interrupts allow FreeRTOS to keep track of time and manage task switching.
Click to reveal answer
beginner
How does the FreeRTOS scheduler decide which task to run next?
The scheduler selects the highest priority task that is ready to run. If multiple tasks have the same priority, it uses time slicing or round-robin to share CPU time.
Click to reveal answer
intermediate
What happens during a tick interrupt in FreeRTOS?
During a tick interrupt, FreeRTOS updates its internal tick count and checks if any tasks need to be switched based on their state and priority.
Click to reveal answer
intermediate
Why is the tick rate important in FreeRTOS?
The tick rate determines how often the scheduler runs and how precise timing functions are. A higher tick rate means more frequent task switching but more CPU overhead.
Click to reveal answer
intermediate
Explain the difference between preemptive and cooperative scheduling in FreeRTOS.
Preemptive scheduling allows the scheduler to interrupt a running task to switch to a higher priority task. Cooperative scheduling requires tasks to yield control voluntarily.
Click to reveal answer
What triggers the FreeRTOS scheduler to run?
AA button press
BA tick timer interrupt
CA network packet arrival
DA manual function call only
✗ Incorrect
The tick timer interrupt triggers the scheduler to check if a task switch is needed.
What does the tick timer frequency affect?
AThe CPU clock speed
BThe size of the memory
CThe number of tasks allowed
DHow often tasks can be switched
✗ Incorrect
The tick timer frequency controls how often the scheduler runs and can switch tasks.
In preemptive scheduling, when can a task be interrupted?
AOnly when it finishes
BOnly when it yields
CWhen a higher priority task becomes ready
DNever
✗ Incorrect
Preemptive scheduling allows interruption when a higher priority task is ready.
What is the main purpose of the FreeRTOS scheduler?
ATo decide which task runs and when
BTo manage memory allocation
CTo handle input/output devices
DTo compile code
✗ Incorrect
The scheduler manages task execution order based on priority and readiness.
What happens if the tick rate is set too high?
ACPU overhead increases due to frequent interrupts
BTasks run slower
CMemory usage decreases
DScheduler stops working
✗ Incorrect
A very high tick rate causes more CPU time spent handling interrupts, reducing efficiency.
Describe how the tick timer and scheduler work together in FreeRTOS to manage tasks.
Think about what happens every time the tick timer interrupts.
You got /4 concepts.
Explain the difference between preemptive and cooperative scheduling in FreeRTOS and how the tick timer affects them.
Consider how tasks lose control in each scheduling type.
You got /4 concepts.
Practice
(1/5)
1. What is the main role of the tick timer in FreeRTOS?
easy
A. To handle input/output operations
B. To store task priorities
C. To allocate memory for tasks
D. To count time in small steps called ticks
Solution
Step 1: Understand tick timer function
The tick timer counts time in small units called ticks, which are the basic time measurement in FreeRTOS.
Step 2: Differentiate from other functions
Other options like storing priorities or handling I/O are not related to the tick timer's role.
Final Answer:
To count time in small steps called ticks -> Option D
Quick Check:
Tick timer = counts ticks [OK]
Hint: Tick timer counts time steps, not priorities or memory [OK]
Common Mistakes:
Confusing tick timer with task priority management
Thinking tick timer handles memory or I/O
Mixing tick timer with scheduler directly
2. Which of the following is the correct way to delay a task for 100 ticks in FreeRTOS?
easy
A. xTaskDelay(100);
B. vTaskDelay(1000);
C. vTaskDelay(100);
D. delayTask(100);
Solution
Step 1: Identify correct function name
The correct FreeRTOS function to delay a task is vTaskDelay().
Step 2: Check parameter correctness
The parameter is the number of ticks to delay. For 100 ticks, vTaskDelay(100); is correct.
Final Answer:
vTaskDelay(100); -> Option C
Quick Check:
Delay task = vTaskDelay(ticks) [OK]
Hint: Use vTaskDelay with tick count to pause tasks [OK]
Common Mistakes:
Using wrong function name like xTaskDelay or delayTask
Passing milliseconds instead of ticks
Using too large or incorrect delay values
3. Consider this code snippet in FreeRTOS:
TickType_t start = xTaskGetTickCount();
vTaskDelay(50);
TickType_t end = xTaskGetTickCount();
TickType_t diff = end - start;
What is the expected value of diff?
medium
A. 0
B. 50
C. 100
D. Depends on task priority
Solution
Step 1: Understand xTaskGetTickCount()
This function returns the current tick count since the scheduler started.
Step 2: Analyze vTaskDelay(50)
The task delays itself for 50 ticks, so the tick count advances by 50 during the delay.
Step 3: Calculate difference
Subtracting start from end gives the delay duration, which should be 50 ticks.
Final Answer:
50 -> Option B
Quick Check:
Delay ticks = 50 [OK]
Hint: Delay of 50 ticks means tick count difference is 50 [OK]