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 09:06:16 -0400 Message-ID: References: <838ren6mpp.fsf@gnu.org> 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="18890"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 20 15:07:21 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 1ppU0P-0004nJ-76 for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Apr 2023 15:07:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppTzm-0006yp-Ia; Thu, 20 Apr 2023 09:06:42 -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 1ppTzg-0006x0-St for emacs-devel@gnu.org; Thu, 20 Apr 2023 09:06:39 -0400 Original-Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppTzb-0000BT-HP; Thu, 20 Apr 2023 09:06:36 -0400 Original-Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-247048f86c7so682299a91.2; Thu, 20 Apr 2023 06:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681995988; x=1684587988; 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=jmB/v3JufWnV5nNCsXTNcq4C4Oj6tX2tpkO5oX074E0=; b=KSMY6OcQfImtTcdFvXn9QWW40sqN/vC69W6yIdxDOmWcwQ0O3yrp+ZUIuexfaKUcO9 H14yu+OV/1Z4qUGlxbzts/lrw3qf/DSyVzJ8mMUGIFnn70wLXBuv4CVJIcy0xqh7bJvA u6px9N01Zz0C1PjTRdOQY/BZRDV+gtteewz8h/VwgcXw0t2aEM0eergNq1KSP30YjOp0 bIukJz3KCvawU/RopF8FmIxRbba0txP/xXfDdSAtRbLvh0CoJXAGdprr2S2bqSCIZrl5 s2f3KecsvDZGpaAxkbnTNbpfhH5C4H+MrK+0ZllU5wmUqidsTqO8kR1T3M0OJ1NaYOUH IjCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681995988; x=1684587988; 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=jmB/v3JufWnV5nNCsXTNcq4C4Oj6tX2tpkO5oX074E0=; b=K+VenKmRlxWClNE0dHSLzivnqige/idwJFRLj5atHsven41f5aIRlXG2/iju+I8Enn kha1kV9nMGkcgdLFjHn7LZjNJ944WXOWrFnp8B8BOLQd2DfvHjXRU7ZMM7p2wj77yMBR cuF5q8zy3dqWConZbCyhvzaGE7LoXfQr6Ix3Fo0+qKFhKRkEr0uHNjOegW7XUBg1mkOg GlgtCIM5lY7M1Ks5dgkA04JSCkfBf57tkvpNE3lFLkIAb/YnbMxWmpCn7xtsXEVQbya5 VA6GRqKRVHRJFan5KZKywMoMmKVw8qyp4LbP9gD5miskN6TMxDdOuGOSRl+wYuBB9/j6 lFOQ== X-Gm-Message-State: AAQBX9fwiFo4/41O1S70x8dil4Qfg/olGACb4QCpdzWMpFjt5kYEhbs3 r/e9RH3MXKMKo149F+n0o8J5UTEGVodNl5oXlc+oIdR4 X-Google-Smtp-Source: AKy350axwVnmv4FxO37TQ1lZ92XGt0Wsw0bVgnizwgY8VXFBQ/sZmfRlAiyR4TudwlLH9ejuoYfXPvoKhkbXti1Rj+8= X-Received: by 2002:a17:90b:3a89:b0:247:6edf:e934 with SMTP id om9-20020a17090b3a8900b002476edfe934mr1505655pjb.42.1681995988353; Thu, 20 Apr 2023 06:06:28 -0700 (PDT) In-Reply-To: <838ren6mpp.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=owinebar@gmail.com; helo=mail-pj1-x1029.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:305504 Archived-At: On Thu, Apr 20, 2023 at 3:23=E2=80=AFAM Eli Zaretskii wrote: > > From: Lynn Winebarger > > Date: Thu, 20 Apr 2023 01:31:14 -0400 > > > > The thread on how to make asynchronous behavior explicit made me > > curious whether making a blocking system call would cause the lisp > > thread to yield to other lisp threads (release the global lock). Do > > blocking system calls yield the lisp thread, or is there any way in > > lisp code to call blocking functions so that the lisp thread will > > yield while the system thread blocks? > > What do you mean by "blocking system calls", exactly? > > If you mean the likes of 'read' and 'write' (i.e. "blocking system > calls" on the OS level), Almost - I mean the subrs that make those operations available to the lisp machine, e.g. insert-file-contents. > then no, a thread which makes these calls > will not yield. How can it? the implementation of those calls is not > in Emacs, so how can Emacs change the way these syscalls work? 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. > > The "blocking system calls" which do yield are calls emitted from > Lisp: accept-process-output, sit-for, read-key-sequence, etc. Are these identified as a group anywhere for reference? Otherwise, I don't know what is included in the "etc". Thanks, Lynn