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: Sun, 07 Dec 2008 15:51:25 -0500 Message-ID: References: <87abbiody1.fsf@master.homenet> <877i6l5d8s.fsf@master.homenet> <874p1npvtj.fsf@master.homenet> <87ej0qci8g.fsf@master.homenet> <87y6yxm7xr.fsf@master.homenet> <87d4g4c1o1.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 1228683105 8790 80.91.229.12 (7 Dec 2008 20:51:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Dec 2008 20:51:45 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: Giuseppe Scrivano Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 07 21:52:50 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 1L9QcT-0002LV-Ee for ged-emacs-devel@m.gmane.org; Sun, 07 Dec 2008 21:52:49 +0100 Original-Received: from localhost ([127.0.0.1]:46017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9QbI-0002en-OS for ged-emacs-devel@m.gmane.org; Sun, 07 Dec 2008 15:51:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9QbD-0002eC-1e for emacs-devel@gnu.org; Sun, 07 Dec 2008 15:51:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9QbB-0002bG-6A for emacs-devel@gnu.org; Sun, 07 Dec 2008 15:51:29 -0500 Original-Received: from [199.232.76.173] (port=59034 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9QbB-0002au-10 for emacs-devel@gnu.org; Sun, 07 Dec 2008 15:51:29 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:12501 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L9Qb8-0004OV-Jz; Sun, 07 Dec 2008 15:51:26 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq8EAM/FO0nO+KHA/2dsb2JhbACBbMpAgwWBJg X-IronPort-AV: E=Sophos;i="4.33,730,1220241600"; d="scan'208";a="30759738" Original-Received: from 206-248-161-192.dsl.teksavvy.com (HELO pastel.home) ([206.248.161.192]) by ironport2-out.teksavvy.com with ESMTP; 07 Dec 2008 15:51:25 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 09E668219; Sun, 7 Dec 2008 15:51:25 -0500 (EST) In-Reply-To: <87d4g4c1o1.fsf@master.homenet> (Giuseppe Scrivano's message of "Sun, 07 Dec 2008 00:41:02 +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:106662 Archived-At: >>> Each thread should have its own local bindings. To do this >>> requires swapping bindings in and out of the specpdls >>> when switching threads. It is not hard. [...] > Actually I am using what Richard suggested. Every thread has a specpdl > and on a thread switch I copy the current symbol value inside its > specbinding cell. Switching the value of specpdl is not enough. Try (progn (run-in-thread a-thread '(dotimes (i 2) (print "hello") (yield))) (let ((i 5)) (while (< i 7) (print "world") (yield) (setq i (1+ i)))) What Richard suggests is that upon a thread-switch we walk up the specpdl stack, undoing all the bindings, then switch specpdl to the one of the other thread and walk down that one to reestablish the local bindings of the new thread. Stefan