Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What interprocess locking calls should I monitor?

I'm monitoring a process with strace/ltrace in the hope to find and intercept a call that checks, and potentially activates some kind of globally shared lock.

While I've dealt with and read about several forms of interprocess locking on Linux before, I'm drawing a blank on what to calls to look for.

Currently my only suspect is futex() which comes up very early on in the process' execution.

Update0

There is some confusion about what I'm after. I'm monitoring an existing process for calls to persistent interprocess memory or equivalent. I'd like to know what system and library calls to look for. I have no intention call these myself, so naturally futex() will come up, I'm sure many libraries will implement their locking calls in terms of this, etc.

Update1

I'd like a list of function names or a link to documentation, that I should monitor at the ltrace and strace levels (and specifying which). Any other good advice about how to track and locate the global lock in mind would be great.

like image 372
Matt Joiner Avatar asked Oct 15 '22 10:10

Matt Joiner


2 Answers

If you can start monitored process in valgrind, then there are two projects:

http://code.google.com/p/data-race-test/wiki/ThreadSanitizer

and Helgrind

http://valgrind.org/docs/manual/hg-manual.html

Helgrind is aware of all the pthread abstractions and tracks their effects as accurately as it can. On x86 and amd64 platforms, it understands and partially handles implicit locking arising from the use of the LOCK instruction prefix.

So, this tools can detect even atomic memory accesses. And they will check pthread usage

like image 159
osgx Avatar answered Oct 17 '22 14:10

osgx


flock is another good one

like image 28
user262976 Avatar answered Oct 17 '22 12:10

user262976