From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juliusz Chroboczek Newsgroups: gmane.emacs.devel Subject: Re: semantics of thread-signal Date: Mon, 12 Dec 2016 02:21:38 +0100 Message-ID: <871sxe2b8d.fsf@irif.fr> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1481505774 28342 195.159.176.226 (12 Dec 2016 01:22:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Dec 2016 01:22:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 12 02:22:49 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 1cGFKL-0006Ga-0k for ged-emacs-devel@m.gmane.org; Mon, 12 Dec 2016 02:22:49 +0100 Original-Received: from localhost ([::1]:57850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGFKN-00031R-I4 for ged-emacs-devel@m.gmane.org; Sun, 11 Dec 2016 20:22:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGFJB-0002hw-6c for emacs-devel@gnu.org; Sun, 11 Dec 2016 20:21:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGFJ7-0005lg-5r for emacs-devel@gnu.org; Sun, 11 Dec 2016 20:21:37 -0500 Original-Received: from [195.159.176.226] (port=45929 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cGFJ6-0005lK-Vj for emacs-devel@gnu.org; Sun, 11 Dec 2016 20:21:33 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cGFJ0-000281-Aa for emacs-devel@gnu.org; Mon, 12 Dec 2016 02:21:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:zlCxLFsdK2F/JaSYvVob025gnUM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:210319 Archived-At: >> I assumed this to mean that the condition will only be delivered when >> one of these functions is called, but your comment seems to imply that >> it's meant to deliver the condition as soon as possible. > My interpretation is that mutex-lock (and the others) block the thread > until something happens (e.g., another thread calls mutex-unlock), and > thread-signal is another thing which can end the blocking (and also > trigger a signal when the thread next runs). Reasonable enough. Perhaps somebody could clarify the docs? >> if a condition is signalled just before the cleanup but after exiting >> the body, will we leak a foo? > This can't happen, because thread are cooperative. The manual says: However, the Emacs thread support has been designed in a way to later allow more fine-grained concurrency, and correct programs should not rely on cooperative threading. So if thread-signal can be delivered asynchronously, this will cause trouble when Emacs moves to kernel threads. (And this does happen. Viz. SBCL, CCL, ACL, all of which switched from userspace threading to kernel threads sometime in the last 20 years or so.) -- Juliusz