0
0
FreeRTOSprogramming~10 mins

Common RTOS bugs and debugging strategies 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 create a FreeRTOS task that runs the function taskFunction.

FreeRTOS
xTaskCreate([1], "Task1", 1000, NULL, 1, NULL);
Drag options to blanks, or click blank then click option'
AtaskFunction
BvTaskStartScheduler
CxQueueCreate
DvTaskDelay
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the scheduler start function instead of the task function.
2fill in blank
medium

Complete the code to delay a task for 500 milliseconds using FreeRTOS API.

FreeRTOS
vTaskDelay([1]);
Drag options to blanks, or click blank then click option'
ApdMS_TO_TICKS(500)
B500 * portTICK_PERIOD_MS
C500 / portTICK_PERIOD_MS
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw milliseconds instead of ticks.
3fill in blank
hard

Fix the error in the code that causes a deadlock when two tasks try to take the same mutex.

FreeRTOS
if(xSemaphoreTake([1], portMAX_DELAY) == pdTRUE) {
    // critical section
    xSemaphoreGive([1]);
}
Drag options to blanks, or click blank then click option'
AtaskHandle
Bqueue1
Cmutex1
Dtimer1
Attempts:
3 left
💡 Hint
Common Mistakes
Using different handles for take and give.
Using a queue handle instead of a mutex.
4fill in blank
hard

Fill both blanks to correctly check if a queue is full before sending data.

FreeRTOS
if(uxQueueSpacesAvailable([1]) [2] 0) {
    xQueueSend([1], &data, 0);
}
Drag options to blanks, or click blank then click option'
AqueueHandle
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using different queue handles.
Checking if spaces equal zero instead of greater than zero.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps task names to their stack high water marks if the mark is less than 100.

FreeRTOS
{ [1]: [2] for [1] in tasks if uxTaskGetStackHighWaterMark([1]) [3] 100 }
Drag options to blanks, or click blank then click option'
Atask
BuxTaskGetStackHighWaterMark(task)
C<
Dtask.name
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and iteration.
Using wrong comparison operators.