#include <mach/thread_info.h> also included by <mach/mach.h>

mach/thread_info.h

24 macros · 10 typedefs · 5 structs

typedefthread_flavor_t

Generic information structure to allow for expansion.
typedef natural_t thread_flavor_t
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Defined values:
THREAD_BASIC_INFOReturns basic information about the thread, such as the thread's run state and suspend count. The returned structure is thread_basic_info.
THREAD_SCHED_FIFO_INFOReturns FIFO scheduling policy information about the thread. The returned structure is policy_fifo_info.
THREAD_SCHED_RR_INFOReturns round-robin scheduling policy information about the thread. The returned structure is policy_rr_info.
THREAD_SCHED_TIMESHARE_INFOReturns timeshare scheduling policy information about the thread. The returned structure is policy_timeshare_info.

typedefthread_info_t

typedef integer_t *thread_info_t
varying array of int

macroTHREAD_INFO_MAX

#define THREAD_INFO_MAX (32)
maximum array size

typedefthread_info_data_t

typedef integer_t thread_info_data_t[THREAD_INFO_MAX]

macroTHREAD_BASIC_INFO

Currently defined information.
#define THREAD_BASIC_INFO 3
basic information
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Returns basic information about the thread, such as the thread's run state and suspend count. The returned structure is thread_basic_info.
a value of thread_flavor_t

structthread_basic_info

size 40, align 4
time_value_tuser_timeuser run time
time_value_tsystem_timesystem run time
integer_tcpu_usagescaled cpu usage percentage
policy_tpolicyscheduling policy in effect
integer_trun_staterun state (see below)
integer_tflagsvarious flags (see below)
integer_tsuspend_countsuspend count for thread
integer_tsleep_timenumber of seconds that thread has been sleeping
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Defines basic information for a thread.
The thread_basic_info structure defines the basic information array for threads. The thread_info function returns this array for a specified thread.

typedefthread_basic_info_data_t

typedef struct thread_basic_info thread_basic_info_data_t

typedefthread_basic_info_t

typedef struct thread_basic_info *thread_basic_info_t
GNU Mach reference · 7.1.3 Thread Information · © FSF, GFDL
thread_basic_info_t
This is a pointer to a struct thread_basic_info.

macroTHREAD_BASIC_INFO_COUNT

#define THREAD_BASIC_INFO_COUNT ((mach_msg_type_number_t)
	        (sizeof(thread_basic_info_data_t) / sizeof(natural_t)))

macroTHREAD_IDENTIFIER_INFO

#define THREAD_IDENTIFIER_INFO 4
thread id and other information

structthread_identifier_info

size 24, align 8
uint64_tthread_idsystem-wide unique 64-bit thread id
uint64_tthread_handlehandle to be used by libproc
uint64_tdispatch_qaddrlibdispatch queue address

typedefthread_identifier_info_data_t

typedef struct thread_identifier_info thread_identifier_info_data_t

typedefthread_identifier_info_t

typedef struct thread_identifier_info *thread_identifier_info_t

macroTHREAD_IDENTIFIER_INFO_COUNT

#define THREAD_IDENTIFIER_INFO_COUNT ((mach_msg_type_number_t)
	        (sizeof(thread_identifier_info_data_t) / sizeof(natural_t)))

macroTH_USAGE_SCALE

#define TH_USAGE_SCALE 1000

macroTH_STATE_RUNNING

#define TH_STATE_RUNNING 1
thread is running normally

macroTH_STATE_STOPPED

#define TH_STATE_STOPPED 2
thread is stopped

macroTH_STATE_WAITING

#define TH_STATE_WAITING 3
thread is waiting normally

macroTH_STATE_UNINTERRUPTIBLE

#define TH_STATE_UNINTERRUPTIBLE 4
thread is in an uninterruptible wait

macroTH_STATE_HALTED

#define TH_STATE_HALTED 5
thread is halted at a clean point

macroTH_FLAGS_SWAPPED

Thread flags (flags field).
#define TH_FLAGS_SWAPPED 0x1
thread is swapped out

macroTH_FLAGS_IDLE

#define TH_FLAGS_IDLE 0x2
thread is an idle thread

macroTH_FLAGS_GLOBAL_FORCED_IDLE

#define TH_FLAGS_GLOBAL_FORCED_IDLE 0x4
thread performs global forced idle

macroTHREAD_EXTENDED_INFO

Thread extended info (returns same info as proc_pidinfo(...,PROC_PIDTHREADINFO,...)
#define THREAD_EXTENDED_INFO 5

macroMAXTHREADNAMESIZE

#define MAXTHREADNAMESIZE 64

structthread_extended_info

size 112, align 8
uint64_tpth_user_timeuser run time
uint64_tpth_system_timesystem run time
int32_tpth_cpu_usagescaled cpu usage percentage
int32_tpth_policyscheduling policy in effect
int32_tpth_run_staterun state (see below)
int32_tpth_flagsvarious flags (see below)
int32_tpth_sleep_timenumber of seconds that thread
int32_tpth_curpricur priority
int32_tpth_prioritypriority
int32_tpth_maxprioritymax priority
char[64]pth_namethread name, if any

typedefthread_extended_info_data_t

typedef struct thread_extended_info thread_extended_info_data_t

typedefthread_extended_info_t

typedef struct thread_extended_info * thread_extended_info_t

macroTHREAD_EXTENDED_INFO_COUNT

#define THREAD_EXTENDED_INFO_COUNT ((mach_msg_type_number_t)
	        (sizeof(thread_extended_info_data_t) / sizeof (natural_t)))

macroTHREAD_DEBUG_INFO_INTERNAL

#define THREAD_DEBUG_INFO_INTERNAL 6
for kernel development internal info

macroIO_NUM_PRIORITIES

#define IO_NUM_PRIORITIES 4

macroUPDATE_IO_STATS

#define UPDATE_IO_STATS(info, size) {
	info.count++;
	info.size += size;
}

macroUPDATE_IO_STATS_ATOMIC

#define UPDATE_IO_STATS_ATOMIC(info, io_size) {
	OSIncrementAtomic64((SInt64 *)&(info.count));
	OSAddAtomic64(io_size, (SInt64 *)&(info.size));
}

structio_stat_entry

size 16, align 8
uint64_tcount
uint64_tsize

structio_stat_info

size 128, align 8
struct io_stat_entrydisk_reads
struct io_stat_entry[4]io_priority
struct io_stat_entrypaging
struct io_stat_entrymetadata
struct io_stat_entrytotal_io

typedefio_stat_info_t

typedef struct io_stat_info *io_stat_info_t

macroTHREAD_SCHED_TIMESHARE_INFO

#define THREAD_SCHED_TIMESHARE_INFO 10
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Returns timeshare scheduling policy information about the thread. The returned structure is policy_timeshare_info.
a value of thread_flavor_t

macroTHREAD_SCHED_RR_INFO

#define THREAD_SCHED_RR_INFO 11
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Returns round-robin scheduling policy information about the thread. The returned structure is policy_rr_info.
a value of thread_flavor_t

macroTHREAD_SCHED_FIFO_INFO

#define THREAD_SCHED_FIFO_INFO 12
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Returns FIFO scheduling policy information about the thread. The returned structure is policy_fifo_info.
a value of thread_flavor_t