From: Marius Vollmer <marius.vollmer@uni-dortmund.de>
Cc: guile-user@gnu.org, Ken Raeburn <raeburn@raeburn.org>,
Kevin Ryde <user42@zip.com.au>
Subject: Re: Some introductory docs about C level threading
Date: Thu, 10 Feb 2005 12:15:31 +0100 [thread overview]
Message-ID: <ljhdkksm24.fsf@troy.dt.e-technik.uni-dortmund.de> (raw)
In-Reply-To: <16906.15215.714725.852570@casey.transmeta.com> (Doug Evans's message of "Wed, 9 Feb 2005 08:33:51 -0800 (PST)")
Doug Evans <dje@transmeta.com> writes:
> Marius Vollmer writes:
> > Kevin Ryde <user42@zip.com.au> writes:
> >
> > > You can force load/stores to be exactly as given using `volatile', [...]
> >
> > How would that work exactly? Can we flag each assignment operation as
> > volatile, or would the SCM type need to be made volatile? Would this
> > be a reason to remove SCM_SMOB_OBJECT_LOC, for example, and to
> > disallow pointers to SCM in general (since we must control all
> > assignments)?
>
> I don't think GCC uses `volatile' to emit the memory barriers
> Ken is refering to. Using `volatile' to solve this problem
> seems to me to be a non-starter.
There are two issues here: one is guaranteeing atomic access to SCM
values (SCM is a pointer type, i.e., a full word). The other is
synchronizing memory (weekly ordered or not), so that all CPUs have a
coherent view of memory at a certain point in time.
We only need to solve the first issue for all accesses to SCM values
(I think). The second issue might need to be addressed for a certain
small number of situations, but not in general for all accesses.
To put it differently, the question is what kind of memory model to
present to a multi-threaded Scheme program.
1) We must guarantee atomic accesses to values (where a 'value' is a
machine word) because a Scheme program must not crash because of
corrupted values, even when the threads of the program are not
properly synchronized.
2) We can get by with a weakly ordered memory model since out-of-order
stores do not crash the system. They might cause the Scheme program
to be incorrect, but you need to properly synchronize it anyway.
As to 1), hopefully 'volatile' will guarantee atomic loads and stores.
Does it? It will be enough if it just happens to work on the most
important SMP platforms. (I.e., I could imagine that there is no way
to atomically read a 32-bit word on a CPU with a 16-bit bus, but I can
also imagine that these CPUs are not used in SMP systems any more that
we need to care about.)
As to 2), the Single Unix Specification says that a number of pthread
functions (and others) synchronize memory between threads, so that
using mutexes etc in the normal way will take care of memory
coherency, including weakly ordered memory.
Does this make sense? I am still grabbling with the fundamentals, it
seems...
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2005-02-10 11:15 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-21 18:29 Some introductory docs about C level threading Marius Vollmer
2005-01-21 21:20 ` Neil Jerram
2005-01-24 19:23 ` Marius Vollmer
2005-02-15 4:11 ` Robert Uhl
2005-01-22 12:37 ` tomas
2005-01-24 19:28 ` Marius Vollmer
2005-01-25 9:06 ` tomas
2005-01-25 15:58 ` Rob Browning
2005-01-25 16:01 ` Rob Browning
2005-01-26 9:05 ` tomas
2005-02-01 16:01 ` Marius Vollmer
2005-02-02 9:31 ` tomas
2005-02-02 13:18 ` Marius Vollmer
2005-02-02 13:47 ` tomas
2005-01-23 23:34 ` Kevin Ryde
2005-01-24 19:31 ` Some new reference docs about initialization Marius Vollmer
2005-01-24 20:27 ` Andreas Rottmann
2005-01-24 22:00 ` Marius Vollmer
2005-02-01 17:37 ` Some introductory docs about C level threading Ken Raeburn
2005-02-01 23:40 ` Kevin Ryde
2005-02-02 0:38 ` Ken Raeburn
2005-02-07 0:48 ` Kevin Ryde
2005-02-08 21:45 ` Ken Raeburn
2005-02-09 12:17 ` Marius Vollmer
2005-02-09 20:26 ` Kevin Ryde
2005-02-10 11:36 ` Marius Vollmer
2005-02-09 12:13 ` Marius Vollmer
2005-02-09 18:10 ` Ken Raeburn
2005-02-10 12:05 ` Marius Vollmer
2005-02-10 19:59 ` Ken Raeburn
2005-02-09 12:08 ` Marius Vollmer
2005-02-09 16:33 ` Doug Evans
2005-02-10 11:15 ` Marius Vollmer [this message]
2005-02-09 20:19 ` Kevin Ryde
2005-02-09 12:04 ` Marius Vollmer
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=ljhdkksm24.fsf@troy.dt.e-technik.uni-dortmund.de \
--to=marius.vollmer@uni-dortmund.de \
--cc=guile-user@gnu.org \
--cc=raeburn@raeburn.org \
--cc=user42@zip.com.au \
/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).