From 440ac81c905c21099b0366ff28eec5c34eab8283 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 21 Nov 2007 09:06:06 +0000 Subject: * vm.c: fix to recycle thread data (VM stack). * thread.c: ditto. * benchmark/bm_vm3_thread_create_join.rb: add loop count. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 1655ce054..6955d8682 100644 --- a/thread.c +++ b/thread.c @@ -288,6 +288,7 @@ thread_cleanup_func(void *th_ptr) extern void ruby_error_print(void); static VALUE rb_thread_raise(int, VALUE *, rb_thread_t *); +void rb_thread_recycle_stack_release(VALUE *); static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start) @@ -359,6 +360,11 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s join_th = join_th->join_list_next; } st_delete_wrap(th->vm->living_threads, th->self); + + if (!th->root_fiber) { + rb_thread_recycle_stack_release(th->stack); + th->stack = 0; + } } thread_cleanup_func(th); native_mutex_unlock(&th->vm->global_interpreter_lock); @@ -428,7 +434,6 @@ thread_join(rb_thread_t *target_th, double delay) th->join_list_next = target_th->join_list_head; target_th->join_list_head = th; } - while (target_th->status != THREAD_KILLED) { if (delay == DELAY_INFTY) { sleep_forever(th); -- cgit