From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: User interaction from multiple threads Date: Mon, 20 Aug 2018 20:07:23 +0300 Message-ID: <838t51dl10.fsf@gnu.org> References: <838t59j821.fsf@gnu.org> <87lg92q7ih.fsf@runbox.com> <87bm9xqg46.fsf@runbox.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1534784735 7620 195.159.176.226 (20 Aug 2018 17:05:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Aug 2018 17:05:35 +0000 (UTC) Cc: psainty@orcon.net.nz, emacs-devel-bounces+psainty=orcon.net.nz@gnu.org, emacs-devel@gnu.org To: Gemini Lasswell Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 20 19:05:30 2018 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 1frncQ-0001pM-JJ for ged-emacs-devel@m.gmane.org; Mon, 20 Aug 2018 19:05:30 +0200 Original-Received: from localhost ([::1]:48238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frneV-0003bc-CC for ged-emacs-devel@m.gmane.org; Mon, 20 Aug 2018 13:07:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frneO-0003bG-Sd for emacs-devel@gnu.org; Mon, 20 Aug 2018 13:07:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frneJ-000580-2z for emacs-devel@gnu.org; Mon, 20 Aug 2018 13:07:32 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frneI-00057r-Tt; Mon, 20 Aug 2018 13:07:26 -0400 Original-Received: from [176.228.60.248] (port=3159 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1frneH-0004Lx-Sf; Mon, 20 Aug 2018 13:07:26 -0400 In-reply-to: <87bm9xqg46.fsf@runbox.com> (message from Gemini Lasswell on Mon, 20 Aug 2018 07:15:05 -0700) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:228748 Archived-At: > From: Gemini Lasswell > Cc: Eli Zaretskii , Emacs-devel , emacs-devel@gnu.org > Date: Mon, 20 Aug 2018 07:15:05 -0700 > > Is it guaranteed that the thread scheduler will allow all other > ready threads a turn to execute during the main thread's > thread-yield? No. The "scheduler" we have is actually a race to grab the global lock; the first thread to succeed starts running, the others wait. > If not, maybe a good-enough-most-of-the-time solution would be for the > main thread to do a sleep-for for an amount of time that won't bother > the user, like 0.1s, and if the most-recent thread hasn't added a prompt > to the queue by then, then go on to the next thread's prompt. When the main thread calls sleep-for, it enters the "scheduler", so some other thread will start running, and there's no guarantee that the main thread will resume after 0.1 sec: it might be much later, if that other thread has something to do that takes a long time.