1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

thread_pthread.c: fill stack info by creator thread

* thread_pthread.c (native_thread_init_stack): wait the creator thread
  to fill machine stack info, if get_stack_of() is available.
* thread_pthread.c (native_thread_create): fill the created thread
  stack info after starting, if get_stack_of() is available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-08-30 13:37:59 +00:00
parent b59b1b9bd9
commit 93024c6377
2 changed files with 23 additions and 1 deletions

View file

@ -1,4 +1,10 @@
Fri Aug 30 22:37:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
Fri Aug 30 22:37:57 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* thread_pthread.c (native_thread_init_stack): wait the creator thread
to fill machine stack info, if get_stack_of() is available.
* thread_pthread.c (native_thread_create): fill the created thread
stack info after starting, if get_stack_of() is available.
* thread_pthread.c (native_thread_create): define attr only if it is
used, and merge pthread_create() calls.

View file

@ -754,6 +754,11 @@ native_thread_init_stack(rb_thread_t *th)
th->machine_stack_start = start;
th->machine_stack_maxsize = size;
}
#elif defined get_stack_of
if (!th->machine_stack_maxsize) {
native_mutex_lock(&th->interrupt_lock);
native_mutex_unlock(&th->interrupt_lock);
}
#else
rb_raise(rb_eNotImpError, "ruby engine can initialize only in the main thread");
#endif
@ -928,8 +933,19 @@ native_thread_create(rb_thread_t *th)
CHECK_ERR(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED));
# endif
CHECK_ERR(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED));
#endif
#ifdef get_stack_of
native_mutex_lock(&th->interrupt_lock);
#endif
err = pthread_create(&th->thread_id, attrp, thread_start_func_1, th);
#ifdef get_stack_of
if (!err) {
get_stack_of(th->thread_id,
&th->machine_stack_start,
&th->machine_stack_maxsize);
}
native_mutex_unlock(&th->interrupt_lock);
#endif
thread_debug("create: %p (%d)\n", (void *)th, err);
#ifdef HAVE_PTHREAD_ATTR_INIT
CHECK_ERR(pthread_attr_destroy(&attr));