Previous: Task Interface, Up: Threads and Tasks
The function
task_enable_pc_samplingenables PC sampling for task, the functionthread_enable_pc_samplingenables PC sampling for thread. The kernel's idea of clock granularity is returned in ticks in usecs. (this value should not be trusted). The sampling flavor is specified by flavor.The function returns
KERN_SUCCESSif the operation is completed successfully andKERN_INVALID_ARGUMENTif thread is not a valid thread.
The function
task_disable_pc_samplingdisables PC sampling for task, the functionthread_disable_pc_samplingdisables PC sampling for thread. The number of sample elements in the kernel for the thread is returned in sample_count.The function returns
KERN_SUCCESSif the operation is completed successfully andKERN_INVALID_ARGUMENTif thread is not a valid thread.
The function
task_get_sampled_pcsextracts the PC samples for task, the functionthread_get_sampled_pcsextracts the PC samples for thread. seqno is the sequence number of the sampled PCs. This is useful for determining when a collector thread has missed a sample. The sampled PCs for the thread are returned in sampled_pcs. sample_count contains the number of sample elements returned.The function returns
KERN_SUCCESSif the operation is completed successfully,KERN_INVALID_ARGUMENTif thread is not a valid thread andKERN_FAILUREif thread is not sampled.
This structure is returned in sampled_pcs by the
thread_get_sampled_pcsandtask_get_sampled_pcsfunctions and provides pc samples for threads or tasks. It has the following members:
natural_t id- A thread-specific unique identifier.
vm_offset_t pc- A pc value.
sampled_pc_flavor_t sampletype- The type of the sample as per flavor.
This data type specifies a pc sample flavor, either as argument passed in flavor to the
thread_enable_pc_sampleandthread_disable_pc_samplefunctions, or as membersampletypein thesample_pc_tdata type. The flavor is a bitwise-or of the possible flavors defined in mach/pc_sample.h:
SAMPLED_PC_PERIODIC- default
SAMPLED_PC_VM_ZFILL_FAULTS- zero filled fault
SAMPLED_PC_VM_REACTIVATION_FAULTS- reactivation fault
SAMPLED_PC_VM_PAGEIN_FAULTS- pagein fault
SAMPLED_PC_VM_COW_FAULTS- copy-on-write fault
SAMPLED_PC_VM_FAULTS_ANY- any fault
SAMPLED_PC_VM_FAULTS- the bitwise-or of
SAMPLED_PC_VM_ZFILL_FAULTS,SAMPLED_PC_VM_REACTIVATION_FAULTS,SAMPLED_PC_VM_PAGEIN_FAULTSandSAMPLED_PC_VM_COW_FAULTS.