Task specific callback for resource cleanup.
Market leading real time kernel for 40+ microcontroller architectures
Brought to you by:
gaurav-aws,
rtel
Sequence Diagram
Logged In: YES
user_id=1924273
Originator: YES
Regards,
Stefano
Although this is a very old proposal, I'd like to respond to it.
The biggest problem with the proposed solution is that the function pointed to by
pCallback
will be called ( executed ) from either a different task or worse, from the idle task. Note that no guarantees can be given about the available stack space, the current task priority, or task specific privileges.When task-A terminates, its termination code should be better executed from the task-A context. This means that also
vTaskDelete()
will be called by task to be deleted.So why not send a message to task-A that says "please terminate"? The task can first finish any important action, release mutexes / resources, and then call its own termination code. The final thing to do is call
vTaskDelete()
.For C++ users: this solution also allows to declare objects that have destructors:
As for this feature request: I recommend closing it after 13 years.