Go to the first, previous, next, last section, table of contents.
mach_thread_self
system call returns the calling thread's
thread port.
mach_thread_self
has an effect equivalent to receiving a send
right for the thread port. mach_thread_self
returns the name of
the send right. In particular, successive calls will increase the
calling task's user-reference count for the send right.
As a special exception, the kernel will happily overrun the user reference count of the thread name port, so that this function can not fail for that reason. Because of this, the user should not deallocate the port right if an overrun might have happened. Otherwise the reference count could drop to zero and the send right be destroyed while the user still expects to be able to use it. As the kernel does not make use of the number of extant send rights anyway, this is safe to do (the thread port itself is not destroyed, even when there are no send rights anymore).
The function returns MACH_PORT_NULL
if a resource shortage
prevented the reception of the send right or if the thread port is
currently null and MACH_PORT_DEAD
if the thread port is currently
dead.
thread_info
returns the selected information array
for a thread, as specified by flavor.
thread_info is an array of integers that is supplied by the caller
and returned filled with specified information. thread_infoCnt is
supplied as the maximum number of integers in thread_info. On
return, it contains the actual number of integers in thread_info.
The maximum number of integers by any flavor is THREAD_INFO_MAX
.
The type of information returned is defined by flavor, which can be one of the following:
THREAD_BASIC_INFO
thread_basic_info_t
. This includes the user and system time, the
run state, and scheduling priority. The number of integers returned is
THREAD_BASIC_INFO_COUNT
.
THREAD_SCHED_INFO
thread_sched_info_t
. The number of integers
returned is THREAD_SCHED_INFO_COUNT
.
The function returns KERN_SUCCESS
if the call succeeded and
KERN_INVALID_ARGUMENT
if target_thread is not a thread or
flavor is not recognized. The function returns
MIG_ARRAY_TOO_LARGE
if the returned info array is too large for
thread_info. In this case, thread_info is filled as much as
possible and thread_infoCnt is set to the number of elements that
would have been returned if there were enough room.
thread_info
function and provides basic information about the
thread. You can cast a variable of type thread_info_t
to a
pointer of this type if you provided it as the thread_info
parameter for the THREAD_BASIC_INFO
flavor of thread_info
.
It has the following members:
time_value_t user_time
time_value_t system_time
int cpu_usage
TH_USAGE_SCALE
.
int base_priority
int cur_priority
int run_state
TH_STATE_RUNNING
TH_STATE_STOPPED
TH_STATE_WAITING
TH_STATE_UNINTERRUPTIBLE
TH_STATE_HALTED
flags
TH_FLAGS_SWAPPED
TH_FLAGS_IDLE
int suspend_count
int sleep_time
time_value_t creation_time
struct thread_basic_info
.
thread_info
function and provides schedule information about the
thread. You can cast a variable of type thread_info_t
to a
pointer of this type if you provided it as the thread_info
parameter for the THREAD_SCHED_INFO
flavor of thread_info
.
It has the following members:
int policy
int data
int base_priority
int max_priority
int cur_priority
int depressed
int depress_priority
struct thread_sched_info
.
Go to the first, previous, next, last section, table of contents.