From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.devel Subject: Re: Concurrency, again Date: Wed, 19 Oct 2016 03:02:20 -0400 Message-ID: <5DF186E8-093B-425D-8875-4480BDE081E0@raeburn.org> References: <87wq97i78i.fsf@earlgrey.lan> <86k2dk77w6.fsf@molnjunk.nocrew.org> <9D64B8EA-DB52-413D-AE6A-264416C391F3@iotcl.com> <83int1g0s5.fsf@gnu.org> <83twckekqq.fsf@gnu.org> <874m4aic0g.fsf@tromey.com> <7D150317-7A01-464D-8352-942631A3116B@raeburn.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_DB2865BD-936E-4545-A9F8-8802453EC5FC" X-Trace: blaine.gmane.org 1476860793 32553 195.159.176.226 (19 Oct 2016 07:06:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Oct 2016 07:06:33 +0000 (UTC) Cc: Emacs-Devel devel To: Alan Third Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 19 09:06:29 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 1bwkx3-00067v-Qu for ged-emacs-devel@m.gmane.org; Wed, 19 Oct 2016 09:06:14 +0200 Original-Received: from localhost ([::1]:45981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwkx6-0007mU-0L for ged-emacs-devel@m.gmane.org; Wed, 19 Oct 2016 03:06:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwktQ-0005Z6-4d for emacs-devel@gnu.org; Wed, 19 Oct 2016 03:02:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwktN-0000ru-0e for emacs-devel@gnu.org; Wed, 19 Oct 2016 03:02:28 -0400 Original-Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]:34793) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwktM-0000rM-Mm for emacs-devel@gnu.org; Wed, 19 Oct 2016 03:02:24 -0400 Original-Received: by mail-qk0-x235.google.com with SMTP id f128so20501002qkb.1 for ; Wed, 19 Oct 2016 00:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raeburn-org.20150623.gappssmtp.com; s=20150623; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=jb8cVqrNQKENKs0ckzyKvdfatfQ3hCYxoNQy2OQ5BVg=; b=RIEzrZ8Aow1JdtcakeRzYkMSD6YqFd13J8T0trZA2Xuuc6F5fq3EWe2TPzmAVbp8Ke k6W4RKXFQPFnc0waDavXSGliyprlfxGfxIuYl1lz4SHqw0mX23emwsJqfSv2xUmVahSu 1wqznjj9qZ7EJIyq0j0pJGPkixsXT9YysqvLfnfkWh/Jq8POdd/XMA+9wScotDvyVgOi LPGsHKoaKSkhbPZB4bvyWihrBd5fNnOfXUfuRvZLKodk08n0HLYmti5VZbIDV0KmU9Rm VnjOw7Vw0gH7YASop8VAT5bRDEjVqDwk13MunuwvhSID8q5VhDMKTCRcj+oH/BEeZQRP zC2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=jb8cVqrNQKENKs0ckzyKvdfatfQ3hCYxoNQy2OQ5BVg=; b=TeQZQq5hu1JG0Z9NKattIF89h1Rb3L68GCL1dRLHrWwWvJw2sqGbrFMMv1Sip9n9uQ GNq2NfKF/YnxnPw8yGhB9aoCZ6bOcML8bd/kqwKYWwHuQj0M7lzI11HbSSB3bmP2mI9+ 6rjAuleczH2uvLsKXsO2WR/gBqS/5rYXAbQ79w4MktPwCn+1Gd+9VqjZsJqdBDkBWdPp qR/ewZ7a774R92vwcWkxrhkIWM8glml6kgs6BrcGcvksERONxpO7tPFLgVuzFGdCMaVg gzNVPysMVHu8V+SJGbKQv1bX89Pa1gSw1IOZp3qVXGcib++HqbmVxnR/lQe22qQEu6L8 uJOQ== X-Gm-Message-State: ABUngvddzsrLhrSoxTZ+pAe5RODClzfqpRpFLSWIGHsUSXcE8KsHBNszitwyPQroRb93tg== X-Received: by 10.55.129.6 with SMTP id c6mr4348467qkd.4.1476860543552; Wed, 19 Oct 2016 00:02:23 -0700 (PDT) Original-Received: from [192.168.23.52] (c-50-138-183-136.hsd1.ma.comcast.net. [50.138.183.136]) by smtp.gmail.com with ESMTPSA id d127sm8203511qkf.24.2016.10.19.00.02.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 00:02:22 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::235 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:208456 Archived-At: --Apple-Mail=_DB2865BD-936E-4545-A9F8-8802453EC5FC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 18, 2016, at 06:46, Alan Third wrote: >=20 >=20 > On 18 October 2016 at 08:58, Ken Raeburn > wrote: > * ns_select needs fixing >=20 > Do you have any more information about what's to be fixed here? >=20 >=20 > --=20 > Alan Third =46rom my notes I thought that came out of the 2013 discussion, but I = can=E2=80=99t find anything in the archives at the moment. Looks like I = put it in the wrong sections of my notes. Last November I put in a patch (commit b87000208) changing a few the = select calls because of locking issues; the global lock still needed to = be held while xg_select called routines like unblock_input, so I pushed = the thread_select wrapper (which releases and re-acquires the lock) = calls to a lower level. In ns_select it wasn=E2=80=99t clear to me where to put the calls. = It=E2=80=99s also clearly using static storage for fd arrays, which is a = no-no if multiple threads will be able to call into that routine = concurrently. So I added a =E2=80=9CFIXME=E2=80=9D statement to = nsterm.m to prevent compilation of a version known to be wrong. Depending how the NS version needs to change, possibly the = =E2=80=9Cthread_select(pselect,=E2=80=A6)=E2=80=9D calls should be = replaced with a wrapper specifically for pselect-using platforms, and = the NS code manage the global lock separately. Or perhaps we=E2=80=99ll = wind up with an NS-specific pselect-like routine that we pass to = thread_select on the Mac, keeping the global lock management in one = place. Ken= --Apple-Mail=_DB2865BD-936E-4545-A9F8-8802453EC5FC Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On Oct 18, 2016, at 06:46, Alan Third <alan@idiocy.org> = wrote:


On 18 October 2016 at 08:58, Ken Raeburn <raeburn@raeburn.org> = wrote:
 * ns_select = needs fixing

Do you have any more = information about what's to be fixed here?


--
Alan = Third

=46rom my = notes I thought that came out of the 2013 discussion, but I can=E2=80=99t = find anything in the archives at the moment.  Looks like I put it = in the wrong sections of my notes.

Last November I put in a patch (commit = b87000208) changing a few the select calls because of locking issues; = the global lock still needed to be held while xg_select called routines = like unblock_input, so I pushed the thread_select wrapper (which = releases and re-acquires the lock) calls to a lower level.

In ns_select it wasn=E2=80= =99t clear to me where to put the calls.  It=E2=80=99s also clearly = using static storage for fd arrays, which is a no-no if multiple threads = will be able to call into that routine concurrently.  So I added a = =E2=80=9CFIXME=E2=80=9D statement to nsterm.m to prevent compilation of = a version known to be wrong.

Depending how the NS version needs to = change, possibly the =E2=80=9Cthread_select(pselect,=E2=80=A6)=E2=80=9D = calls should be replaced with a wrapper specifically for pselect-using = platforms, and the NS code manage the global lock separately.  Or = perhaps we=E2=80=99ll wind up with an NS-specific pselect-like routine = that we pass to thread_select on the Mac, keeping the global lock = management in one place.

Ken
= --Apple-Mail=_DB2865BD-936E-4545-A9F8-8802453EC5FC--