thread_mtx_unlock(thread);
- if (thread_stop(thread, FALSE)) {
+ if (thread_stop(thread, TRUE)) {
thread_mtx_lock(thread);
result = machine_thread_set_state(
thread, flavor, state, state_count);
return (thread_get_state(thread, flavor, tstate, count));
}
+/*
+ * Change thread's machine-dependent userspace TSD base.
+ * Called with nothing locked. Returns same way.
+ */
+kern_return_t
+thread_set_tsd_base(
+ thread_t thread,
+ mach_vm_offset_t tsd_base)
+{
+ kern_return_t result = KERN_SUCCESS;
+
+ if (thread == THREAD_NULL)
+ return (KERN_INVALID_ARGUMENT);
+
+ thread_mtx_lock(thread);
+
+ if (thread->active) {
+ if (thread != current_thread()) {
+ thread_hold(thread);
+
+ thread_mtx_unlock(thread);
+
+ if (thread_stop(thread, TRUE)) {
+ thread_mtx_lock(thread);
+ result = machine_thread_set_tsd_base(thread, tsd_base);
+ thread_unstop(thread);
+ }
+ else {
+ thread_mtx_lock(thread);
+ result = KERN_ABORTED;
+ }
+
+ thread_release(thread);
+ }
+ else
+ result = machine_thread_set_tsd_base(thread, tsd_base);
+ }
+ else
+ result = KERN_TERMINATED;
+
+ thread_mtx_unlock(thread);
+
+ return (result);
+}
+
/*
* install_special_handler:
*