vTaskDelete and xSemaphoreTake(xMutex, portMAX_DELAY);

Please clear my doubts?

When I have a task running and within that task there is, for example:

A traffic light with take and give.

Then, from within another task, I go there and delete this running task… How do I know what state the Semaforo is in??



and …


Unless you have provided some path to know, you don’t. (you could interogate it yourself).

If this is a Mutex, then you may be in a bad state if it held the Mutex when the task was deleted, as then no one exists that can give it.

Basically, deleting task when you don’t know their current state is generally a very bad idea.

Thank you for the response.

I implemented a semaphore and only delete the task when the semaphore is available.

I would like to know if the same also applies to vTaskSuspend and vTaskResume

These functions are task related. No 3rd party involved which could be left in an unwanted or unknown state.
BUT also these functions are somewhat special because a task can be suspended at any time without any synchronization. It’s easy to get trapped by subtle race conditions.

Systems development with the FreeRTOs environment involves a change in mindset, the way we think about system development is different from superloop.