5 Replies Latest reply: Feb 12, 2013 4:58 AM by etresoft
Dhiraj Bhor Level 1 Level 1 (0 points)

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)