from Hacker News

System V Semaphores: How not to design an API

by jaywalker on 12/24/10, 7:04 PM with 5 comments

  • by baddox on 12/24/10, 7:52 PM

    My OS course was my first real exposure to the depths of UNIX and C. Being used to Python, I quickly got fed up with how archaic and arcane most of the UNIX/C APIs are. I have a feeling that, if it were judged by even somewhat modern software engineering standards, it would be panned.
  • by wipt on 12/24/10, 9:53 PM

    There is probably a logical reason to the design and nomenclature of the system. Unfortunately, these things seem to get lost over time. I imagine that in another twenty to thirty years a portion of our current technology will be considered unnecessarily complicated and obfuscated.
  • by tzs on 12/25/10, 9:08 AM

       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.