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

yarv-diff:329

From: ko1 atdot.net
Date: 5 May 2006 05:07:41 -0000
Subject: [yarv-diff:329] r496 - in trunk: . test/ruby

Author: ko1
Date: 2006-05-05 14:07:40 +0900 (Fri, 05 May 2006)
New Revision: 496

Modified:
   trunk/
   trunk/ChangeLog
   trunk/test/ruby/test_signal.rb
   trunk/thread.c
   trunk/thread_win32.h
Log:
 r768@lermite:  ko1 | 2006-05-05 14:06:17 +0900
 	* test/ruby/test_signal.rb : disable a test
 
 	* thread.c : do trylock before lock on mutex_lock
 
 	* thread_win32.h : use CriticalSection instead of Mutex
 



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:765
   + 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:768

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-05-04 18:35:00 UTC (rev 495)
+++ trunk/ChangeLog	2006-05-05 05:07:40 UTC (rev 496)
@@ -4,6 +4,15 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2006-05-05(Fri) 13:59:00 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* test/ruby/test_signal.rb : disable a test
+
+	* thread.c : do trylock before lock on mutex_lock
+
+	* thread_win32.h : use CriticalSection instead of Mutex
+
+
 2006-05-05(Fri) 03:03:22 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* common.mk : vtune rule make run test.rb

Modified: trunk/test/ruby/test_signal.rb
===================================================================
--- trunk/test/ruby/test_signal.rb	2006-05-04 18:35:00 UTC (rev 495)
+++ trunk/test/ruby/test_signal.rb	2006-05-05 05:07:40 UTC (rev 496)
@@ -34,7 +34,8 @@
 
   def test_exit_action
     return unless have_fork?	# snip this test
-    assert(false, "test_exit_action doesn't work on cygwin") if /cygwin/ =~ RUBY_PLATFORM
+    # assert(false, "test_exit_action doesn't work on cygwin") if /cygwin/ =~ RUBY_PLATFORM
+    assert(false, "This tests doesn't work on YARV.")
     begin
       r, w = IO.pipe
       r0, w0 = IO.pipe

Modified: trunk/thread.c
===================================================================
--- trunk/thread.c	2006-05-04 18:35:00 UTC (rev 495)
+++ trunk/thread.c	2006-05-05 05:07:40 UTC (rev 496)
@@ -1862,7 +1862,13 @@
 	rb_raise(rb_eThreadError, "deadlock; recursive locking");
     }
 
-    GVL_UNLOCK_RANGE(native_mutex_lock(&mutex->lock));
+    if (native_mutex_trylock(&mutex->lock) != 0) {
+	/* can't cancel */
+	GVL_UNLOCK_BEGIN();
+	native_mutex_lock(&mutex->lock);
+	GVL_UNLOCK_END();
+    }
+
     mutex->th = GET_THREAD();
     return self;
 }

Modified: trunk/thread_win32.h
===================================================================
--- trunk/thread_win32.h	2006-05-04 18:35:00 UTC (rev 495)
+++ trunk/thread_win32.h	2006-05-05 05:07:40 UTC (rev 496)
@@ -5,8 +5,11 @@
 
 #include <windows.h>
 
+WINBASEAPI BOOL WINAPI
+TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
+
 typedef HANDLE yarv_thread_id_t;
-typedef HANDLE yarv_thread_lock_t;
+typedef CRITICAL_SECTION yarv_thread_lock_t;
 
 int native_mutex_lock(yarv_thread_lock_t *);
 int native_mutex_unlock(yarv_thread_lock_t *);
@@ -128,8 +131,8 @@
 int
 native_mutex_lock(yarv_thread_lock_t *lock)
 {
+#if USE_WIN32_MUTEX
     DWORD result;
-
     while (1) {
 	thread_debug("native_mutex_lock: %p\n", *lock);
 	result = w32_wait_event(*lock, INFINITE, 0);
@@ -155,21 +158,32 @@
 	}
     }
     return 0;
+#else
+    EnterCriticalSection(lock);
+    return 0;
+#endif
 }
 
 int
 native_mutex_unlock(yarv_thread_lock_t *lock)
 {
+#if USE_WIN32_MUTEX
     thread_debug("release mutex: %p\n", *lock);
     return ReleaseMutex(*lock);
+#else
+    LeaveCriticalSection(lock);
+    return 0;
+#endif
 }
 
 int
 native_mutex_trylock(yarv_thread_lock_t *lock)
 {
+#if USE_WIN32MUTEX
     int result;
     thread_debug("native_mutex_trylock: %p\n", *lock);
     result = w32_wait_event(*lock, 1, 0);
+    thread_debug("native_mutex_trylock result: %d\n", result);
     switch (result) {
     case WAIT_OBJECT_0:
 	return 0;
@@ -177,13 +191,20 @@
 	return EBUSY;
     }
     return EINVAL;
+#else
+    return TryEnterCriticalSection(lock) == 0;
+#endif
 }
 
 void
 native_mutex_initialize(yarv_thread_lock_t *lock)
 {
+#if USE_WIN32MUTEX
     *lock = CreateMutex(NULL, FALSE, NULL);
     // thread_debug("initialize mutex: %p\n", *lock);
+#else
+    InitializeCriticalSection(lock);
+#endif
 }
 
 NOINLINE(static int


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

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