I have the following scenario:
- Following sequence is executed in Task X:
- Create Semaphore S (with OS_CreateSema()) with initial value of 0
- Create Task A and hand over Semaphore S
- Allow startup of Task A by using OS_Delay()
- Task A approaches OS_WaitCSem() and hence waits for the release of Semaphore S (as the init value has been set to 0)
- Task X terminates Task A by using OS_Terminate()
- Task X deletes Semaphore S ---> this leads to OS error because the semaphore was used by the already terminated Task A
How can I avoid that situation but still making sure that all resources are freed up at the end?
- Following sequence is executed in Task X:
- Create Semaphore S (with OS_CreateSema()) with initial value of 0
- Create Task A and hand over Semaphore S
- Allow startup of Task A by using OS_Delay()
- Task A approaches OS_WaitCSem() and hence waits for the release of Semaphore S (as the init value has been set to 0)
- Task X terminates Task A by using OS_Terminate()
- Task X deletes Semaphore S ---> this leads to OS error because the semaphore was used by the already terminated Task A
How can I avoid that situation but still making sure that all resources are freed up at the end?