J
john
Hi,
firstly not sure if this is the right group as obviously semaphores
implementation seems to be OS dependent but I couldn't find a unix
programming group?
Anyway, just in case someone can help my error is like so. I have two
processes running - one process created a semaphore whilst the other
just needs to look at it and perform an operation based on it being set.
Here is a rough copy of the code:
Process 1:
semget(key, 1, IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR|S_IROTH|S_IWOTH)
semctl(m_nSemID, 0, SETALL, arg)
struct sembuf stSemBuf[1];
stSemBuf[0].sem_num = 0;
stSemBuf[0].sem_op = 1;
while(bLoop)
{
if(semop(m_nSemID, stSemBuf, 1)!=0)
{
.....error
}
}
Process 2:
struct sembuf stSemBuf[1];
stSemBuf[0].sem_num = 0;
stSemBuf[0].sem_op = -1;
while(bLoop)
{
if(semop(nSemKey, stSemBuf, 1)==0)
{
...do something
}
}
Everything seems to run fine for about 5 minutes then I get errors in
process 1 semop with ERANGE. I had a read of the man pages but can't
figure out why I would get this error as I am not setting the SEM_UNDO flag.
Can anyway provide any insight into my problem or point me in the right
direction to sorting it out myself?
Cheers,
John.
firstly not sure if this is the right group as obviously semaphores
implementation seems to be OS dependent but I couldn't find a unix
programming group?
Anyway, just in case someone can help my error is like so. I have two
processes running - one process created a semaphore whilst the other
just needs to look at it and perform an operation based on it being set.
Here is a rough copy of the code:
Process 1:
semget(key, 1, IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR|S_IROTH|S_IWOTH)
semctl(m_nSemID, 0, SETALL, arg)
struct sembuf stSemBuf[1];
stSemBuf[0].sem_num = 0;
stSemBuf[0].sem_op = 1;
while(bLoop)
{
if(semop(m_nSemID, stSemBuf, 1)!=0)
{
.....error
}
}
Process 2:
struct sembuf stSemBuf[1];
stSemBuf[0].sem_num = 0;
stSemBuf[0].sem_op = -1;
while(bLoop)
{
if(semop(nSemKey, stSemBuf, 1)==0)
{
...do something
}
}
Everything seems to run fine for about 5 minutes then I get errors in
process 1 semop with ERANGE. I had a read of the man pages but can't
figure out why I would get this error as I am not setting the SEM_UNDO flag.
Can anyway provide any insight into my problem or point me in the right
direction to sorting it out myself?
Cheers,
John.