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

yarv-diff:388

From: ko1 atdot.net
Date: 5 Sep 2006 22:22:50 +0900
Subject: [yarv-diff:388] r555 - branches/parallel

Author: ko1
Date: 2006-09-05 22:22:49 +0900 (Tue, 05 Sep 2006)
New Revision: 555

Modified:
   branches/parallel/ChangeLog
   branches/parallel/io.c
   branches/parallel/thread.c
   branches/parallel/thread_pthread.h
Log:
	* thread.c : add rb_thread_write

	* io.c : use an above function

	* thread_pthread.h : move BLOCKING_RANGE definition



Modified: branches/parallel/ChangeLog
===================================================================
--- branches/parallel/ChangeLog	2006-09-05 02:41:29 UTC (rev 554)
+++ branches/parallel/ChangeLog	2006-09-05 13:22:49 UTC (rev 555)
@@ -4,6 +4,15 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2006-09-05(Tue) 22:16:37 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* thread.c : add rb_thread_write
+
+	* io.c : use an above function
+
+	* thread_pthread.h : move BLOCKING_RANGE definition
+
+
 2006-09-05(Tue) 11:37:11 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* class.c : add rb_add_method_ts, rb_define_private_method_ts, 

Modified: branches/parallel/io.c
===================================================================
--- branches/parallel/io.c	2006-09-05 02:41:29 UTC (rev 554)
+++ branches/parallel/io.c	2006-09-05 13:22:49 UTC (rev 555)
@@ -15,6 +15,7 @@
 #include "ruby.h"
 #include "rubyio.h"
 #include "rubysig.h"
+
 #include <ctype.h>
 #include <errno.h>
 
@@ -581,9 +582,12 @@
             wsplit_p(fptr)) {
             l = PIPE_BUF;
         }
-        TRAP_BEG;
-	r = write(fptr->fd, RSTRING(str)->ptr+offset, l);
-        TRAP_END; /* xxx: signal handler may modify given string. */
+	
+        //TRAP_BEG;
+	//r = write(fptr->fd, RSTRING(str)->ptr+offset, l);
+        //TRAP_END; /* xxx: signal handler may modify given string. */
+	r = rb_thread_write(fptr->fd, RSTRING(str)->ptr+offset, l);
+	
         if (r == n) return len;
         if (0 <= r) {
             offset += r;

Modified: branches/parallel/thread.c
===================================================================
--- branches/parallel/thread.c	2006-09-05 02:41:29 UTC (rev 554)
+++ branches/parallel/thread.c	2006-09-05 13:22:49 UTC (rev 555)
@@ -75,16 +75,6 @@
 static void yarv_set_interrupt_function(yarv_thread_t *th, yarv_interrupt_function_t *func);
 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); \
-    } \
-    YARV_CHECK_INTS_TH(th); \
-} while (0)
-
-
-
 #if THREAD_DEBUG
 void thread_debug(const char *fmt, ...);
 #else
@@ -150,7 +140,7 @@
 static void __attribute__((destructor))
      pr_show(void)
 {
-    //printf("profile_confilict: %d\n", profile_confilict);
+    fprintf(stderr, "profile_confilict: %d\n", profile_confilict);
 }
 
 static int g_spinlock_count;
@@ -1718,6 +1708,16 @@
 }
 
 int
+rb_thread_write(int fd, char *d, size_t len)
+{
+    int r;
+    BLOCKING_RANGE(GET_THREAD(), 0, {
+	r = write(fd, d, len);
+    });
+    return r;
+}
+
+int
 rb_thread_select(int max, fd_set * read, fd_set * write, fd_set * except,
 		 struct timeval *timeout)
 {

Modified: branches/parallel/thread_pthread.h
===================================================================
--- branches/parallel/thread_pthread.h	2006-09-05 02:41:29 UTC (rev 554)
+++ branches/parallel/thread_pthread.h	2006-09-05 13:22:49 UTC (rev 555)
@@ -61,6 +61,15 @@
     if (__freeed) rb_thread_global_lock_acquire(th_); \
 } while (0)
 
+#define BLOCKING_RANGE(th, func, body) do { \
+    yarv_thread_t *__th = th; \
+    if (rb_thread_blocking_start(__th, func) != 0) { \
+	body; \
+	rb_thread_blocking_end(__th); \
+    } \
+    YARV_CHECK_INTS_TH(__th); \
+} while (0)
+
 #endif /* THREAD_PTHREAD_H_INCLUDED */
 
 
@@ -80,12 +89,6 @@
 	    rb_bug("pthread_mutex_lock: %d", r);
 	}
     }
-    else if (r == 0) {
-	/* success */
-    }
-    else {
-	rb_bug("pthread_mutex_trylock: %d", r);
-    }
 }
 
 void
@@ -97,7 +100,7 @@
     }
 }
 
-int
+inline int
 native_mutex_trylock(yarv_thread_lock_t *lock)
 {
     int r;


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

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