1832513 Members
4970 Online
110043 Solutions
New Discussion

semaphore key 0x00000000

 
Lisa Sorbo
Frequent Advisor

semaphore key 0x00000000

I'm having a semaphore resource problem and when I use ipcs -s I see alot of lines with key of 0x00000000
my question is - can I just remove these ipcrm -s since they have key 0x00000000 ?

Lisa
5 REPLIES 5
Giri Sekar.
Trusted Contributor

Re: semaphore key 0x00000000

Hi:

Try removing with the ID rather than the key

ipcrm -s (ID) right in front of the key. also look into shminfo.

Thanks

Giri Sekar.
"USL" Unix as Second Language
Lisa Sorbo
Frequent Advisor

Re: semaphore key 0x00000000

yes, I will remove using -ssemaphoreid rather than the key -

my question was more along the lines of ...
can I assume that it is safe to remove these entries with the key of 0x00000000 ?

is there a case where an entry with a key of 0x00000000 is still valid and removing it could cause a problem for an active process - or is my recollection that these 0x00000000 entries are essentially orphans and it is safe to remove them without regard for where they came from?

James Murtagh
Honored Contributor

Re: semaphore key 0x00000000

Hi Lisa,

I certainly think its a valid key, although I don't know if it is encouraged when multiple processes could access the semaphore. When a semaphore is created using the IPC_PRIVATE flag of semget, only that process and its children can access the semaphore. Multiple instances of any key can be created in this fashion but they will have different ids. I would use "ipcs -sa" to check the number of semaphore sets (nsems) corresponding to it and the last access times etc, see "man ipcs" for a description of the fields.

regards,

James.
Lisa Sorbo
Frequent Advisor

Re: semaphore key 0x00000000

is there a way to determine what process belongs to a given semaphore so I could check to see if it is still active or not?
James Murtagh
Honored Contributor

Re: semaphore key 0x00000000

Hi Lisa,

There is an HP contributed tool named seminfo which will show you this, contact your local RC for this. Without this its a lot harder, you need to use a kernel debugger.

first, find your semmni value:

# kmtune|grep semmni

Next, use ipcs -s to find the key you want to use, in your case 0x00000000 I believe. This is the hard bit:

# ied q4 /stand/vmunix /dev/kmem
q4> load struct semid_ds from &sema max
q4> keep sem_perm.key ==
q4> load struct __sem from sem_base
q4> print sempid
sempid
2071

So here I see process 2071 was using this semaphore. If you have multiple keys using the same value you will see multiple structs being loaded. You can use "print -tx" in q4 to try and find a unique value a particular structure to keep using the same syntax as the above keep command.

Regards,

James.