From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Delivering SIGIO when several threads are active? Date: Fri, 30 Dec 2016 13:45:31 -0800 Organization: UCLA Computer Science Department Message-ID: References: <8360m1u311.fsf@gnu.org> <8e01d8c5-66fa-fcb8-ef0e-74ca10a72317@cs.ucla.edu> <83wpehs1pm.fsf@gnu.org> <90c023d2-7e44-d159-9249-0e749c05a584@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------469B6FD0D568A2BD2A30C972" X-Trace: blaine.gmane.org 1483134382 12091 195.159.176.226 (30 Dec 2016 21:46:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2016 21:46:22 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 30 22:46:16 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cN509-00023b-7A for ged-emacs-devel@m.gmane.org; Fri, 30 Dec 2016 22:46:13 +0100 Original-Received: from localhost ([::1]:41607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN50D-0002Db-U8 for ged-emacs-devel@m.gmane.org; Fri, 30 Dec 2016 16:46:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN4zd-0002DW-26 for emacs-devel@gnu.org; Fri, 30 Dec 2016 16:45:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN4za-0003js-VX for emacs-devel@gnu.org; Fri, 30 Dec 2016 16:45:40 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:60626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cN4zW-0003hs-TK; Fri, 30 Dec 2016 16:45:35 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 661D916015B; Fri, 30 Dec 2016 13:45:33 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ngev1i_np68D; Fri, 30 Dec 2016 13:45:32 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 38CC9160161; Fri, 30 Dec 2016 13:45:32 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z-NC4Cz2angJ; Fri, 30 Dec 2016 13:45:32 -0800 (PST) Original-Received: from [192.168.1.9] (unknown [47.153.178.162]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 18A9616015B; Fri, 30 Dec 2016 13:45:32 -0800 (PST) In-Reply-To: <90c023d2-7e44-d159-9249-0e749c05a584@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211008 Archived-At: This is a multi-part message in MIME format. --------------469B6FD0D568A2BD2A30C972 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > This will give thread.c the freedom to use names like "main_thread" for its own > purposes. I installed the attached further patch to do that. --------------469B6FD0D568A2BD2A30C972 Content-Type: text/x-diff; name="0001-Rename-primary_thread-to-main_thread.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Rename-primary_thread-to-main_thread.patch" >From ddb1ab4b661358f6f91b96fef132fbb82b7d25dc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 30 Dec 2016 13:42:38 -0800 Subject: [PATCH] Rename primary_thread to main_thread This avoids the confusion of using two different phrases "main thread" and "primary thread" internally to mean the same thing. See: http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg01142.html * src/thread.c (main_thread): Rename from primary_thread, since the new name no longer clashes with main_thread_id and Emacs internals normally call this the "main thread". (init_main_thread): Rename from init_primary_thread. (main_thread_p): Rename from primary_thread_p. All uses changed. --- src/alloc.c | 4 ++-- src/thread.c | 40 ++++++++++++++++++++-------------------- src/thread.h | 2 +- src/w32.h | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 121d704..d74c4be 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6404,7 +6404,7 @@ mark_object (Lisp_Object arg) #ifdef GC_CHECK_MARKED_OBJECTS m = mem_find (po); - if (m == MEM_NIL && !SUBRP (obj) && !primary_thread_p (po)) + if (m == MEM_NIL && !SUBRP (obj) && !main_thread_p (po)) emacs_abort (); #endif /* GC_CHECK_MARKED_OBJECTS */ @@ -6416,7 +6416,7 @@ mark_object (Lisp_Object arg) if (pvectype != PVEC_SUBR && pvectype != PVEC_BUFFER - && !primary_thread_p (po)) + && !main_thread_p (po)) CHECK_LIVE (live_vector_p); switch (pvectype) diff --git a/src/thread.c b/src/thread.c index 560d2cf..9a1198a 100644 --- a/src/thread.c +++ b/src/thread.c @@ -26,11 +26,11 @@ along with GNU Emacs. If not, see . */ #include "coding.h" #include "syssignal.h" -static struct thread_state primary_thread; +static struct thread_state main_thread; -struct thread_state *current_thread = &primary_thread; +struct thread_state *current_thread = &main_thread; -static struct thread_state *all_threads = &primary_thread; +static struct thread_state *all_threads = &main_thread; static sys_mutex_t global_lock; @@ -927,41 +927,41 @@ thread_check_current_buffer (struct buffer *buffer) static void -init_primary_thread (void) +init_main_thread (void) { - primary_thread.header.size + main_thread.header.size = PSEUDOVECSIZE (struct thread_state, m_stack_bottom); - XSETPVECTYPE (&primary_thread, PVEC_THREAD); - primary_thread.m_last_thing_searched = Qnil; - primary_thread.m_saved_last_thing_searched = Qnil; - primary_thread.name = Qnil; - primary_thread.function = Qnil; - primary_thread.error_symbol = Qnil; - primary_thread.error_data = Qnil; - primary_thread.event_object = Qnil; + XSETPVECTYPE (&main_thread, PVEC_THREAD); + main_thread.m_last_thing_searched = Qnil; + main_thread.m_saved_last_thing_searched = Qnil; + main_thread.name = Qnil; + main_thread.function = Qnil; + main_thread.error_symbol = Qnil; + main_thread.error_data = Qnil; + main_thread.event_object = Qnil; } bool -primary_thread_p (void *ptr) +main_thread_p (void *ptr) { - return (ptr == &primary_thread) ? true : false; + return ptr == &main_thread; } void init_threads_once (void) { - init_primary_thread (); + init_main_thread (); } void init_threads (void) { - init_primary_thread (); - sys_cond_init (&primary_thread.thread_condvar); + init_main_thread (); + sys_cond_init (&main_thread.thread_condvar); sys_mutex_init (&global_lock); sys_mutex_lock (&global_lock); - current_thread = &primary_thread; - primary_thread.thread_id = sys_thread_self (); + current_thread = &main_thread; + main_thread.thread_id = sys_thread_self (); } void diff --git a/src/thread.h b/src/thread.h index 9472ae3..e6dc668 100644 --- a/src/thread.h +++ b/src/thread.h @@ -285,7 +285,7 @@ extern void maybe_reacquire_global_lock (void); extern void init_threads_once (void); extern void init_threads (void); extern void syms_of_threads (void); -extern bool primary_thread_p (void *); +extern bool main_thread_p (void *); typedef int select_func (int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); diff --git a/src/w32.h b/src/w32.h index c73ff30..03dee09 100644 --- a/src/w32.h +++ b/src/w32.h @@ -89,7 +89,7 @@ typedef struct _child_process terminate it by sys_kill. */ HWND hwnd; /* Information about subprocess returned by CreateProcess. Includes - handles to the subprocess and its primary thread, and the + handles to the subprocess and its main thread, and the corresponding process ID and thread ID numbers. The PID is mirrored by the 'pid' member above. The process handle is used to wait on it. */ -- 2.7.4 --------------469B6FD0D568A2BD2A30C972--