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.
I ended up creating a separate profiler thread that sleeps for intervals and
pthread_killsall other threads withSIGPROF. TheSIGPROFhandler looks at the how much cpu time the thread consumed and punts if it’s too little.