Software Tuning, Performance Optimization & Platform Monitoring
Discussion around monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform monitoring

Intercept calls to pthread_mutex_lock

Umesh__Deepthi
Beginner
158 Views

Hi All,

I would want to profile multithreaded program and find out if threre was a contention for mutex by threads.

If a thread is going to operate on some mutex, the thread needs to call corresponding pthread functions, like pthread_mutex_lock.  I should be able to redirect the execution of these functions, as in wrap before and after the execution of these functions, where I can get the parameters and return values.

 how to intercept calls to pthread_mutex_lock. doing something like  #define pthread_mutex_lock my_pthread_mutex_lock?

Kindly throw some light on this.I request you to help me out.

Thank you in advance.

Regards,

Deepthi

0 Kudos
1 Reply
Travis_D_
New Contributor II
158 Views

This doesn't have much to do with Intel, but you can Google for "symbol interposition" or something like that. One way is to use LD_LIBRARY_PRELOAD on Unix-like with a library that redefines the symbols. You can also look at uprobes and similar.

Reply