The valgrind
tool drd http://valgrind.org/docs/manual/drd-manual.html允许您指定在报告错误之前锁定应等待的时间限制。
This site http://0pointer.de/blog/projects/mutrace.html提及drd
还提到了他们自己的工具,称为mutrace
这看起来就是你想要的那种工具。它告诉你:
- 互斥锁被锁定了多少次
- 互斥拥有线程改变了多少次
- 互斥锁被争用了多少次(在发出锁定请求时已被锁定)
- 有关互斥体锁定持续时间的各种统计数据
e.g.
mutrace: 10 most contended mutexes:
Mutex # Locked Changed Cont. tot.Time[ms] avg.Time[ms] max.Time[ms] Type
35 368268 407 275 120,822 0,000 0,894 normal
5 234645 100 21 86,855 0,000 0,494 normal
26 177324 47 4 98,610 0,001 0,150 normal
19 55758 53 2 23,931 0,000 0,092 normal
53 106 73 1 0,769 0,007 0,160 normal
25 15156 70 1 6,633 0,000 0,019 normal
4 973 10 1 4,376 0,004 0,174 normal
75 68 62 0 0,038 0,001 0,004 normal
9 1663 52 0 1,068 0,001 0,412 normal
3 136553 41 0 61,408 0,000 0,281 normal
... ... ... ... ... ... ... ...
mutrace: Total runtime 9678,142 ms.