ClientTask sends a message with command=1 and data=5 to the resourceQueue.
Step 2: Analyze ResourceManagerTask processing
ResourceManagerTask receives the message, checks command==1, then prints data*2 = 5*2 = 10.
Final Answer:
Processed data: 10 -> Option B
Quick Check:
Data 5 doubled = 10 output [OK]
Hint: Multiply data by 2 when command is 1 [OK]
Common Mistakes:
Confusing data value with output
Assuming no message received
Ignoring the multiplication by 2
4. Identify the bug in this Resource Manager Task code snippet:
void ResourceManagerTask(void *params) {
RequestMessage req;
while (1) {
if (xQueueReceive(resourceQueue, &req, 0) == pdPASS) {
if (req.command == 1) {
// Process command
}
}
}
}
What is the problem?
medium
A. xQueueReceive should not be used in Resource Manager Task
B. RequestMessage struct is not defined
C. ResourceManagerTask should not use a while loop
D. Using zero block time causes missed messages if queue is empty
Solution
Step 1: Understand xQueueReceive block time
Using 0 as block time means the call returns immediately if queue is empty, possibly missing messages.
Step 2: Effect on Resource Manager Task
The task may spin without waiting, causing high CPU usage and missed processing.
Final Answer:
Using zero block time causes missed messages if queue is empty -> Option D
Quick Check:
Zero block time = possible missed messages [OK]
Hint: Use portMAX_DELAY to wait for messages in resource manager [OK]
Common Mistakes:
Ignoring block time effect
Thinking struct is undefined
Believing while loop is wrong
5. You want to design a Resource Manager Task that handles multiple resource types (e.g., UART, SPI) with different commands. Which approach best applies the Resource Manager Task Pattern to handle this efficiently?
hard
A. Create separate manager tasks for each resource type and let clients send requests directly to each
B. Let clients access resources directly with mutexes protecting each resource
C. Use a single queue with a message struct containing resource type and command fields, then switch-case inside the manager task
D. Use global variables to store resource states and update them without task communication
Solution
Step 1: Consider centralized control for multiple resources
A single Resource Manager Task can handle multiple resource types by differentiating requests.
Step 2: Use message struct with resource type and command
This allows the manager task to use a switch-case to process requests efficiently and safely.
Final Answer:
Use a single queue with a message struct containing resource type and command fields, then switch-case inside the manager task -> Option C
Quick Check:
Single queue + message struct = efficient multi-resource management [OK]
Hint: Use message struct with resource type and switch-case in manager [OK]
Common Mistakes:
Creating multiple manager tasks unnecessarily
Allowing direct resource access with mutexes
Using global variables without communication
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.