* eval.c (thread_timer): use timer by sub-thread and nanosleep.
[ruby-talk:87519] * gc.c (Init_stack): no stack adjustment for THREAD_SAFE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fe7c38c862
commit
6a3f682ff7
@ -1,3 +1,10 @@
|
|||||||
|
Sat Dec 13 18:09:42 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (thread_timer): use timer by sub-thread and nanosleep.
|
||||||
|
[ruby-talk:87519]
|
||||||
|
|
||||||
|
* gc.c (Init_stack): no stack adjustment for THREAD_SAFE.
|
||||||
|
|
||||||
Sat Dec 13 17:17:59 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Dec 13 17:17:59 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (proc_alloc): cache the created object at first time.
|
* eval.c (proc_alloc): cache the created object at first time.
|
||||||
|
82
eval.c
82
eval.c
@ -9486,7 +9486,63 @@ rb_thread_alloc(klass)
|
|||||||
return th;
|
return th;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_SETITIMER)
|
static int thread_init = 0;
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBPTHREAD) && defined(_REENTRANT)
|
||||||
|
# define PTHREAD_TIMER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(POSIX_SIGNAL)
|
||||||
|
# define ruby_signal(x,y) posix_signal((x), (y))
|
||||||
|
#else
|
||||||
|
# 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)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
catch_timer(sig)
|
catch_timer(sig)
|
||||||
int sig;
|
int sig;
|
||||||
@ -9501,12 +9557,6 @@ catch_timer(sig)
|
|||||||
else rb_thread_pending = 1;
|
else rb_thread_pending = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int rb_thread_tick = THREAD_TICK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_SETITIMER)
|
|
||||||
static int thread_init = 0;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_thread_start_timer()
|
rb_thread_start_timer()
|
||||||
@ -9531,6 +9581,8 @@ rb_thread_stop_timer()
|
|||||||
tval.it_value = tval.it_interval;
|
tval.it_value = tval.it_interval;
|
||||||
setitimer(ITIMER_VIRTUAL, &tval, NULL);
|
setitimer(ITIMER_VIRTUAL, &tval, NULL);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int rb_thread_tick = THREAD_TICK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -9550,18 +9602,18 @@ rb_thread_start_0(fn, arg, th)
|
|||||||
"can't start a new thread (frozen ThreadGroup)");
|
"can't start a new thread (frozen ThreadGroup)");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_SETITIMER)
|
|
||||||
if (!thread_init) {
|
if (!thread_init) {
|
||||||
#ifdef POSIX_SIGNAL
|
|
||||||
posix_signal(SIGVTALRM, catch_timer);
|
|
||||||
#else
|
|
||||||
signal(SIGVTALRM, catch_timer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
thread_init = 1;
|
thread_init = 1;
|
||||||
|
#if defined(HAVE_SETITIMER) || defined(PTHREAD_TIMER)
|
||||||
|
ruby_signal(SIGVTALRM, catch_timer);
|
||||||
|
|
||||||
|
#ifdef PTHREAD_TIMER
|
||||||
|
pthread_create(&time_thread, 0, thread_timer, 0);
|
||||||
|
#else
|
||||||
rb_thread_start_timer();
|
rb_thread_start_timer();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (THREAD_SAVE_CONTEXT(curr_thread)) {
|
if (THREAD_SAVE_CONTEXT(curr_thread)) {
|
||||||
return thread;
|
return thread;
|
||||||
|
7
gc.c
7
gc.c
@ -423,11 +423,11 @@ stack_growup_p(addr)
|
|||||||
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
|
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GC_WARTER_MARK 512
|
#define GC_WATER_MARK 512
|
||||||
|
|
||||||
#define CHECK_STACK(ret) do {\
|
#define CHECK_STACK(ret) do {\
|
||||||
SET_STACK_END;\
|
SET_STACK_END;\
|
||||||
(ret) = (STACK_LENGTH > STACK_LEVEL_MAX + GC_WARTER_MARK);\
|
(ret) = (STACK_LENGTH > STACK_LEVEL_MAX + GC_WATER_MARK);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1393,9 +1393,6 @@ Init_stack(addr)
|
|||||||
if (STACK_LEVEL_MAX > IA64_MAGIC_STACK_LIMIT)
|
if (STACK_LEVEL_MAX > IA64_MAGIC_STACK_LIMIT)
|
||||||
STACK_LEVEL_MAX = IA64_MAGIC_STACK_LIMIT;
|
STACK_LEVEL_MAX = IA64_MAGIC_STACK_LIMIT;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _THREAD_SAFE
|
|
||||||
STACK_LEVEL_MAX /= 4;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user