This discussion is archived
0 Replies Latest reply: May 24, 2011 2:39 PM by 864157 RSS

problem with SystemV semaphores

864157 Newbie
Currently Being Moderated
Hi
I have a problem with synchronizing two processes with a named SysV semaphore. i am trying to build an auto-reset event between two processes. the idea is that one process always wait on 0 and the other proces wakes the other process by setting the semaphore to 0 and reseting it to 1 immidiatly. this is the code of the set method.

sembuf sem;
sem.sem_num =0;
sem.sem_op = -1;
sem.sem_flg = SEM_UNDO;
int ret = semop(semID,&sem,1);
if(ret == 0)
{
sem.sem_op = 1;
semop(semID,&sem,1)
}

for some reason , the waitnig thread does not wake up unless i wait a considerable time befor the reset.
the same code runs on Linux RH with no problems.

what could be the problem ????
thanks,
Alon

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points