Skip to main content

Posts

Showing posts from 2010

System V vs Posix Semaphores

http://stackoverflow.com/questions/368322/differences-between-system-v-and-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() http://www.cim.mcgill.ca/~franco/OpSys-304-427/lecture-notes/node31.html#SECTION00071100000000000000
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 no longer necessa…