yarv-diff:113
From: ko1 atdot.net
Date: 30 Sep 2005 15:26:59 -0000
Subject: [yarv-diff:113] r269 - trunk
Author: ko1
Date: 2005-10-01 00:26:58 +0900 (Sat, 01 Oct 2005)
New Revision: 269
Modified:
trunk/ChangeLog
trunk/thread.c
trunk/thread_pthread.h
trunk/yarvcore.h
Log:
* thread.c, yarvcore.h : rename GIL (Global Interpreter Lock) to
GVL (Global VM Lock)
* thread_pthread.h : fix pthread mutex initialize
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2005-09-30 11:12:25 UTC (rev 268)
+++ trunk/ChangeLog 2005-09-30 15:26:58 UTC (rev 269)
@@ -4,6 +4,14 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2005-10-01(Sat) 00:25:28 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * thread.c, yarvcore.h : rename GIL (Global Interpreter Lock) to
+ GVL (Global VM Lock)
+
+ * thread_pthread.h : fix pthread mutex initialize
+
+
2005-09-30(Fri) 20:11:19 +0900 Koichi Sasada <ko1 atdot.net>
* thread.c : support join with timeout
Modified: trunk/thread.c
===================================================================
--- trunk/thread.c 2005-09-30 11:12:25 UTC (rev 268)
+++ trunk/thread.c 2005-09-30 15:26:58 UTC (rev 269)
@@ -17,9 +17,9 @@
------------------------------------------------------------------------
mode 2:
- A thread has mutex (GIL: Global Interpreter Lock) can run. When
- thread scheduling, running thread release GIL. If running thread
- try blocking operation, this thread must release GIL and another
+ A thread has mutex (GVL: Global VM Lock) can run. When thread
+ scheduling, running thread release GVL. If running thread
+ try blocking operation, this thread must release GVL and another
thread can continue this flow. After blocking operation, thread
must check interrupt (CHECK_INTS).
@@ -79,7 +79,7 @@
th->machine_stack_start = stack_start;
thead_debug("start: %p\n", th);
- GIL_LOCK_BEGIN();
+ GVL_LOCK_BEGIN();
yarv_set_current_running_thread(th);
thead_debug("get_lock, start: %p\n", th);
th->value = th_invoke_proc(th, proc, RARRAY(args)->len, RARRAY(args)->ptr);
@@ -87,7 +87,7 @@
thead_debug("end: %p\n", th);
rb_hash_delete(GET_VM()->living_threads, th->self);
- GIL_LOCK_END();
+ GVL_LOCK_END();
return 0;
}
@@ -163,9 +163,9 @@
}
if(argc == 0){
- GIL_UNLOCK_BEGIN();
+ GVL_UNLOCK_BEGIN();
err = native_thread_join(th->thread_id, 0);
- GIL_UNLOCK_END();
+ GVL_UNLOCK_END();
switch(err){
case EDEADLK:
@@ -181,9 +181,9 @@
limit += interval.tv_usec * 1e-6;
while(1){
- GIL_UNLOCK_BEGIN();
+ GVL_UNLOCK_BEGIN();
sleep_for_polling();
- GIL_UNLOCK_END();
+ GVL_UNLOCK_END();
if(th->status == THREAD_KILLED){
break;
@@ -220,9 +220,9 @@
void
rb_thread_sleep_forever()
{
- GIL_UNLOCK_BEGIN();
+ GVL_UNLOCK_BEGIN();
pause();
- GIL_UNLOCK_END();
+ GVL_UNLOCK_END();
}
static double
@@ -282,9 +282,9 @@
double date;
CSL_UNLOCK_BEGIN();
- GIL_UNLOCK_BEGIN();
+ GVL_UNLOCK_BEGIN();
sleep_timeval(time);
- GIL_UNLOCK_END();
+ GVL_UNLOCK_END();
CSL_UNLOCK_END();
}
Modified: trunk/thread_pthread.h
===================================================================
--- trunk/thread_pthread.h 2005-09-30 11:12:25 UTC (rev 268)
+++ trunk/thread_pthread.h 2005-09-30 15:26:58 UTC (rev 269)
@@ -10,9 +10,12 @@
#define native_mutex_unlock pthread_mutex_unlock
#define native_thread_join pthread_join
-#define yarv_thread_lock_initialize(lock) \
- ((lock) = PTHREAD_MUTEX_INITIALIZER)
+#define yarv_thread_lock_initialize(lock) do { \
+ pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER; \
+ ((lock) = _lock); \
+} while (0)
+
#define native_cleanup_push pthread_cleanup_push
#define native_cleanup_pop pthread_cleanup_pop
Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h 2005-09-30 11:12:25 UTC (rev 268)
+++ trunk/yarvcore.h 2005-09-30 15:26:58 UTC (rev 269)
@@ -453,19 +453,19 @@
#include "yarv.h"
-#define GIL_LOCK_BEGIN() do { \
+#define GVL_LOCK_BEGIN() do { \
native_mutex_lock(&GET_VM()->global_interpreter_lock)
-#define GIL_LOCK_END() \
+#define GVL_LOCK_END() \
native_mutex_unlock(&GET_VM()->global_interpreter_lock); \
} while(0)
-#define GIL_UNLOCK_BEGIN() do { \
+#define GVL_UNLOCK_BEGIN() do { \
yarv_thread_t *_th_stored = GET_THREAD(); \
yarv_save_machine_context(_th_stored); \
native_mutex_unlock(&GET_VM()->global_interpreter_lock)
-#define GIL_UNLOCK_END() \
+#define GVL_UNLOCK_END() \
native_mutex_lock(&GET_VM()->global_interpreter_lock); \
yarv_set_current_running_thread(_th_stored); \
} while(0)
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml