sem_init is not working on Mac OSX 10.6.4(Snow Leopard)

I am writing code that will solve readers writers problem but when i use sem_init to initialise unnamed semaphore,

it returns -1 my code is

sem_t sem;

main()

{

int ret;

ret = sem_init(&sem, 0, 1);

printf("Return %d\n", ret);

}

Is there any mistake with my code please let me know.If not provide me with suggestions to solve this problem?

Mac mini, Mac OS X (10.6.4)

Posted on Feb 8, 2013 1:26 AM

Reply
6 replies

Feb 12, 2013 4:58 AM in response to Dhiraj Bhor

You are trying to use a specific, newer type of semaphore that is meant for realtime systems like VxWorks. Linux includes it too, even though Linux isn't any more realtime than OS X. The original semaphore idea belongs to Edsger Dijkstra from 1965. It really isn't used anymore in new development. The state of the art in concurrency is Apple's Grand Central Dispatch.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

sem_init is not working on Mac OSX 10.6.4(Snow Leopard)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.