1819805 Members
3269 Online
109607 Solutions
New Discussion юеВ

semop not working

 
SOLVED
Go to solution
anup1890
Occasional Advisor

semop not working

We were having a semaphore locking implementation to lock semaphore before accessing the shared memory .When this implementation is ported to HP Ux from Digital.

When the code is ported to HP UX, the application is hanging at semop function.

sem_buf.sem_num = 0;
sem_buf.sem_op = LOCK; /* LOCK = -1*/
sem_buf.sem_flg = SEM_UNDO;

/*
** lock
*/
if ( semop(shms.sem_id, &sem_buf, 1) ) {
rc = IPC_ERROR_EXIT;
}

Is there any change in HP UX for semop
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: semop not working

Do know what the value of semval is?
How are you calling semctl(2)? Are you in 64 bit mode?
anup1890
Occasional Advisor

Re: semop not working

Hi,
Thanks for the response,

Yes, I am compiling in 64bit mode.

Creation of semaphore is done like this
semctl(*sem_id, 0, SETVAL, 1)

Once before calling semop I used "semctl(sem_id, 0, GETVAL, 0);" to get semaphore value
it returned me 0. So this means semaphore value is 0.

One more thing i noted is when i used IPC_NOWAIT for sem_flg the hanging issue was not there
Is it correct to use IPC_NOWAIT instead of SEM_UNDO. Or am i doing something functionally wrong due to which this problem is comming

Thanks
anup1890
Occasional Advisor

Re: semop not working

It worked!!

Thanks for the solution Dennis.
Dennis Handly
Acclaimed Contributor

Re: semop not working

>Thanks for the solution Dennis.

If you are happy with the answers you have gotten, please read the following about how to assign points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33