Search code examples
profilerdarwin

SIGPROF on darwin


setitimer + sigprof doesn't work on 64 bit darwin.

References:

http://openradar.appspot.com/9336975

http://lists.apple.com/archives/Unix-porting/2007/Aug/msg00000.html

Given this, what's the recommended way to build a time based, sampling profiler on darwin? In a multithreaded environment.


Solution

  • I ended up creating a separate profiler thread that sleeps for intervals and pthread_kills all other threads with SIGPROF. The SIGPROF handler looks at the how much cpu time the thread consumed and punts if it's too little.