News for hackers. Stuff that matters.
Re:System V Semaphores: How not to design an API by tzs on Saturday December 25, 2010 @04:08AM (#2038715)

   Is it too much to ask to create separate sem_wait()
   and sem_post() methods.
What happens when you want to do a sequence of waits and posts, and you want to do it atomically? You'd have to introduce an extra semaphore to control access to all doing your sequence.

With the semop() function, you put all your desired operations in one array of ops, and make one semop call, which does all the operations atomically.

Re:System V Semaphores: How not to design an API by jaywalker on Saturday December 25, 2010 @05:39AM (#2038779)
Yes, that's exactly why I think the "operations" concept was added. But isn't it good to provide extra sem_wait() and sem_post() for most of the rest of us who want a single increment or a decrement? I have yet to find a good use of an array of operations in a single atomic fashion. Neither dining philosophers nor reader-writers need multiple increments/ decrements in one go.