LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-02-2008, 03:08 PM   #1
mmcds
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Rep: Reputation: 0
semaphores


I am using SuSE Linux and have reached my array limit for semaphores. I did the ipcs -u to see what I am using and ipcs -l to show my limits. I tried the ipcs -s to see what all arrays are being used and it is showing this

------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 360448 nobody 600 1
0x00000000 3997697 nobody 600 1
0x00000000 4030466 nobody 600 1

My question is how do I know what semid is belonging to what process that is running on my machine that I can safely destroy to get some of my arrays back?
 
Old 01-02-2008, 03:34 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Hmmm ... I'm playing around with ipcs and I'm not sure if there's a way to do what you want because IIRC semaphores don't really "belong" to any given process. They have a process that creates tghem, but then any process with the appropriate permissions can then use them. Do you have a process that is creating semaphores but not removing them? If so that's an application bug and you should try to get it fixed. Otherwise you can adjust the per user and per process limits with the kernel.sem sysctl variable. There might be some other way of determining what processes hold a semaphore but I'm not familiar with it.
 
Old 01-02-2008, 03:41 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Code:
$ ipcs -p

------ Shared Memory Creator/Last-op --------
shmid      owner      cpid       lpid
32768      root       3288       3474
65537      root       3288       3348
2424834    colucix    13252      13263
2457603    colucix    13252      3288
2654212    colucix    13252      3288
2588678    colucix    13252      13252
where cpid is the process ID of the creator (the information I think you're looking for) and lpid is the process ID of the last process that accessed that particular segment of memory.

Edit: notes by btmiller are correct: killing a creator process will free shared memory and the related semaphores, but bugs may prevent the normal behavior.

Last edited by colucix; 01-02-2008 at 03:46 PM.
 
Old 01-02-2008, 04:27 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Aha ... you can look for the shared memory segment that corresponds with a particular semaphore in order to see the creator and who accessed it last (the shmid of the shared memory segment will be equal to the semaphore key). I didn't realize that but it would make sense that semaphores are implemented as part of the shared memory segments, which I guess is going on.
 
Old 01-03-2008, 09:16 AM   #5
mmcds
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for both of your replies. I am sure it is an application problem, but I just wanted to see if there was a way to relate an semid to an actual process to pinpoint it down further to go back to the developer to say ok this is what is causing this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
questions on semaphores feetyouwell Programming 3 10-03-2004 10:55 PM
Semaphores and IPC gsu_790 Programming 2 09-29-2004 10:29 AM
What is Semaphores? imsajjadali Red Hat 3 04-23-2004 02:26 AM
Semaphores help mojozoox Programming 1 01-07-2004 09:41 AM
semaphores charles_sjc Linux - Software 2 12-06-2003 01:15 AM


All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration