1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* thread.c, vm_core.h, vm.c, thread_pthread.c, thread_win32.c: add

deadlock detection.  [ruby-dev:35044]

* bootstraptest/test_thread.rb: add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-06-12 13:01:38 +00:00
parent 2b66844f48
commit 6f5aaff73b
7 changed files with 294 additions and 40 deletions

View file

@ -402,7 +402,7 @@ ubf_select(void *ptr)
#endif
static void
native_sleep(rb_thread_t *th, struct timeval *tv)
native_sleep(rb_thread_t *th, struct timeval *tv, int deadlockable)
{
int prev_status = th->status;
struct timespec ts;
@ -418,7 +418,14 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
}
}
th->status = THREAD_STOPPED;
if (!tv && deadlockable) {
th->status = THREAD_STOPPED_FOREVER;
th->vm->sleeper++;
rb_check_deadlock(th->vm);
}
else {
th->status = THREAD_STOPPED;
}
thread_debug("native_sleep %ld\n", tv ? tv->tv_sec : -1);
GVL_UNLOCK_BEGIN();
@ -455,9 +462,10 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
th->unblock.arg = 0;
pthread_mutex_unlock(&th->interrupt_lock);
th->status = prev_status;
}
GVL_UNLOCK_END();
th->status = prev_status;
if (!tv && deadlockable) th->vm->sleeper--;
RUBY_VM_CHECK_INTS();
thread_debug("native_sleep done\n");