summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 722ce44487..8a4825548b 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1369,7 +1369,7 @@ setup_communication_pipe(void)
* @pre the calling context is in the timer thread.
*/
static inline void
-timer_thread_sleep(rb_vm_t *vm)
+timer_thread_sleep(rb_global_vm_lock_t* gvl)
{
int result;
int need_polling;
@@ -1382,15 +1382,7 @@ timer_thread_sleep(rb_vm_t *vm)
need_polling = !ubf_threads_empty();
- if (SIGCHLD_LOSSY && !need_polling) {
- rb_native_mutex_lock(&vm->waitpid_lock);
- if (!list_empty(&vm->waiting_pids) || !list_empty(&vm->waiting_grps)) {
- need_polling = 1;
- }
- rb_native_mutex_unlock(&vm->waitpid_lock);
- }
-
- if (vm->gvl.waiting > 0 || need_polling) {
+ if (gvl->waiting > 0 || need_polling) {
/* polling (TIME_QUANTUM_USEC usec) */
result = poll(pollfds, 1, TIME_QUANTUM_USEC/1000);
}
@@ -1429,7 +1421,7 @@ static rb_nativethread_lock_t timer_thread_lock;
static rb_nativethread_cond_t timer_thread_cond;
static inline void
-timer_thread_sleep(rb_vm_t *unused)
+timer_thread_sleep(rb_global_vm_lock_t* unused)
{
struct timespec ts;
ts.tv_sec = 0;
@@ -1493,14 +1485,7 @@ native_set_another_thread_name(rb_nativethread_id_t thread_id, VALUE name)
static void *
thread_timer(void *p)
{
- rb_vm_t *vm = p;
-#ifdef HAVE_PTHREAD_SIGMASK /* mainly to enable SIGCHLD */
- {
- sigset_t mask;
- sigemptyset(&mask);
- pthread_sigmask(SIG_SETMASK, &mask, NULL);
- }
-#endif
+ rb_global_vm_lock_t *gvl = (rb_global_vm_lock_t *)p;
if (TT_DEBUG) WRITE_CONST(2, "start timer thread\n");
@@ -1522,7 +1507,7 @@ thread_timer(void *p)
if (TT_DEBUG) WRITE_CONST(2, "tick\n");
/* wait */
- timer_thread_sleep(vm);
+ timer_thread_sleep(gvl);
}
#if USE_SLEEPY_TIMER_THREAD
CLOSE_INVALIDATE(normal[0]);
@@ -1594,7 +1579,7 @@ rb_thread_create_timer_thread(void)
if (timer_thread.created) {
rb_bug("rb_thread_create_timer_thread: Timer thread was already created\n");
}
- err = pthread_create(&timer_thread.id, &attr, thread_timer, vm);
+ err = pthread_create(&timer_thread.id, &attr, thread_timer, &vm->gvl);
pthread_attr_destroy(&attr);
if (err == EINVAL) {
@@ -1605,7 +1590,7 @@ rb_thread_create_timer_thread(void)
* default stack size is enough for them:
*/
stack_size = 0;
- err = pthread_create(&timer_thread.id, NULL, thread_timer, vm);
+ err = pthread_create(&timer_thread.id, NULL, thread_timer, &vm->gvl);
}
if (err != 0) {
rb_warn("pthread_create failed for timer: %s, scheduling broken",
@@ -1786,22 +1771,4 @@ rb_thread_create_mjit_thread(void (*child_hook)(void), void (*worker_func)(void)
return ret;
}
-#define USE_NATIVE_SLEEP_COND (1)
-
-#if USE_NATIVE_SLEEP_COND
-rb_nativethread_cond_t *
-rb_sleep_cond_get(const rb_execution_context_t *ec)
-{
- rb_thread_t *th = rb_ec_thread_ptr(ec);
-
- return &th->native_thread_data.sleep_cond;
-}
-
-void
-rb_sleep_cond_put(rb_nativethread_cond_t *cond)
-{
- /* no-op */
-}
-#endif /* USE_NATIVE_SLEEP_COND */
-
#endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */