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: multi-threaded Emacs Date: Sat, 29 Nov 2008 15:26:21 -0500 Message-ID: References: <87abbiody1.fsf@master.homenet> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1227990401 25119 80.91.229.12 (29 Nov 2008 20:26:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 29 Nov 2008 20:26:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: Giuseppe Scrivano Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 29 21:27:44 2008 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 1L6WPm-00065r-Q7 for ged-emacs-devel@m.gmane.org; Sat, 29 Nov 2008 21:27:43 +0100 Original-Received: from localhost ([127.0.0.1]:34608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6WOc-0002DG-DB for ged-emacs-devel@m.gmane.org; Sat, 29 Nov 2008 15:26:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L6WOX-0002D6-Nl for emacs-devel@gnu.org; Sat, 29 Nov 2008 15:26:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L6WOV-0002Ch-U0 for emacs-devel@gnu.org; Sat, 29 Nov 2008 15:26:24 -0500 Original-Received: from [199.232.76.173] (port=52807 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6WOV-0002Ce-NF for emacs-devel@gnu.org; Sat, 29 Nov 2008 15:26:23 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:32650 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L6WOU-0004sL-JX; Sat, 29 Nov 2008 15:26:22 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAGI0MUnO+Jkl/2dsb2JhbACBbcwRgn2BJA X-IronPort-AV: E=Sophos;i="4.33,687,1220241600"; d="scan'208";a="30436194" Original-Received: from 206-248-153-37.dsl.teksavvy.com (HELO pastel.home) ([206.248.153.37]) by ironport2-out.teksavvy.com with ESMTP; 29 Nov 2008 15:26:21 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 3A9AA84C0; Sat, 29 Nov 2008 15:26:21 -0500 (EST) In-Reply-To: <87abbiody1.fsf@master.homenet> (Giuseppe Scrivano's message of "Sat, 29 Nov 2008 14:32:22 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:106319 Archived-At: > I attached a small patch that enables basic threads in Emacs; it is just > a proof of concept and not usable yet, my goal was the execution of the > elisp code I included at the bottom. [...] > It is a prototype and the code is not very clean, still a lot of work > must be done in order to have working threads, but I think that have a > multi-threaded Emacs worths this effort. [...] > What do you think about? I agree that multithreading is a worthwhile goal, even tho it's going to be a long ride. It involves several problems: - handling thread-specific data: gcprolist, mark_byte_stack, and things like that. You've tackled this one. I don't find your solution very elegant, but I can't think of a much better one, unless pthreads does provide some kind of thread-specific variables. I guess the only improvement is to put those vars together, so we have an array of structs (that then contain gcprolist, and mark_byte_stack fields) rather than several arrays. And then define `gcprolist' as a macro that expands into "thread_data[current_thread()].gcprolist", so as to reduce the amount of source-code changes. - dynamic-scoping: your handling of specpdl is naive and fundamentally flawed. For multithreading, we will have to completely change the implementation technique of dynamic-scoping. - synchronization to access all the global variables/objects. You haven't yet have time to tackle this (other than in `put', it seems), and it's going to be difficult. - concurrent GC (later to be refined to parallel concurrent GC ;-). - redisplay in its own thread (later to be refined to one redisplay thread per terminal, then per frame, then per window ;-). A first step will be to restrict the implementation such that there's no parallelism: only one thread executes at any given time (i.e. have a single lock and have all thread grab the lock before doing any actual work). Stefan