0
0
FreeRTOSprogramming~10 mins

xTaskNotifyGive() as lightweight semaphore in FreeRTOS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to notify a task using xTaskNotifyGive().

FreeRTOS
xTaskNotifyGive([1]);
Drag options to blanks, or click blank then click option'
AxTaskHandle
BxQueue
CxSemaphore
DxTaskToNotify
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a semaphore or queue handle instead of a task handle.
Using an undefined variable as the task handle.
2fill in blank
medium

Complete the code to wait for a notification as a lightweight semaphore using ulTaskNotifyTake().

FreeRTOS
ulTaskNotifyTake([1], portMAX_DELAY);
Drag options to blanks, or click blank then click option'
A0
BpdTRUE
CpdFALSE
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Passing pdTRUE which clears the count immediately.
Passing numeric values like 0 or 1 instead of pdFALSE or pdTRUE.
3fill in blank
hard

Fix the error in the code to correctly use xTaskNotifyGive() as a semaphore signal.

FreeRTOS
void signalTask() {
    xTaskNotifyGive([1]);
}
Drag options to blanks, or click blank then click option'
AxTaskToNotify
BxTaskHandle
CNULL
DxSemaphore
Attempts:
3 left
💡 Hint
Common Mistakes
Passing NULL which causes no task to be notified.
Passing a semaphore handle instead of a task handle.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps task names to their notification counts if count is greater than zero.

FreeRTOS
taskNotifyCounts = {taskName: [1] for taskName, count in taskCounts.items() if count [2] 0}
Drag options to blanks, or click blank then click option'
Acount
B==
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality (==) instead of greater than (>) in the condition.
Mapping to taskName instead of count.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase task names to their counts if count is less than 5.

FreeRTOS
filteredCounts = [1]: [2] for task, count in counts.items() if count [3] 5}
Drag options to blanks, or click blank then click option'
Atask.upper()
Bcount
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using greater than (>) instead of less than (<) in the condition.
Mapping task names without converting to uppercase.