From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: advice needed for multi-threading patch Date: Mon, 21 Sep 2009 17:19:42 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253568005 9943 80.91.229.12 (21 Sep 2009 21:20:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Sep 2009 21:20:05 +0000 (UTC) Cc: Emacs development discussions To: Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 21 23:19:58 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MpqIg-00017L-0Q for ged-emacs-devel@m.gmane.org; Mon, 21 Sep 2009 23:19:58 +0200 Original-Received: from localhost ([127.0.0.1]:53991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MpqIf-0002BO-Av for ged-emacs-devel@m.gmane.org; Mon, 21 Sep 2009 17:19:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MpqIY-000271-TT for emacs-devel@gnu.org; Mon, 21 Sep 2009 17:19:50 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MpqIT-00026a-CT for emacs-devel@gnu.org; Mon, 21 Sep 2009 17:19:49 -0400 Original-Received: from [199.232.76.173] (port=52223 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MpqIT-00026X-6K for emacs-devel@gnu.org; Mon, 21 Sep 2009 17:19:45 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:35675) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MpqIS-0006XM-RS for emacs-devel@gnu.org; Mon, 21 Sep 2009 17:19:45 -0400 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id n8LLJgR4002795; Mon, 21 Sep 2009 17:19:42 -0400 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 60C4B3A104; Mon, 21 Sep 2009 17:19:42 -0400 (EDT) In-Reply-To: (Tom Tromey's message of "Fri, 18 Sep 2009 16:59:37 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3367=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115501 Archived-At: > * Many, but not all, of the 9 kinds of variables that Emacs implements > work properly with threads. In particular, working ones are > defvaralias, objfwd, and ordinary. These all should do the right > thing in all cases. Buffer-local and buffer objfwd mostly work, > because we do buffer locking. (However, I think make-local-variable > doesn't work properly with let-binding and multiple threads.) Not > working on intfwd, boolfwd, keyboard-local and frame-local. How do you handle objfwd objects? Do you swap them in&out during context switches? > * Buffer locking is actually quite a pain. > If you have a background thread locking some buffer, you can't switch > to that buffer. Emacs will just pause. I don't think we allow > interrupting a lock acquisition (clearly a bug). Yes, we may have to relax the locking somehow. E.g. we should clearly allow to display a buffer in any window, if the buffer is "locked" by a thread. I.e. things like switch-to-buffer should not take the buffer's lock. Of course, if the buffer is locked by a thread, we also need to be careful what we do if the user then types a command in it (should we wait for the thread to yield or should we signal an erreur?) > * Giuseppe implemented minibuffer exclusion. But really the keyboard > should only be available to one thread at a time. You mean "each keyboard", right? > Also, there are tons more problems if you want preemptive > multithreading... redisplay probably needs work, regex is not > reentrant, the GC needs a bit more work, you need lisp-level > locks, etc. Yes, lots of fun stuff, indeed. > Sometimes I wonder whether it would be better to just fork a second > emacs and communicate with it using pipes + princ + read. This uses > more memory but the implementation would be a lot simpler and (I think) > it would suffice for the one case that seems most important: Gnus. But you can already do that right now, so it's a different "solution". Stefan