0

I have a school assignment where we are supposed to solve readers-writers problem. As I found earlier sem_init is not supported on osx machine so I went with sem_open. However the code below does not work as expected.

if(sem_open(sem_reader, O_CREAT, 1, 0600) == SEM_FAILED)
    perror("sem_reader"); 

The semaphore IS created, but when I try to unlink it with following code:

if(sem_unlink(sem_reader) != 0)
    perror("unlink_sem_reader"); 

I get the output:

unlink_sem_reader: Permission denied

I tried to play with permissions like 0700, 0660 etc., but I always get permission denided. They are both wrapped in function and no action is taken with them. I am not sure where the problem is. My question is:

Did I set permissions incorrectly or the problem is somewhere else?

EDIT: Working in Xcode / 10.7

Community
  • 1
  • 1
rojcyk
  • 247
  • 1
  • 3
  • 16

1 Answers1

3

I think you switched arguments mode and value of sem_open.

Jens Gustedt
  • 76,821
  • 6
  • 102
  • 177