- kern_return_t result = KERN_SUCCESS;
- thread_t thread;
-
- if (act == THR_ACT_NULL || act == current_act())
- return (KERN_INVALID_ARGUMENT);
-
- thread = act_lock_thread(act);
-
- if (!act->active) {
- act_unlock_thread(act);
- return (KERN_TERMINATED);
- }
-
- thread_hold(act);
-
- for (;;) {
- thread_t thread1;
-
- if ( thread == THREAD_NULL ||
- thread->top_act != act )
- break;
- act_unlock_thread(act);
-
- if (!thread_stop(thread)) {
- result = KERN_ABORTED;
- (void)act_lock_thread(act);
- thread = THREAD_NULL;
- break;
- }
-
- thread1 = act_lock_thread(act);
- if (thread1 == thread)
- break;
-
- thread_unstop(thread);
- thread = thread1;
- }
-
- if (result == KERN_SUCCESS)
- result = machine_thread_get_state(act, flavor, state, state_count);
-
- if ( thread != THREAD_NULL &&
- thread->top_act == act )
- thread_unstop(thread);
-
- thread_release(act);
- act_unlock_thread(act);
+ return thread_get_state_internal(thread, flavor, state, state_count, FALSE);
+}