From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.user Subject: Re: Some introductory docs about C level threading Date: Thu, 10 Feb 2005 13:05:04 +0100 Message-ID: References: <6b496d191d7216e82df4e9a7afbb3168@raeburn.org> <87fz0falxl.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1108037356 4894 80.91.229.2 (10 Feb 2005 12:09:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Feb 2005 12:09:16 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Feb 10 13:09:15 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1CzD8C-0005c8-VM for guile-user@m.gmane.org; Thu, 10 Feb 2005 13:09:13 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CzDMv-0007vk-Vk for guile-user@m.gmane.org; Thu, 10 Feb 2005 07:24:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CzDLf-0007PO-HH for guile-user@gnu.org; Thu, 10 Feb 2005 07:23:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CzDLb-0007NW-6A for guile-user@gnu.org; Thu, 10 Feb 2005 07:23:04 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CzDLZ-0007LF-T8 for guile-user@gnu.org; Thu, 10 Feb 2005 07:23:02 -0500 Original-Received: from [129.217.163.1] (helo=mail.dt.e-technik.uni-dortmund.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CzD4F-00015H-RJ for guile-user@gnu.org; Thu, 10 Feb 2005 07:05:08 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.dt.e-technik.uni-dortmund.de (Postfix) with ESMTP id 064FA44234; Thu, 10 Feb 2005 13:05:06 +0100 (CET) Original-Received: from mail.dt.e-technik.uni-dortmund.de ([127.0.0.1]) by localhost (krusty [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 25136-06-2; Thu, 10 Feb 2005 13:05:04 +0100 (CET) Original-Received: from troy.dt.e-technik.uni-dortmund.de (troy.dt.e-technik.uni-dortmund.de [129.217.163.17]) by mail.dt.e-technik.uni-dortmund.de (Postfix) with ESMTP id DE63A44233; Thu, 10 Feb 2005 13:05:04 +0100 (CET) Original-Received: by troy.dt.e-technik.uni-dortmund.de (Postfix, from userid 520) id A3461B999; Thu, 10 Feb 2005 13:05:04 +0100 (CET) Original-To: Ken Raeburn In-Reply-To: (Ken Raeburn's message of "Wed, 9 Feb 2005 13:10:59 -0500") User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) X-Virus-Scanned: by amavisd-new at dt.e-technik.uni-dortmund.de X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org X-MailScanner-To: guile-user@m.gmane.org Xref: main.gmane.org gmane.lisp.guile.user:4237 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:4237 Ken Raeburn writes: > I think someone might be tempted to do something like: > > thread 1, on cpu 1, with guile core mutex locked: (There is no guile core mutex. Is it relevant to the discussion below?) > (precondition: z is a pair, SCM_CAR(z) is a pair) > allocate cons cell x > fill in x.car = v1 > fill in x.cdr = v2 > SCM_SETCAR(z, x) > > thread 2, on cpu 2, running without lock: > > set t = SCM_CAR(z) # atomic, so we always get before or after, right? > read SCM_CAR(t) # should Just Work? Yes, I had planned for this to just work... > With weak memory ordering, and no locking during this sequence in > either thread, I don't think we get any guarantee that SCM_CAR(t) will > get v1 instead of the uninitialized contents of the cons cell as > pulled off of the free list. Yes, I now realize that at least initialization needs to have some kind of memory synchronization after it. Would declaring x.car and x.cdr as volatile do it? > Especially if it's one that cpu 2 happened to examine recently > (perhaps it ran the GC pass) and thus has it in cache. I think you > need a memory synchronization operation in each to guarantee this. Needing to have the synch operation in all threads would be really bad... is it really necessary? If it is, I would get serious doubts whether we can achieve the SCM is always valid' goal with full concurrency. _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user