From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: Blocking calls and threads Date: Thu, 20 Apr 2023 10:26:36 -0400 Message-ID: References: <838ren6mpp.fsf@gnu.org> <875y9qfztq.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1682"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 20 16:27:35 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ppVG3-0000HG-Ek for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Apr 2023 16:27:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppVFN-00089r-Rh; Thu, 20 Apr 2023 10:26:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppVFM-00087k-FG for emacs-devel@gnu.org; Thu, 20 Apr 2023 10:26:52 -0400 Original-Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppVFK-0007eC-Rb; Thu, 20 Apr 2023 10:26:52 -0400 Original-Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1a6ebc66ca4so9385535ad.3; Thu, 20 Apr 2023 07:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682000808; x=1684592808; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HIYXxdpj3pOdrZ5eTw0W4j9+aBhp3lfA0+U/WLaQnXw=; b=V+s6y4aqsKRE3kMpTgSI4e31L9o3YclckS4iGvkJJdS7ecCmkQKybLBOaEE+XHED1Q 3K3e8M5GAY0JtkzZb23Z7XhHi30g9lW23ZNQ1UC9BvwPNggvEekNUDFD2jX5/JPDMr0c 3czsvOSrclssXRX99KcMFn06ihVupFAdBgMKjZMP9AuWG63LvuiqRdzDhfhlmHNYfQhh LQzmmfmrEOJGVGflokeGggaIEb2grLg//u67XrDsFaL7a+jHmEz2imSOHGgUZ1YHdZgx HssPhhpm/g05IKrWh24Xertku1EjkQVK+KgdLoewGyqaRzzwmo+6lN0Rm17Bk3WtnpBN 6XMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682000808; x=1684592808; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HIYXxdpj3pOdrZ5eTw0W4j9+aBhp3lfA0+U/WLaQnXw=; b=QXqvsVggKNbz8ih/LZ5ulFYtgvJcToQ2C0jHVT/UVYMk3vh92057Yc0v6JpnCW2GTh LsEp8aADwQlUzaN+La2LgqeVbE22PQ6ZNO8r1VLtCgfZUP7EVzx05oXv8LYlsAsbfBRd 2CmL/CmaIx8yxEgDXX5gv62BsZAQ1yEwynNg30/r2MlDjyVXf083eB9XYUOYgHCspa2W 6dhP/Wk4P9JWCjGlwMFwP9wWKojYv58h2e2I90SPAtgyc/ux5k4zMLwi01yH8akh2wi+ 8VeT1DceN7Lm9vuw0NXW8ZA2907KA2ofYYkpRxvB4dQzFplLBBN+Bojf+MOPPmh4MIVN MTQw== X-Gm-Message-State: AAQBX9en1tWxNLKcsXUKgIdM3COkLDAXsu3UyFCNwmgNcSLo+sNih1aO Gem50lFOz/eP0voapTP7+0zwyYhNdFAxNLidi70= X-Google-Smtp-Source: AKy350Yevenrn7UQ1M7EX+pJKBMzr0jiAtnH+6oxcEGxgVQ6eM6bVJyQuRAQUjtffnmi8Y4hZQTADOpb52/4NaDzhT4= X-Received: by 2002:a17:902:b20b:b0:1a2:9183:a499 with SMTP id t11-20020a170902b20b00b001a29183a499mr1589527plr.34.1682000807755; Thu, 20 Apr 2023 07:26:47 -0700 (PDT) In-Reply-To: <875y9qfztq.fsf@yahoo.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=owinebar@gmail.com; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305513 Archived-At: On Thu, Apr 20, 2023 at 9:28=E2=80=AFAM Po Lu wrote: > Lynn Winebarger writes: > > Presumably whatever mechanism is used for the calls you identified > > below could be generalized. In practical terms, it would mean > > assigning locks to every system resource that isn't inherently part of > > the lisp machine, in this case at least file descriptors. Then, for > > example, the read call in emacs_intr_read (in sysdep.c) could be > > surrounded by a release of the global lock (which yields the thread of > > the lisp machine) and the re-acquisition of the global lock. The file > > descriptor lock might be acquired after yielding the lisp thread, or > > it might be owned exclusively by the thread that opened it. > > I'm afraid that's not so easy. Parts of Emacs have certainly been > designed with the assumption that context switching cannot happen inside > read and friends; at least the Android and NS ports have this problem. I didn't mean to imply that was *all* that was required - although I would distinguish concerns around maintaining consistency of the Lisp machine state (heap/globals) from the correctness of Lisp code that has race conditions on buffer objects, etc. I'm not saying the latter don't have to be addressed, just that they pose distinct engineering problems from the former. It's not unlike the move from dynamic to lexical scope. Perhaps some day there will be a `thread-safe' local variable. > > Are these identified as a group anywhere for reference? Otherwise, I > > don't know what is included in the "etc". > > Basically anything that calls `thread_select'. This includes almost > everything that waits for input. Please grep around in the C sources. Thanks, Lynn