0
0
FreeRTOSprogramming~20 mins

vTaskDelete() for task removal in FreeRTOS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FreeRTOS Task Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What happens after calling vTaskDelete() on a running task?

Consider a FreeRTOS task that calls vTaskDelete(NULL); inside its own function. What is the expected behavior?

FreeRTOS
void TaskFunction(void *pvParameters) {
    // Task code here
    vTaskDelete(NULL);
    // Code here will not run
}
AThe system crashes due to invalid task deletion.
BThe task pauses but can be resumed later.
CThe task continues running after the call.
DThe task deletes itself and stops running immediately.
Attempts:
2 left
💡 Hint

Think about what NULL means when passed to vTaskDelete().

🧠 Conceptual
intermediate
2:00remaining
Which task handle should be passed to vTaskDelete() to remove a specific task?

You want to delete a task other than the currently running one. Which value should you pass to vTaskDelete()?

AThe handle of the task you want to delete.
BAlways <code>NULL</code> to delete the current task.
CThe priority of the task you want to delete.
DThe task's name as a string.
Attempts:
2 left
💡 Hint

Think about how FreeRTOS identifies tasks internally.

🔧 Debug
advanced
2:00remaining
Why does this code cause a runtime error when deleting a task?

Examine the code below. Why does calling vTaskDelete(taskHandle); cause a runtime error?

FreeRTOS
TaskHandle_t taskHandle;

void Task1(void *pvParameters) {
    // Task code
    vTaskDelete(taskHandle);
}

void setup() {
    xTaskCreate(Task1, "Task1", 1000, NULL, 1, &taskHandle);
}
AvTaskDelete cannot delete tasks created with xTaskCreate.
BThe handle is used before the task is created and assigned.
CThe task deletes itself before the handle is assigned.
DThe task priority is too low to allow deletion.
Attempts:
2 left
💡 Hint

Check when taskHandle is assigned relative to its use.

📝 Syntax
advanced
2:00remaining
Which option correctly deletes a task named myTask?

Given a task handle myTask, which code snippet correctly deletes the task?

AvTaskDelete(myTask);
BvTaskDelete(NULL);
CvTaskDelete(*myTask);
DvTaskDelete(&myTask);
Attempts:
2 left
💡 Hint

Remember the type expected by vTaskDelete().

🚀 Application
expert
3:00remaining
What is the effect of deleting a task that is currently blocked on a queue?

A task is blocked waiting for data on a queue. If vTaskDelete() is called on this task, what happens?

AThe system deadlocks because the task is blocked.
BThe queue is deleted along with the task.
CThe task is removed immediately and the queue is unaffected.
DThe task remains blocked and is not deleted until unblocked.
Attempts:
2 left
💡 Hint

Consider how FreeRTOS handles task deletion regardless of state.