[前][次][番号順一覧][スレッド一覧]

ruby-changes:30653

From: nobu <ko1@a...>
Date: Fri, 30 Aug 2013 22:38:10 +0900 (JST)
Subject: [ruby-changes:30653] nobu:r42732 (trunk): thread_pthread.c: fill stack info by creator thread

nobu	2013-08-30 22:37:59 +0900 (Fri, 30 Aug 2013)

  New Revision: 42732

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42732

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42731)
+++ ChangeLog	(revision 42732)
@@ -1,4 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Fri Aug 30 22:37:49 2013  Nobuyoshi Nakada  <nobu@r...>
+Fri Aug 30 22:37:57 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 42731)
+++ thread_pthread.c	(revision 42732)
@@ -754,6 +754,11 @@ native_thread_init_stack(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L754
 	    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
@@ -929,7 +934,18 @@ native_thread_create(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L934
 # 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));

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]