osfmk/man/task_sample.html
Function - Sample the target task's thread program counters periodically.
**kern\_return\_t task\_sample**** (task\_t **sample\_task,** mach\_port\_make\_send\_t **reply\_port** );**
sample_task[in task send right] Port for the task whose threads' PC are to be sampled.
reply_port[in sample receive (to be converted to send) right] Port to which PC sample buffers are sent. A value of MACH_PORT_NULL stops PC sampling for the task.
The task_sample function causes the program counter (PC) of the specified sample_task (actually, all of the threads within sample_task) to be sampled periodically (whenever one of the threads happens to be running at the time of the kernel's "hardclock" interrupt). The set of PC sample values obtained are saved in buffers which are sent to the specified reply_port in receive_samples messages.
Only generic errors apply.
Functions: thread_sample, receive_samples.