void GC_push_all_stacks() {
int i;
+ task_t my_task;
kern_return_t r;
mach_port_t me;
ptr_t lo, hi;
me = mach_thread_self();
if (!GC_thr_initialized) GC_thr_init();
- r = task_threads(current_task(), &act_list, &listcount);
+ my_task = current_task();
+ r = task_threads(my_task, &act_list, &listcount);
if(r != KERN_SUCCESS) ABORT("task_threads failed");
for(i = 0; i < listcount; i++) {
thread_act_t thread = act_list[i];
(unsigned long) hi
);
# endif
- GC_push_all_stack(lo, hi);
+ GC_push_all_stack(lo, hi);
+ mach_port_deallocate(my_task, thread);
} /* for(p=GC_threads[i]...) */
- vm_deallocate(current_task(), (vm_address_t)act_list, sizeof(thread_t) * listcount);
+ vm_deallocate(my_task, (vm_address_t)act_list, sizeof(thread_t) * listcount);
+ mach_port_deallocate(my_task, me);
}
#endif /* !DARWIN_DONT_PARSE_STACK */
}
if (!found) GC_mach_threads_count++;
}
+
+ mach_port_deallocate(current_task(), my_thread);
return changed;
}
{
int i, changes;
GC_thread p;
+ task_t my_task = current_task();
mach_port_t my_thread = mach_thread_self();
kern_return_t kern_result;
thread_act_array_t act_list, prev_list;
prevcount = 0;
do {
int result;
- kern_result = task_threads(current_task(), &act_list, &listcount);
+ kern_result = task_threads(my_task, &act_list, &listcount);
result = GC_suspend_thread_list(act_list, listcount,
prev_list, prevcount);
changes = result;
prev_list = act_list;
prevcount = listcount;
- vm_deallocate(current_task(), (vm_address_t)act_list, sizeof(thread_t) * listcount);
+
+ if(kern_result == KERN_SUCCESS) {
+ int i;
+
+ for(i = 0; i < listcount; i++)
+ mach_port_deallocate(my_task, act_list[i]);
+
+ vm_deallocate(my_task, (vm_address_t)act_list, sizeof(thread_t) * listcount);
+ }
} while (changes);
#if DEBUG_THREADS
GC_printf1("World stopped from 0x%lx\n", my_thread);
#endif
+
+ mach_port_deallocate(my_task, my_thread);
}
/* Caller holds allocation lock, and has held it continuously since */
/* the world stopped. */
void GC_start_world()
{
+ task_t my_task = current_task();
mach_port_t my_thread = mach_thread_self();
int i, j;
GC_thread p;
}
# endif
- kern_result = task_threads(current_task(), &act_list, &listcount);
+ kern_result = task_threads(my_task, &act_list, &listcount);
for(i = 0; i < listcount; i++) {
thread_act_t thread = act_list[i];
if (thread != my_thread &&
}
}
}
+
+ mach_port_deallocate(my_task, thread);
}
- vm_deallocate(current_task(), (vm_address_t)act_list, sizeof(thread_t) * listcount);
+ vm_deallocate(my_task, (vm_address_t)act_list, sizeof(thread_t) * listcount);
+
+ mach_port_deallocate(my_task, my_thread);
# if DEBUG_THREADS
GC_printf0("World started\n");
# endif