From fcaf874585df8984a23fb89a81bff522cc0ea52e Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 27 Aug 2018 23:39:58 +0000 Subject: thread_pthread.c: document sigwait_th and sigwait_fd [ci skip] This is an important concept to document, I think. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/thread_pthread.c b/thread_pthread.c index dca30bd026..4f5bc001f4 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -134,6 +134,13 @@ static void threadptr_trap_interrupt(rb_thread_t *); /* for testing, and in case we come across a platform w/o pipes: */ #define BUSY_WAIT_SIGNALS (0) + +/* + * sigwait_th is the thread which owns sigwait_fd and sleeps on it + * (using ppoll). MJIT worker can be sigwait_th==0, so we initialize + * it to THREAD_INVALID at startup and fork time. It is the ONLY thread + * allowed to read from sigwait_fd, otherwise starvation can occur. + */ #define THREAD_INVALID ((const rb_thread_t *)-1) static const rb_thread_t *sigwait_th; @@ -1380,7 +1387,7 @@ static int ubf_threads_empty(void) { return 1; } static struct { /* pipes are closed in forked children when owner_process does not match */ - int normal[2]; + int normal[2]; /* [0] == sigwait_fd */ /* volatile for signal handler use: */ volatile rb_pid_t owner_process; -- cgit v1.2.3