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

ruby-changes:14791

From: nobu <ko1@a...>
Date: Sat, 13 Feb 2010 07:18:42 +0900 (JST)
Subject: [ruby-changes:14791] Ruby:r26653 (mvm): * (ruby_vm_send_signal): deal with signals properly.

nobu	2010-02-13 07:11:59 +0900 (Sat, 13 Feb 2010)

  New Revision: 26653

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

  Log:
    * (ruby_vm_send_signal): deal with signals properly.

  Modified files:
    branches/mvm/ChangeLog
    branches/mvm/thread.c
    branches/mvm/vm_core.h

Index: mvm/ChangeLog
===================================================================
--- mvm/ChangeLog	(revision 26652)
+++ mvm/ChangeLog	(revision 26653)
@@ -1,3 +1,7 @@
+Sat Feb 13 07:11:57 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* (ruby_vm_send_signal): deal with signals properly.
+
 Sat Nov 21 01:03:39 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* thread.c (rb_queue_mark): mark possible objects.
Index: mvm/vm_core.h
===================================================================
--- mvm/vm_core.h	(revision 26652)
+++ mvm/vm_core.h	(revision 26653)
@@ -733,11 +733,18 @@
 #error "unsupported thread model"
 #endif
 
-#define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= 0x02)
-#define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= 0x01)
-#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04)
-#define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
+enum {
+    ruby_vm_timer_bit = 0x01,
+    ruby_vm_interrupt_bit = 0x02,
+    ruby_vm_finalizer_bit = 0x04,
+    ruby_vm_signal_bit = 0x08
+};
 
+#define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= ruby_vm_interrupt_bit)
+#define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= ruby_vm_timer_bit)
+#define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= ruby_vm_finalizer_bit)
+#define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & ruby_vm_interrupt_bit)
+
 void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
 void rb_threadptr_signal_exit(rb_thread_t *th);
 void rb_threadptr_execute_interrupts(rb_thread_t *);
Index: mvm/thread.c
===================================================================
--- mvm/thread.c	(revision 26652)
+++ mvm/thread.c	(revision 26653)
@@ -1379,7 +1379,7 @@
     rb_vm_t *vm = GET_VM();
 
     if (vm->main_thread == th) {
-	while (rb_signal_buff_size() && !(th->interrupt_flag & 0x08)) {
+	while (rb_signal_buff_size() && !(th->interrupt_flag & ruby_vm_signal_bit)) {
 	    native_thread_yield();
 	}
     }
@@ -1388,8 +1388,8 @@
 
     while (th->interrupt_flag) {
 	enum rb_thread_status status = th->status;
-	int timer_interrupt = th->interrupt_flag & 0x01;
-	int finalizer_interrupt = th->interrupt_flag & 0x04;
+	int timer_interrupt = th->interrupt_flag & ruby_vm_timer_bit;
+	int finalizer_interrupt = th->interrupt_flag & ruby_vm_finalizer_bit;
 	void *exec_signal;
 
 	th->status = THREAD_RUNNABLE;
@@ -2806,11 +2806,11 @@
 
     if (sig <= 0 || sig >= RUBY_NSIG) return -1;
     mth = vm->main_thread;
-    if (mth->interrupt_flag) return -1;
+    if (mth->interrupt_flag & ruby_vm_signal_bit) return -1;
     prev_status = mth->status;
     thread_debug("main_thread: %s, sig: %d\n",
 		 thread_status_name(prev_status), sig);
-    mth->interrupt_flag |= 0x08;
+    mth->interrupt_flag |= ruby_vm_signal_bit;
     rb_queue_push(&mth->queue.signal, (void *)INT2FIX(sig));
     if (mth->status != THREAD_KILLED) mth->status = THREAD_RUNNABLE;
     rb_threadptr_interrupt(mth);

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

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