[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:380

From: ko1 atdot.net
Date: 3 Sep 2006 04:26:41 +0900
Subject: [yarv-diff:380] r547 - branches/parallel

Author: ko1
Date: 2006-09-03 04:26:40 +0900 (Sun, 03 Sep 2006)
New Revision: 547

Modified:
   branches/parallel/ChangeLog
   branches/parallel/thread.c
   branches/parallel/thread_pthread.h
   branches/parallel/thread_win32.h
Log:
	* thread.c : add cancel blocking state feature

	* thread_pthread.h : ditto

	* thread_win32.h : ditto



Modified: branches/parallel/ChangeLog
===================================================================
--- branches/parallel/ChangeLog	2006-09-02 13:52:32 UTC (rev 546)
+++ branches/parallel/ChangeLog	2006-09-02 19:26:40 UTC (rev 547)
@@ -4,6 +4,15 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2006-09-03(Sun) 04:23:47 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* thread.c : add cancel blocking state feature
+
+	* thread_pthread.h : ditto
+
+	* thread_win32.h : ditto
+
+
 2006-09-02(Sat) 22:35:43 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* compile.c : same change of trunk

Modified: branches/parallel/thread.c
===================================================================
--- branches/parallel/thread.c	2006-09-02 13:52:32 UTC (rev 546)
+++ branches/parallel/thread.c	2006-09-02 19:26:40 UTC (rev 547)
@@ -76,10 +76,11 @@
 static void yarv_clear_interrupt_function(yarv_thread_t *th);
 
 #define BLOCKING_RANGE(th, func, body) do { \
-  if (rb_thread_blocking_start(th, func) != 0) { \
-      body; \
-      rb_thread_blocking_end(th); \
-  } \
+    if (rb_thread_blocking_start(th, func) != 0) { \
+	body; \
+	rb_thread_blocking_end(th); \
+    } \
+    YARV_CHECK_INTS_TH(th); \
 } while (0)
 
 
@@ -296,6 +297,7 @@
 {
     native_mutex_lock(&th->interrupt_lock);
     th->interrupt_function = 0;
+    yarv_remove_repeat_interrupt_func(th);
     native_mutex_unlock(&th->interrupt_lock);
 }
 
@@ -1754,11 +1756,16 @@
 {
     yarv_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */
     
-    if (vm->bufferd_signal_size && vm->main_thread->exec_signal == 0) {
-	vm->main_thread->exec_signal = rb_get_next_signal(vm);
-	thread_debug("bufferd_signal_size: %d, sig: %d\n",
-		     vm->bufferd_signal_size, vm->main_thread->exec_signal);
-	rb_thread_interrupt(vm->main_thread);
+    if (vm->bufferd_signal_size) {
+	if (vm->main_thread->exec_signal == 0) {
+	    vm->main_thread->exec_signal = rb_get_next_signal(vm);
+	    thread_debug("bufferd_signal_size: %d, sig: %d\n",
+			 vm->bufferd_signal_size, vm->main_thread->exec_signal);
+	    rb_thread_interrupt(vm->main_thread);
+	}
+	else {
+	    /* skip */
+	}
     }
 
 #if 0

Modified: branches/parallel/thread_pthread.h
===================================================================
--- branches/parallel/thread_pthread.h	2006-09-02 13:52:32 UTC (rev 546)
+++ branches/parallel/thread_pthread.h	2006-09-02 19:26:40 UTC (rev 547)
@@ -67,9 +67,11 @@
 #define native_cleanup_pop  pthread_cleanup_pop
 #define native_thread_yield() sched_yield()
 
-static void yarv_add_signal_thread_list(yarv_thread_t *th);
+static void yarv_add_repeat_interrupt_func(yarv_thread_t *th,
+					   yarv_interrupt_function_t *func);
 static void yarv_remove_signal_thread_list(yarv_thread_t *th);
-static int rb_thread_blocking_start(yarv_thread_t *th, yarv_interrupt_function_t *func);
+static int rb_thread_blocking_start(yarv_thread_t *th,
+				    yarv_interrupt_function_t *func);
 static void rb_thread_blocking_end(yarv_thread_t *th);
 
 static yarv_thread_fglock_t signal_thread_list_lock;
@@ -281,7 +283,7 @@
 }
 
 static void
-interrupt_using_posix_signal(yarv_thread_t *th)
+interrupt_using_posix_signal_i(yarv_thread_t *th)
 {
     thread_debug("interrupt_using_posix_signal (%p)\n", th->thread_id);
     if (th) {
@@ -290,6 +292,13 @@
 }
 
 static void
+interrupt_using_posix_signal(yarv_thread_t *th)
+{
+    yarv_add_repeat_interrupt_func(th, interrupt_using_posix_signal_i);
+    thread_debug("interrupt_using_posix_signal: register\n");
+}
+
+static void
 native_sleep(yarv_thread_t *th, struct timeval *tv)
 {
     int prev_status = th->status;
@@ -339,20 +348,15 @@
     thread_debug("native_sleep done\n");
 }
 
-void
-native_thread_interrupt(yarv_thread_t *th)
-{
-    yarv_add_signal_thread_list(th);
-}
-
 struct yarv_signal_thread_list {
     yarv_thread_t *th;
+    yarv_interrupt_function_t *func;
     struct yarv_signal_thread_list *prev;
     struct yarv_signal_thread_list *next;
 };
 
 static struct yarv_signal_thread_list signal_thread_list_anchor = {
-    0, 0, 0,
+    0, 0, 0, 0,
 };
 
 static void
@@ -369,8 +373,9 @@
 }
 
 static void
-yarv_add_signal_thread_list(yarv_thread_t *th)
+yarv_add_repeat_interrupt_func(yarv_thread_t *th, yarv_interrupt_function_t *func)
 {
+    thread_debug("yarv_add_repeat_interrupt_func\n");
     if (!th->native_thread_data.signal_thread_list) {
 	FGLOCK_RANGE(&signal_thread_list_lock, {
 	    struct yarv_signal_thread_list *list =
@@ -382,7 +387,8 @@
 	    }
 
 	    list->th = th;
-
+	    list->func = func;
+	    
 	    list->prev = &signal_thread_list_anchor;
 	    list->next = signal_thread_list_anchor.next;
 	    if (list->next) {
@@ -395,9 +401,10 @@
 }
 
 static void
-yarv_remove_signal_thread_list(yarv_thread_t *th)
+yarv_remove_repeat_interrupt_func(yarv_thread_t *th)
 {
     if (th->native_thread_data.signal_thread_list) {
+	thread_debug("yarv_remove_repeat_interrupt_func: start\n");
 	FGLOCK_RANGE(&signal_thread_list_lock, {
 	    struct yarv_signal_thread_list *list =
 	      (struct yarv_signal_thread_list *)
@@ -411,6 +418,7 @@
 	    list->th = 0;
 	    free(list);
 	});
+	thread_debug("yarv_remove_repeat_interrupt_func: end\n");
     }
     else {
 	/* */
@@ -442,7 +450,7 @@
 		struct yarv_signal_thread_list *list;
 		list = signal_thread_list_anchor.next;
 		while (list) {
-		    interrupt_using_posix_signal(list->th);
+		    (*list->func)(list->th);
 		    list = list->next;
 		}
 	    });

Modified: branches/parallel/thread_win32.h
===================================================================
--- branches/parallel/thread_win32.h	2006-09-02 13:52:32 UTC (rev 546)
+++ branches/parallel/thread_win32.h	2006-09-02 19:26:40 UTC (rev 547)
@@ -34,7 +34,7 @@
 #undef Sleep
 
 #define native_thread_yield() Sleep(0)
-#define yarv_remove_signal_thread_list(th)
+#define yarv_remove_repeat_interrupt_func(th)
 
 static void
 Init_native_thread()


--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]