Skip to main content


Showing posts from August, 2010

System V vs Posix Semaphores the semaphore set must be initialized using semget(); the semaphore creator can change its ownership or permissions using semctl(); and semaphore operations are performed via the semop() Three features contribute to this unnecessary complication: A semaphore counter is not just a single value. It's rather a set of one or more values, and the exact number of values is specified upon semaphore creation. The creation of a semaphore is independent of its initialization. This is a fatal flaw, since we cannot atomically create a new semaphore set and initialize all the values in the set: a competing process may sneak in and access the semaphore after creation but before initialization, thus finding semagarbage. A semaphore must be explicitly destroyed when the shared resource is