3

What is the difference between sema_init and sem_init ? Are there any specific usage scenarios and other dependencies for the respective APIs ?

Karthik Balaguru
  • 7,424
  • 7
  • 48
  • 65

2 Answers2

4

Since you tagged this with "linux" I'll ignore other Unixes.

sema_init is the Linux kernel's counting semaphore implementation initialization function.
sem_init is the initializer from the Posix thread library (and is therefore used by userspace code).

3
  • sema_init is from the Solaris thread library.
  • sem_init is from the Posix pthread library.

See Threads: Basic Theory and Libraries

Sjoerd
  • 74,049
  • 16
  • 131
  • 175