From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard M Stallman Newsgroups: gmane.emacs.devel Subject: Re: multi-threaded Emacs Date: Sun, 30 Nov 2008 11:44:04 -0500 Message-ID: References: <87abbiody1.fsf@master.homenet> Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: ger.gmane.org 1228065310 1104 80.91.229.12 (30 Nov 2008 17:15:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Nov 2008 17:15:10 +0000 (UTC) Cc: emacs-devel@gnu.org To: Giuseppe Scrivano Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 30 18:16:14 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 1L6ptz-0003O0-EM for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2008 18:16:11 +0100 Original-Received: from localhost ([127.0.0.1]:40573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6psp-0001G4-82 for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2008 12:14:59 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L6pPI-0005HD-Q3 for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:44:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L6pPH-0005GZ-UE for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:44:28 -0500 Original-Received: from [199.232.76.173] (port=47581 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6pPH-0005GP-M5 for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:44:27 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:50737) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L6pPH-0004Be-Ck for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:44:27 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1L6pOu-0005Of-0H; Sun, 30 Nov 2008 11:44:04 -0500 In-reply-to: <87abbiody1.fsf@master.homenet> (message from Giuseppe Scrivano on Sat, 29 Nov 2008 14:32:22 +0100) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:106338 Archived-At: (create-thread) (with-thread id '(code)) (kill-thread id) It seems to me that `with-thread' should be renamed to `run-in-thread'. Meanwhile, `with-thread' should be a macro that creates a new thread, starts running the body code in it, and will kill it when that body code finishes. It would be cleaner to represent threads by objects that contain info about them rather than IDs. If there is a table of threads, it should not have a fixed size -- it should be extensible, as many other tables inside Emacs are. Instead of indexing by a thread number each time you access certain data structures, you should swap the current thread's pointers in and out of the usual variables as part of switching threads. That would mean far less changes throughout the evaluator. What should happen when another thread gets an error? Should it run the debugger in that thread? (Probably rather annoying.) Kill the thread? Leave the thread somehow suspended to be examined (but how?). Kill the thread, and leave some info on the error in the dead thread object? I haven't well investigated all problems that will raise using threads in Emacs, the first one that come to my attention is the garbage collector and at the moment I simply disable GC while there are running threads. It should not be hard to find all the existing threads and mark all their stacks.