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: Tue, 22 Sep 2009 10:24:15 -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 1253629484 8862 80.91.229.12 (22 Sep 2009 14:24:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Sep 2009 14:24:44 +0000 (UTC) Cc: Emacs development discussions To: Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 22 16:24:36 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 1Mq6IE-0002Rk-KW for ged-emacs-devel@m.gmane.org; Tue, 22 Sep 2009 16:24:36 +0200 Original-Received: from localhost ([127.0.0.1]:33501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mq6IB-0004fn-Gm for ged-emacs-devel@m.gmane.org; Tue, 22 Sep 2009 10:24:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mq6I5-0004fc-St for emacs-devel@gnu.org; Tue, 22 Sep 2009 10:24:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mq6I1-0004en-R1 for emacs-devel@gnu.org; Tue, 22 Sep 2009 10:24:25 -0400 Original-Received: from [199.232.76.173] (port=48744 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mq6I1-0004ek-P5 for emacs-devel@gnu.org; Tue, 22 Sep 2009 10:24:21 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:40625) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mq6I0-0005na-Tk for emacs-devel@gnu.org; Tue, 22 Sep 2009 10:24:21 -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 n8MEOGvc006133; Tue, 22 Sep 2009 10:24:16 -0400 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 33B103A122; Tue, 22 Sep 2009 10:24:16 -0400 (EDT) In-Reply-To: (Tom Tromey's message of "Mon, 21 Sep 2009 15:50:32 -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:115518 Archived-At: Stefan> How do you handle objfwd objects? Do you swap them in&out during Stefan> context switches? > We have a script to edit the Emacs source. In the end all DEFUN_LISP > variables are defined like: > #define Vafter_change_functions *find_variable_location (&impl_Vafter_change_functions) Oh, right, I remember now, sorry. > This works great as long as the C code follows lispy rules. However, I > don't think that is always the case -- there are places doing direct > assignment to some of these variables where, really, a per-thread > assignment is meant. I'm not sure what you mean. Are you still talking about objfwd variables? > We don't swap anything in and out during a context switch. I've tried > to make all the decisions with an eye on the long term: preemptive > threading. Ultimately I'd like to get rid of the global lock and have > all threads run free. That was the motivation for my question, indeed. > Right now when a thread yields it does not release its buffer lock. I think it should, unless some of the buffer-local variables are let-bound by the thread. > One way forward would be to work out the semantics properly, and > eliminate buffer locking. Yes, although the result of this may end up requiring some form of buffer-locking, still. > Some of the semantics seems tricky. Oh, yes. Stefan> You mean "each keyboard", right? > Yes. > Locking a keyboard will probably have strange effects. There are some > things here that I have not thought through; like, what is the right > behavior of debug-on-error? Under what conditions would the main thread > ever release the keyboard? Maybe another way to look at all these problems is to take an "agent" point of view: rather than threads moving around, we could consider each keyboard and each buffer as an active object (i.e. with its own thread), which communicate among each other. I.e. a buffer-thread never leaves its buffer, instead it does an RPC to another buffer-thread, or to a keyboard-thread, ... > Yeah. I just wonder why nobody has done it and whether it would not be > a better approach. IIUC people do it all the time, tho not with another Emacs process: with an hexl process, a shell process, an openssl process, ... Emacs currently is not very good at using stdin/stdout so running an inferior Emacs process is poorly supported. Stefan