From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Giuseppe Scrivano Newsgroups: gmane.emacs.devel Subject: Re: multi-threaded Emacs Date: Mon, 08 Dec 2008 00:51:04 +0100 Message-ID: <87y6yrtuhj.fsf@master.homenet> 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 1228693892 6606 80.91.229.12 (7 Dec 2008 23:51:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Dec 2008 23:51:32 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 08 00:52:35 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 1L9TQR-00053S-GZ for ged-emacs-devel@m.gmane.org; Mon, 08 Dec 2008 00:52:35 +0100 Original-Received: from localhost ([127.0.0.1]:59194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9TPG-0006yt-5z for ged-emacs-devel@m.gmane.org; Sun, 07 Dec 2008 18:51:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9TPA-0006tm-Iq for emacs-devel@gnu.org; Sun, 07 Dec 2008 18:51:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9TP8-0006ot-Qp for emacs-devel@gnu.org; Sun, 07 Dec 2008 18:51:15 -0500 Original-Received: from [199.232.76.173] (port=52766 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9TP8-0006oC-CY for emacs-devel@gnu.org; Sun, 07 Dec 2008 18:51:14 -0500 Original-Received: from jack.mail.tiscali.it ([213.205.33.53]:48110) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L9TP6-0000IF-Qf; Sun, 07 Dec 2008 18:51:13 -0500 Original-Received: from master.homenet (84.222.170.162) by jack.mail.tiscali.it (8.0.022) id 48F7481002994A61; Mon, 8 Dec 2008 00:51:10 +0100 Original-Received: from gscrivano by master.homenet with local (Exim 4.69) (envelope-from ) id 1L9TOy-0001Xg-Ad; Mon, 08 Dec 2008 00:51:04 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 07 Dec 2008 15:51:25 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) 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:106668 Archived-At: Stefan Monnier writes: > > 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. It is exactly what I do in save_thread_bindings () and restore_thread_bindings (). Trying your code (plus initializing the thread and another ')' at the end) I have: (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))))) "hello" "world" "hello" "world" Regards, Giuseppe