Bird
0
0

Consider this code snippet:

medium📝 Predict Output Q4 of 15
FreeRTOS - Design Patterns for RTOS
Consider this code snippet:
EventGroupHandle_t xEventGroup = xEventGroupCreate();
xEventGroupSetBits(xEventGroup, 0x01);
EventBits_t bits = xEventGroupWaitBits(xEventGroup, 0x01, pdTRUE, pdFALSE, portMAX_DELAY);

What is the value of bits after execution?
A0xFF
B0x00
C0x01
DUndefined
Step-by-Step Solution
Solution:
  1. Step 1: Analyze event bits set and wait parameters

    The bit 0x01 is set before waiting. The wait clears bits after return (pdTRUE).
  2. Step 2: Determine returned bits value

    The function returns the bits that were set before clearing. So bits = 0x01.
  3. Final Answer:

    0x01 -> Option C
  4. Quick Check:

    Returned bits = bits set before clearing [OK]
Quick Trick: WaitBits returns bits set before clearing if clear on exit is true [OK]
Common Mistakes:
  • Assuming bits cleared before return
  • Expecting zero after clearing bits
  • Confusing return value with current bits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes