Query about task deletion

I had a basic query about task deletion in freertos. Can we delete a task from within a task? as in last line will be the vTaskDelete call.. What argument do you pass?
Also the documentation says that the memory for the deleted task is only deleted when the idle task is run.. Is there any other way to do this?

Query about task deletion

A task can delete itself by calling either vTaskDelete( NULL ); or vTaskDelete( my_handle ), where my_handle is a variable of type xTaskHandle that holds the calling tasks handle. The memory allocated to the task for the task stack and task control block are freed the next time the idle task runs.  That is currently the only way it is done. Regards.

Query about task deletion

Reading your question again – if you mean can one task delete another task (rather than itself), then “yes” it can.  The parameter to vTaskDelete() is the handle of the task you are deleting.  Task handles can be obtained using the last parameter of the xTaskCreate() call used to create the task in the first place. Regards.

Query about task deletion

Thanks for that.. Maybe an api call to delete allocated memory in a future release ? :)