Which of the following is the correct way to check a shutdown flag inside a FreeRTOS task loop?
easy📝 Syntax Q3 of 15
FreeRTOS - Design Patterns for RTOS
Which of the following is the correct way to check a shutdown flag inside a FreeRTOS task loop?
Aif (shutdownFlag == true) { /* cleanup */ }
Bif shutdownFlag = true { /* cleanup */ }
Cif (shutdownFlag = true) { /* cleanup */ }
Dif shutdownFlag == true then { /* cleanup */ }
Step-by-Step Solution
Solution:
Step 1: Review correct C syntax for conditionals
Conditions require parentheses and double equals for comparison.
Step 2: Identify syntax errors in options
"if (shutdownFlag == true) { /* cleanup */ }" uses correct syntax. The others have errors: missing parentheses around the condition, using single '=' (assignment) instead of '==' (comparison), or invalid keywords like 'then'.
Final Answer:
if (shutdownFlag == true) { /* cleanup */ } -> Option A