I’m developing a middle layer between a peripheral an upper layers, and this middle layer has a binary semaphore.
The upper layers (threads) call the “Request” function of the middle layer, this takes the binary semaphore (xSemaphoreTake) to allow only one access to the peripheral at a time. Once the use of the peripheral is finished, the upper layer executes the “Release” function of the middle layer that releases the semaphore.
Now suppose the case that the semaphore is taken, and other upper layer (thread) executes the Request function. This will lead the thread to be waiting for the semaphore. If this thread is externally deleted, will the semaphore keep correct values? Is it safe to do?