Within a Linux Box I'm using named semaphores to control access to system resources used by different processes.
If the system accidentally crashes, it can happen, that a semaphore has been acquired but not given back yet. Given that situation, I noticed, that even after a reboot the semaphore remains still in a locked state.
To overcome such situation, would it be ok, to unlink the semaphore at system startup before it is used again by one ore more processes? Or would it be better to give it a sem_post() until the semaphore is released?
BTW:
Where are semaphores stored internally. I wonder why they survive system reboots.