Reputation: 1261
In C programming language why do we need a special sem_t type for defining the semaphore? Couldn't that been an integer?How is sem_t defined? How is the functions sem_post and sem_wait implemented? EDIT:An example implementation like GNU C library will be great.
Upvotes: 3
Views: 11054
Reputation: 24857
Semaphores are OS kernel managed objects, so sem_t will be OS-specific, as will be the signal/wait calls since they also necessarily call into the OS kernel.
Usually, the semaphores are implemented by a unit count and a queue for any waiting threads.
Upvotes: 5