From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Using define in multiple threads? Date: Mon, 17 Nov 2008 15:57:06 +0100 Message-ID: <87od0ee6yl.fsf@gnu.org> References: <3ae3aa420811161427t6b2c65d1q4adcd6e9a5689ddc@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1226933864 15402 80.91.229.12 (17 Nov 2008 14:57:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Nov 2008 14:57:44 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Nov 17 15:58:47 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L25Yk-0003jG-S5 for guile-devel@m.gmane.org; Mon, 17 Nov 2008 15:58:39 +0100 Original-Received: from localhost ([127.0.0.1]:48495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L25Xc-0005wV-Bf for guile-devel@m.gmane.org; Mon, 17 Nov 2008 09:57:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L25XW-0005wP-GQ for guile-devel@gnu.org; Mon, 17 Nov 2008 09:57:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L25XU-0005wD-4k for guile-devel@gnu.org; Mon, 17 Nov 2008 09:57:21 -0500 Original-Received: from [199.232.76.173] (port=45946 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L25XT-0005wA-VN for guile-devel@gnu.org; Mon, 17 Nov 2008 09:57:19 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:60522 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L25XT-0001U3-HC for guile-devel@gnu.org; Mon, 17 Nov 2008 09:57:19 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L25XN-0000ZE-Ar for guile-devel@gnu.org; Mon, 17 Nov 2008 14:57:13 +0000 Original-Received: from 195.83.213.140 ([195.83.213.140]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Nov 2008 14:57:13 +0000 Original-Received: from ludo by 195.83.213.140 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Nov 2008 14:57:13 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 29 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 195.83.213.140 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 27 Brumaire an 217 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) Cancel-Lock: sha1:5sEuWzS/cQ8RoHItu5FU25GnHmE= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7857 Archived-At: Hey! Han-Wen Nienhuys writes: > Linas Vepstas escreveu: >> Is it "safe" or "legal" to use define in multiple threads? > > I guess not. Someone -I forgot who- put in the pthreads without thinking > through the consequences. > > Look through eval.c, youŽll see > > SCM_SETCAR (expr, SCM_IM_DO); > // * > SCM_SETCDR (expr, tail); > > which is very dubious if a thread switch happens at (*) You're answering a more general question: "is it safe to evaluate code in multiple threads?". I'm afraid your answer is correct, but, if it happens that the code to be evaluated has already been memoized, then everything's alright. Thankfully, the VM will soon save us from this. :-) Besides, as Linas noted, the hash table implementation isn't thread-safe, which makes it "unsafe" to `define' in parallel. Thanks, Ludo'.