From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp
Newsgroups: gmane.emacs.help
Subject: Re: Is automatic yield support feasible for threads?
Date: Tue, 9 Nov 2021 15:53:32 +0100
Message-ID: <46501A5F-9C72-4048-8EEA-CE219D54CEC2@gmail.com>
References:
Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.20.0.1.32\))
Content-Type: text/plain;
charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
logging-data="24340"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: "help-gnu-emacs@gnu.org"
To: ndame
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 09 16:00:40 2021
Return-path:
Envelope-to: geh-help-gnu-emacs@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 1mkSc3-00069o-KD
for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 16:00:39 +0100
Original-Received: from localhost ([::1]:56978 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1mkSc2-0001Wt-5l
for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 10:00:38 -0500
Original-Received: from eggs.gnu.org ([209.51.188.92]:49848)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1mkSbD-0001Ut-AW
for help-gnu-emacs@gnu.org; Tue, 09 Nov 2021 09:59:47 -0500
Original-Received: from [2a00:1450:4864:20::329] (port=51848
helo=mail-wm1-x329.google.com)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1mkSb9-0006yi-V6
for help-gnu-emacs@gnu.org; Tue, 09 Nov 2021 09:59:47 -0500
Original-Received: by mail-wm1-x329.google.com with SMTP id z200so16103078wmc.1
for ; Tue, 09 Nov 2021 06:59:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:subject:from:in-reply-to:date:cc
:content-transfer-encoding:message-id:references:to;
bh=uS5NKjUZGjPHQgANdJsFYeatG60u89+wsFF59BaO4us=;
b=Y+i1NenuSxR7gKQcuWh4NTlXwPczPShIU9uswRCip7BKVrAajNW9nE0gQCL2tv5Z5R
awHMeqrOXxvLGbyLwQtQw3Fh5840AG74f3n/KinFBs8CjCBWvHoQcMtjpwpGc1FgS/D7
5oZ39nAW/ofcEUV3DxPwUjS4H6eKbzHczZ9yNpoFzZp6g8rmxNOKtXkPUrce6JqTS2c0
tmSlnkPhUiR80LaHxhjM/9QIxsx46dQxP2IIgvNBqgD421TZAMaUU3A/9ZLyKtNvRjBK
cpZ5iDsD+IDTPuvxP3vlciHc4cDqdYIiguWg31nCZgdncB04G/ooO1nF8vuIRRIuTRfq
w2gw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc
:content-transfer-encoding:message-id:references:to;
bh=uS5NKjUZGjPHQgANdJsFYeatG60u89+wsFF59BaO4us=;
b=70vgRfWLkfZ6EFDTcY7uIQeaCXW98e+c6WVYjIYlBPKiqshv8sNpNogrRFYrTWc121
pesB/7UdntBKsMbX8Ho/LXrW4tRj0Wor91OtYEu7yMALjNbZsdYbyJKE5pi533PQO9Xt
4SBItArqFBzNf5fLdKSpO0nNAlAgAcxBoaOqhsGkqn1PBjJPWArJepCbowWXq2nBnUUX
hJbwIlHwvaBBSokzE+51dw0EFGDOpZS6pRTuG0WMS1mYMOh2CnFQuh0OlT5qHUZwQC1R
20ko9ZIgME1INRGSC3i8U6p1MLl9i2Ulfeg1oF7rKUS6X+JswST8Up/ljW/a+tQ7tcmZ
fB0g==
X-Gm-Message-State: AOAM530igfqXzDaIk5WW0c3vBtf5CYdOMbw7PUwDKB8r+XOE4nt/c5IE
7N683UEuZblC0T9RT+yWZyF3UhbRmaE=
X-Google-Smtp-Source: ABdhPJzctVnX3q76yala1CFuGJM6mhe8tpFrMGdZ/8uHpCktsNeLun4aDcFmPOXKxfyyChJpfIrIPA==
X-Received: by 2002:a7b:c005:: with SMTP id c5mr7621809wmb.150.1636469613351;
Tue, 09 Nov 2021 06:53:33 -0800 (PST)
Original-Received: from smtpclient.apple (p57997199.dip0.t-ipconnect.de.
[87.153.113.153])
by smtp.gmail.com with ESMTPSA id j19sm20167040wra.5.2021.11.09.06.53.32
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Tue, 09 Nov 2021 06:53:33 -0800 (PST)
In-Reply-To:
X-Mailer: Apple Mail (2.3693.20.0.1.32)
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::329
(failed)
Received-SPF: pass client-ip=2a00:1450:4864:20::329;
envelope-from=p.stephani2@gmail.com; helo=mail-wm1-x329.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001,
RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Users list for the GNU Emacs text editor
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "help-gnu-emacs"
Xref: news.gmane.io gmane.emacs.help:134466
Archived-At:
> Am 04.11.2021 um 18:10 schrieb ndame via Users list for the GNU Emacs =
text editor :
>=20
> AFAIK Emacs has cooperative threading, so a badly behaving thread can =
prevent UI updates, therefore if some costly operation is moved into a =
separate thread then the code has to be modified in order to yield =
periodically if the code doesn't do I/O.
>=20
> If that's the case then what if the interpreter itself could support =
automatic yielding when some flag is set, so it could yield =
automatically after every several instructions?
>=20
> For example, make-thread could have an optional argument specifying =
after how many instructions a thread-yield should be called =
automatically and if this argument is set then a global flag is set, so =
the interpreter knowns it should call yield regularly.
>=20
> This automatic yielding would have some cost, but in return any code =
could safely be moved into a separate thread without the danger of =
locking up the UI if this optional argument is given to make-thread. So =
it could makes using cooperative threads easier.
>=20
> Could such an automatic yield support be feasible for threads?
I don't think it's feasible. Emacs Lisp code typically relies heavily =
on mutating global state (think buffer contents, the buffer list, =
`point', dynamic variables, ...), and normally doesn't put such state =
mutations into properly synchronized critical sections. Yielding from =
such unprotected critical sections would result in very subtle bugs =
(`point' randomly moving around, corruption of internal data structures, =
buffers vanishing surprisingly, ...).=