5

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.

4

4 に答える 4

2

群れは別の良いものです

于 2010-02-08T02:48:31.777 に答える
2

valgrind で監視対象のプロセスを開始できる場合、次の 2 つのプロジェクトがあります。

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

とヘルグリンド

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

Helgrind はすべての pthread 抽象化を認識しており、それらの効果を可能な限り正確に追跡します。x86 および amd64 プラットフォームでは、LOCK 命令プレフィックスの使用に起因する暗黙のロックを理解し、部分的に処理します。

したがって、このツールはアトミック メモリ アクセスも検出できます。そして、彼らはpthreadの使用状況をチェックします

于 2010-05-30T02:28:23.703 に答える
0

glibc〜> = 2.5(glibc + nptl)のシステムでは、プロセス共有を使用できます

semaphores (last parameter to sem_init), more precisely, posix unnamed semaphores

posix mutexes (with PTHREAD_PROCESS_SHARED to pthread_mutexattr_setpshared)

posix named semaphores (got from sem_open/sem_unlink)

system v (sysv) semaphores: semget, semop

glibc 2.2、2.3のlinuxthreadsを備えた古いシステム、またはuClibcを備えた組み込みシステムでは、iterprocess通信にsystem v(sysv)セマフォのみを使用できます。

upd1:IPCとソッカーをチェックする必要があります。

于 2010-02-10T18:14:00.970 に答える
0
  1. ロックに使用できるシステム コールは多数あります。flock、fcntl、さらには create です。

  2. pthreads/sem_* ロックを使用している場合、それらはユーザー空間で実行される可能性があるため、保留中の操作に対してのみ futex が呼び出されるため、strace でそれらが表示されることはありません。実際に待つ必要があるときのように。

  3. 一部の操作はユーザー空間でのみ実行できます-スピンロックのように-タイマーを待機しない限りそれらは表示されません-バックオフなので、1 つのロックが他のロックを待機しているときに nanosleep のようなものしか表示されない場合があります。

したがって、それらを追跡する「一般的な」方法はありません。

于 2010-05-29T13:43:17.247 に答える