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:43:21 -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 1228065214 756 80.91.229.12 (30 Nov 2008 17:13:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Nov 2008 17:13:34 +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:14:36 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 1L6psL-0002vJ-9c for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2008 18:14:35 +0100 Original-Received: from localhost ([127.0.0.1]:35807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6prA-00005T-1Y for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2008 12:13:16 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L6pOc-0004xg-JP for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:43:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L6pOc-0004xD-3j for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:43:46 -0500 Original-Received: from [199.232.76.173] (port=47557 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6pOb-0004x6-Nb for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:43:45 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:50670) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L6pOb-0003y3-Ar for emacs-devel@gnu.org; Sun, 30 Nov 2008 11:43:45 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1L6pOD-0005Gc-Pz; Sun, 30 Nov 2008 11:43:21 -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:106336 Archived-At: The main issue about multiple threads in Emacs is, when should a thread-switch be possible? I think it should be allowed only where quitting is allowed. Otherwise, internal data can be made inconsistent. Does pthreads provide the option to forbid thread-switching except when the code calls a specific function? If so, we could make the QUIT macro run that function if there is more than one thread. (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 is un-Lispy to represent threads with numbers. They should be represented by objects that contain info about them. If there is a table of threads, it should not have a fixed size -- it should be extended with realloc whenever it gets full. What should happen when another thread gets an error? Should Emacs 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 about the error in the dead thread object? Perhaps there should be a way to specify a choice for each thread. 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 and specpdls.