summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 23:39:58 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-27 23:39:58 (GMT)
commitfcaf874585df8984a23fb89a81bff522cc0ea52e (patch)
tree00988875eddf262efab93cd4943d56654a7aaacd /thread_pthread.c
parent1b1274f728c268fba30685966174ff813115ae11 (diff)
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
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index dca30bd..4f5bc00 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;