emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delivering SIGIO when several threads are active?


From: Paul Eggert
Subject: Re: Delivering SIGIO when several threads are active?
Date: Fri, 30 Dec 2016 13:05:44 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

Eli Zaretskii wrote:
what if another thread
is waiting on the keyboard descriptor and wants to handle keyboard
input, or wants to receive X events?

That depends on what is meant by "waiting on the keyboard descriptor" and "wants to receive X events". At the low level, if the other thread was not involved in delivering the signal and is calling pselect on the keyboard descriptor while keyboard input occurs, pselect will return successfully without being interrupted. Similarly for X events, I assume.

On GNU/Linux, process signals get sent to the main thread unless the main thread
is blocking them (or if a few less-common situations arise, e.g., the main
thread is exiting).
And what happens in those exceptional cases?

Typically the signal gets sent to some other thread. (There are exceptions to this, too; it's complicated.)

Hmm, I see that the recent changes use mixed terminology. Until now, Emacs has
called the initial thread the "main thread", but the recent code sometimes calls
it the "primary thread". We shouldn't have two names for the same thing. I'll
look into fixing that.
"Primary thread" is the name of the main thread.

How so? Threads don't have names in Emacs.

In POSIX it's called the "initial thread". Emacs has long used "main thread" internally to describe the same thing; this is a common alternative name, and it's shorter so it's OK as long as we're consistent about it. Using a *third* phrase "primary thread" for the same thing in some places adds needless confusion.

Evidently the longstanding variable named main_thread (which is a thread ID) got in the way of the names that thread.c should have used, and thread.c instead used names like "primary_thread". I'll try to lessen the confusion by changing the longstanding variable name to "main_thread_id" (which is more-accurate anyway). This will give thread.c the freedom to use names like "main_thread" for its own purposes. Also, it'll avoid an unnecessary duplicate of the main thread ID in emacs-module.c. I installed the attached patch to do all this.

Attachment: 0001-Rename-main_thread-to-main_thread_id-and-simplify.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]