What does the 'FromISR' suffix in FreeRTOS API functions indicate?
It indicates that the function is safe to call from an Interrupt Service Routine (ISR). These functions are designed to be used in interrupt context without causing issues like blocking or priority inversion.
Click to reveal answer
beginner
Why can't regular FreeRTOS API functions be called directly from an ISR?
Regular FreeRTOS API functions may block or use operations that are not safe in interrupt context, such as waiting for a resource. ISRs must be fast and non-blocking, so special 'FromISR' versions are provided to be safe in ISRs.
Click to reveal answer
intermediate
How do 'FromISR' functions handle task switching differently?
They use a pointer parameter to indicate if a context switch should happen after the ISR completes. This allows the kernel to defer the switch safely until after the interrupt, maintaining system stability.
Click to reveal answer
beginner
Give an example of a FreeRTOS API function and its ISR-safe counterpart.
Example: xQueueSend() is the regular function to send to a queue. Its ISR-safe counterpart is xQueueSendFromISR(), which can be safely called inside an ISR.
Click to reveal answer
intermediate
What is the purpose of the 'pxHigherPriorityTaskWoken' parameter in 'FromISR' functions?
It is a pointer to a variable that the function sets to pdTRUE if calling the function caused a higher priority task to become ready to run. This informs the ISR that a context switch should be requested after the ISR finishes.
Click to reveal answer
What is the main reason to use 'FromISR' functions in FreeRTOS?
AThey are safe to call inside Interrupt Service Routines.
BThey run faster than regular functions.
CThey allocate more memory.
DThey block until a resource is available.
✗ Incorrect
FromISR functions are specifically designed to be safe when called inside ISRs, avoiding blocking and unsafe operations.
Which parameter in 'FromISR' functions helps decide if a context switch is needed?
ApxHigherPriorityTaskWoken
BxQueueHandle
CxTicksToWait
DpvParameters
✗ Incorrect
The pxHigherPriorityTaskWoken pointer is set by the function to indicate if a higher priority task was woken.
Can you call xQueueSend() directly inside an ISR?
AYes, always.
BOnly if interrupts are disabled.
CNo, use xQueueSendFromISR() instead.
DOnly if the queue is empty.
✗ Incorrect
xQueueSend() is not safe in ISRs; the FromISR version must be used.
What happens if a 'FromISR' function sets pxHigherPriorityTaskWoken to pdTRUE?
ANothing happens.
BThe ISR must request a context switch after it finishes.
CThe ISR disables interrupts.
DThe system crashes.
✗ Incorrect
Setting pxHigherPriorityTaskWoken to pdTRUE signals that a higher priority task is ready and a context switch should occur.
Which of these is NOT true about 'FromISR' functions?
AThey never block.
BThey can be called from normal tasks.
CThey use special parameters for context switching.
DThey are unsafe in ISRs.
✗ Incorrect
'FromISR' functions are specifically designed to be safe in ISRs.
Explain why FreeRTOS provides 'FromISR' versions of API functions and how they differ from regular API calls.
Think about what makes interrupt routines special and how these functions avoid problems.
You got /4 concepts.
Describe the role of the pxHigherPriorityTaskWoken parameter in ISR-safe FreeRTOS API functions.
Consider how FreeRTOS decides when to switch tasks after an interrupt.
You got /4 concepts.
Practice
(1/5)
1.
What is the main reason to use FreeRTOS API functions with the FromISR suffix inside an interrupt service routine (ISR)?
easy
A. They disable all interrupts during execution.
B. They are safe to call from ISRs and handle interrupt context correctly.
C. They run tasks faster than normal API functions.
D. They automatically create new tasks inside the ISR.
Solution
Step 1: Understand ISR context constraints
Inside an ISR, normal FreeRTOS API functions are unsafe because they may block or cause race conditions.
Step 2: Role of FromISR functions
Functions with the FromISR suffix are designed to be safe in interrupt context by avoiding blocking and managing critical sections properly.
Final Answer:
They are safe to call from ISRs and handle interrupt context correctly. -> Option B
Quick Check:
FromISR functions = ISR safe calls [OK]
Hint: Use FromISR functions only inside interrupts for safety [OK]
Common Mistakes:
Calling normal API functions inside ISR causing crashes
Assuming FromISR functions disable interrupts
Thinking FromISR creates tasks automatically
2.
Which of the following is the correct way to declare a variable to track if a higher priority task was woken inside an ISR?
?
easy
A. int higherPriorityTaskWoken = 0;
B. bool higherPriorityTaskWoken = false;
C. BaseType_t higherPriorityTaskWoken = pdFALSE;
D. volatile int higherPriorityTaskWoken = 1;
Solution
Step 1: Identify FreeRTOS type for ISR task wake flag
FreeRTOS uses BaseType_t for portability and defines pdFALSE and pdTRUE for boolean values.
Step 2: Correct initialization
The variable must start as pdFALSE to indicate no task was woken yet.
Final Answer:
BaseType_t higherPriorityTaskWoken = pdFALSE; -> Option C
Quick Check:
Use BaseType_t and pdFALSE for ISR flags [OK]
Hint: Use BaseType_t and pdFALSE to track task wake in ISR [OK]
A. The variable higherPriorityTaskWoken should be global.
B. The semaphore is given twice causing overflow.
C. The portYIELD_FROM_ISR() call is outside the ISR.
D. The higherPriorityTaskWoken variable is not passed to xSemaphoreGiveFromISR.
Solution
Step 1: Check function used for semaphore give
The code uses xSemaphoreGive, which is not safe inside ISR context.
Step 2: Correct ISR-safe function usage
Inside ISR, xSemaphoreGiveFromISR must be used with higherPriorityTaskWoken passed by reference to track task wake.
Final Answer:
The higherPriorityTaskWoken variable is not passed to xSemaphoreGiveFromISR. -> Option D
Quick Check:
Use FromISR functions with higherPriorityTaskWoken [OK]
Hint: Always pass higherPriorityTaskWoken to FromISR functions [OK]
Common Mistakes:
Using normal API functions inside ISR
Not passing higherPriorityTaskWoken pointer
Declaring higherPriorityTaskWoken as global unnecessarily
5.
You want to send data from an ISR to a task using a queue. Which sequence correctly uses FreeRTOS ISR-safe API functions to do this and ensure the higher priority task runs immediately if woken?
?
hard
A. BaseType_t higherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(queue, &data, &higherPriorityTaskWoken);
if (higherPriorityTaskWoken) portYIELD_FROM_ISR();
B. xQueueSend(queue, &data, 0);
BaseType_t higherPriorityTaskWoken = pdFALSE;
if (higherPriorityTaskWoken) portYIELD_FROM_ISR();
C. BaseType_t higherPriorityTaskWoken = pdTRUE;
xQueueSendFromISR(queue, &data, NULL);
portYIELD_FROM_ISR();
D. BaseType_t higherPriorityTaskWoken = pdFALSE;
xQueueSend(queue, &data, 0);
portYIELD_FROM_ISR();
Solution
Step 1: Use ISR-safe queue send function
Inside ISR, xQueueSendFromISR must be used with a pointer to higherPriorityTaskWoken.
Step 2: Check higherPriorityTaskWoken and yield
If higherPriorityTaskWoken is set to pdTRUE, call portYIELD_FROM_ISR() to request immediate context switch.
Final Answer:
BaseType_t higherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(queue, &data, &higherPriorityTaskWoken);
if (higherPriorityTaskWoken) portYIELD_FROM_ISR(); -> Option A
Quick Check:
Use FromISR + check flag + yield [OK]
Hint: Use xQueueSendFromISR with flag and yield if true [OK]
Common Mistakes:
Using normal xQueueSend inside ISR
Not passing higherPriorityTaskWoken pointer
Calling portYIELD_FROM_ISR unconditionally
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.