ruby-changes:52371
From: normal <ko1@a...>
Date: Tue, 28 Aug 2018 08:40:04 +0900 (JST)
Subject: [ruby-changes:52371] normal:r64580 (trunk): thread_pthread.c: document sigwait_th and sigwait_fd [ci skip]
normal 2018-08-28 08:39:58 +0900 (Tue, 28 Aug 2018) New Revision: 64580 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64580 Log: thread_pthread.c: document sigwait_th and sigwait_fd [ci skip] This is an important concept to document, I think. Modified files: trunk/thread_pthread.c Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 64579) +++ thread_pthread.c (revision 64580) @@ -134,6 +134,13 @@ static void threadptr_trap_interrupt(rb_ https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L134 /* 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) { ret https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L1387 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/