diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | eval.c | 50 |
2 files changed, 26 insertions, 33 deletions
@@ -1,3 +1,12 @@ +Tue Dec 16 01:14:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * eval.c (catch_timer): check rb_thread_crtical in main native + thread. + + * eval.c (thread_timer): just sends signals periodically, to + prevent main native thread from receiving them in critical + section. [ruby-core:01959] + Mon Dec 15 13:32:22 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> * dir.c (check_dirname): check string safety and remove extraneous @@ -9498,9 +9498,7 @@ static int thread_init = 0; # define ruby_signal(x,y) signal((x), (y)) #endif -#if defined(PTHREAD_TIMER) -static pthread_t time_thread; - +#if defined(PTHREAD_TIMER) || defined(HAVE_SETITIMER) static void catch_timer(sig) int sig; @@ -9508,9 +9506,17 @@ catch_timer(sig) #if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL) signal(sig, catch_timer); #endif - rb_thread_schedule(); + if (!rb_thread_critical) { + if (rb_trap_immediate) { + rb_thread_schedule(); + } + else rb_thread_pending = 1; + } } +#ifdef PTHREAD_TIMER +static pthread_t time_thread; + static void* thread_timer(dummy) void *dummy; @@ -9518,17 +9524,10 @@ thread_timer(dummy) struct timespec req, rem; for (;;) { - if (!rb_thread_critical) { - if (rb_trap_immediate) { - pthread_kill(ruby_thid, SIGVTALRM); - } - else { - rb_thread_pending = 1; - } - req.tv_sec = 0; - req.tv_nsec = 10000000; - nanosleep(&req, &rem); - } + req.tv_sec = 0; + req.tv_nsec = 10000000; + nanosleep(&req, &rem); + pthread_kill(ruby_thid, SIGVTALRM); } } @@ -9541,23 +9540,7 @@ void rb_thread_stop_timer() { } -#elif defined(HAVE_SETITIMER) - -static void -catch_timer(sig) - int sig; -{ -#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL) - signal(sig, catch_timer); -#endif - if (!rb_thread_critical) { - if (rb_trap_immediate) { - rb_thread_schedule(); - } - else rb_thread_pending = 1; - } -} - +#else /* HAVE_SETITIMER */ void rb_thread_start_timer() { @@ -9581,7 +9564,8 @@ rb_thread_stop_timer() tval.it_value = tval.it_interval; setitimer(ITIMER_VIRTUAL, &tval, NULL); } -#else +#endif +#else /* !(PTHREAD_TIMER || HAVE_SETITIMER) */ int rb_thread_tick = THREAD_TICK; #endif |