How to find process holding a semaphore?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to find process holding a semaphore?
# 1  
Old 02-19-2015
How to find process holding a semaphore?

Hello All,

The system concerned has multiple processes communicating with each other using shared memory. These processes use semaphores to protect data being used amongst them. The "key" would uniquely identifies the particular semaphore corresponding to a resource for the various processes.

My task is to write a standalone program which would identify the various semaphores being used in the system with their ID, Key etc and also provide information which process is holding the semaphore.

My query is how to find which process is holding a particular semaphore at a particular instant? The best I could find over the internet was that by using semctl with command GETPID I can find out the process ID which performed the last semop operation on a particular instant. However that does not mention what the operation was and whether the process is currently holding the semaphore or not? Best would be to get a mechanism at runtime which could provide this information to provide a snapshot at a particular instant. Please assist.

Thanks.

best regards,
Saptarshi.
# 2  
Old 02-19-2015
What's your OS?
# 3  
Old 02-19-2015
No process "holds" a semaphore. It's not a lock.

Processes block and wait (or not) for another process to post to the semaphore. There's no way to write a program to figure out which process "should" post to the semaphore.
This User Gave Thanks to achenle For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Holding cursor position on one line

Hi there. It's easier to explain this with a pseudo code, I hope this makes sense: var1=hello echo $var1 some kind of loop echo loop counter done How do I hold the cursor position immediately behind the last output so I'd get something like: hello123456789 DOS used to use ","... (5 Replies)
Discussion started by: MuntyScrunt
5 Replies

2. Programming

Find parent process (not process ID)

Hi: I have a program written in FORTRAN running on AIX platform. It is because missing of documentation and without root password, therefore we want to modify the program so that we can find out which script/program that call this FORTRAN program. I have google for few days, all of them are... (3 Replies)
Discussion started by: cstsang
3 Replies

3. Solaris

Process holding /tmp space, need to know the process details

Hi , In a server /tmp has almost reached 75% and i can see the File system utilization is 48Mb only , so i believe some process is using the /tmp space. I would like to know which process is using /tmp space. # df -h /tmp Filesystem size used avail capacity Mounted on swap ... (9 Replies)
Discussion started by: chidori
9 Replies

4. AIX

Wait process holding CPU

Hi all, Have this performance Issue, srvbd1]root]/]>ps vg | head -1 ; ps vg | grep -w wait PID TTY STAT TIME PGIN SIZE RSS LIM TSIZ TRS %CPU %MEM COMMAND 8196 - A 4448:23 0 384 384 xx 0 0 12.8 0.0 wait 53274 - A 4179:28 0 384 ... (9 Replies)
Discussion started by: gopeezere
9 Replies

5. Solaris

How to check which process is holding up the ilde port

HI All Am on Sun OS.While trying to start a process , we could see that the port is idle and we are not able to find the process holding that port. Below is the result we get after using netstat command. lsof command is not yet installed in our machine. netstat -a | grep "port no"... (5 Replies)
Discussion started by: Whiteboard
5 Replies

6. Shell Programming and Scripting

Holding Expect

I seem to remember seeing a way to hold an expect script or make expect wait for a specific key stroke before continuing. I ask because I want to automate logging into a device using a key fob. Cant find it in my notes and been through my orielly book twice .. going for a third. (0 Replies)
Discussion started by: popeye
0 Replies

7. Shell Programming and Scripting

[BASH] Holding a variable unto other scripts.

Ex: Script 1 has pID=333. I want to take pID to Script 2 so I can retrive 333. How can I do this? (3 Replies)
Discussion started by: Yakuzan
3 Replies

8. Shell Programming and Scripting

global variable not holding its value?

dear there, this kept me awake last night, the variable ${TO} in the following script doesn't seem to hold its value. I have a file ./filelist, which lists all files of interests. I group them by keywords in the filename, and would like to count total number of lines in each group. ... (7 Replies)
Discussion started by: patiobarbecue
7 Replies

9. Shell Programming and Scripting

how to find the chid process id from given parent process id

how to find the chid process id from given parent process id.... (the chid process doesnot have sub processes inturn) (3 Replies)
Discussion started by: guhas
3 Replies
Login or Register to Ask a Question