unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Ken Raeburn <raeburn@raeburn.org>
Cc: guile-devel@gnu.org
Subject: Re: What are the arguments in favor of delay/force in eval.c?
Date: Wed, 7 Dec 2005 19:57:58 -0500	[thread overview]
Message-ID: <41321ED5-8534-46C0-9A8A-D532203FC8F9@raeburn.org> (raw)
In-Reply-To: <87y82wo78b.fsf@trouble.defaultvalue.org>

On Dec 7, 2005, at 17:47, Rob Browning wrote:
>     {
>       SCM ans = scm_call_0(SCM_PROMISE_DATA (ans));
>       SCM_SET_PROMISE_DATA(p, ans);
>       SCM_SET_PROMISE_MUTEX(p, SCM_BOOL_F) // (do last to avoid  
> race at [1])
>       result = SCM_PROMISE_DATA(p);
>     }

Of course, the compiler might reorder these accesses, unless you make  
everything volatile.  Even then, the CPU still might reorder them so  
another compiler might see something different.  I'd be worried about  
the reordering or caching in another processor if the code decides it  
can bypass all the mutex stuff, too.

Once every thread agrees on the new data value and no mutex needed,  
everything should be fine, but managing the transition to that state  
(without adding *another* mutex) is very tricky.

>     scm_unlock_mutex(mutex);

That (and the lock call) is probably the only barrier past which you  
can safely assume that non-volatile accesses won't be reordered.   
(And for CPU reordering, you probably shouldn't depend too much on  
simply declaring storage to be volatile.  AFAIK most compilers won't  
insert memory-barrier instructions before and after every volatile  
access.)  Actually, I think some memory models will allow some  
accesses to be moved into the region where the lock is held from  
outside it.

Ken


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  parent reply	other threads:[~2005-12-08  0:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-06 21:14 What are the arguments in favor of delay/force in eval.c? Rob Browning
2005-12-07 21:31 ` Kevin Ryde
2005-12-07 22:47   ` Rob Browning
2005-12-08  0:29     ` Kevin Ryde
2005-12-08  0:52       ` Rob Browning
2005-12-10  0:11         ` Kevin Ryde
2005-12-10  4:23           ` Rob Browning
2005-12-14 21:10             ` Kevin Ryde
2005-12-08  0:57     ` Ken Raeburn [this message]
2005-12-08  1:28       ` Rob Browning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41321ED5-8534-46C0-9A8A-D532203FC8F9@raeburn.org \
    --to=raeburn@raeburn.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).