NAME
thread_get_state - return machine dependent state
thread_set_state - set machine dependent state

SYNOPSIS
#include <mach.h>

kern_return_t thread_get_state(target_thread, flavor, old_state, old_stateCnt)
thread_t target_thread;
int flavor;
thread_state_data_t old_state; /* in and out */
unsigned int *old_stateCnt; /* in and out */

kern_return_t thread_set_state(target_thread, flavor, new_state, new_stateCnt)
thread_t target_thread;
int flavor;
thread_state_data_t new_state;
unsigned int new_stateCnt;

ARGUMENTS
target_thread Thread to get or set the state for.

flavor The type of state that is to be manipulated.
Currently must be one of the following values:
VAX_THREAD_STATE, ROMP_THREAD_STATE,
SUN_THREAD_STATE_REGS, SUN_THREAD_STATE_FPA.

new_state An array of state information.

old_state An array of state information.

new_stateCnt The size of the state information array. Currently
must be one of the following values:
VAX_THREAD_STATE_COUNT, ROMP_THREAD_STATE_COUNT,
SUN_THREAD_STATE_REGS_COUNT,
SUN_THREAD_STATE_FPA_COUNT.

old_stateCnt Same as new_stateCnt.

DESCRIPTION
thread_get_state returns the state component (e.g. the machine
registers) of target_thread as specified by flavor. The old_state
is an array of integers that is provided by the caller and returned
filled with the specified information. old_stateCnt is input set to
the maximum number of integers in old_state and returned equal to
the actual number of integers in old_state.

thread_set_state sets the state component (e.g. the machine
registers) of target_thread as specified by flavor. The new_state
is an array of integers. new_stateCnt is the number of elements in
new_state. The entire set of registers is reset. This will do
unpredictable things if target_thread is not suspended.

target_thread may not be thread_self for either of these calls.

The definition of the state structures can be found in
<machine/thread_status.h>.

DIAGNOSTICS
KERN_SUCCESS The state has been set or returned

MIG_ARRAY_TOO_LARGE Returned state is too large for the
new_state array. new_state is filled
in as much as possible and
new_stateCnt is set to the number of
elements that would be returned if
there were enough room.

KERN_INVALID_ARGUMENT target_thread is not a thread or is
thread_self or flavor is unrecogized
for this machine.

SEE ALSO
task_info(2), thread_info(2)