mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5fd915fc83
commit
ee72d97e99
2 changed files with 39 additions and 46 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
|
||||
|
|
76
eval.c
76
eval.c
|
@ -9498,51 +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;
|
||||
|
||||
static void
|
||||
catch_timer(sig)
|
||||
int sig;
|
||||
{
|
||||
#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
|
||||
signal(sig, catch_timer);
|
||||
#endif
|
||||
rb_thread_schedule();
|
||||
}
|
||||
|
||||
static void*
|
||||
thread_timer(dummy)
|
||||
void *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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_thread_start_timer()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
rb_thread_stop_timer()
|
||||
{
|
||||
}
|
||||
#elif defined(HAVE_SETITIMER)
|
||||
|
||||
#if defined(PTHREAD_TIMER) || defined(HAVE_SETITIMER)
|
||||
static void
|
||||
catch_timer(sig)
|
||||
int sig;
|
||||
|
@ -9558,6 +9514,33 @@ catch_timer(sig)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef PTHREAD_TIMER
|
||||
static pthread_t time_thread;
|
||||
|
||||
static void*
|
||||
thread_timer(dummy)
|
||||
void *dummy;
|
||||
{
|
||||
struct timespec req, rem;
|
||||
|
||||
for (;;) {
|
||||
req.tv_sec = 0;
|
||||
req.tv_nsec = 10000000;
|
||||
nanosleep(&req, &rem);
|
||||
pthread_kill(ruby_thid, SIGVTALRM);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
rb_thread_start_timer()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
rb_thread_stop_timer()
|
||||
{
|
||||
}
|
||||
#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
|
||||
|
||||
|
|
Loading…
Reference in a new issue