From: Ken Raeburn <raeburn@raeburn.org>
Cc: guile-user@gnu.org
Subject: Re: Some introductory docs about C level threading
Date: Wed, 9 Feb 2005 13:10:59 -0500 [thread overview]
Message-ID: <a1122e084916521c9742dca07890ab6d@raeburn.org> (raw)
In-Reply-To: <lj3bw6szhm.fsf@troy.dt.e-technik.uni-dortmund.de>
On Feb 9, 2005, at 07:13, Marius Vollmer wrote:
>> And volatile declarations may fix the possibility of storing
>> incomplete values, but I don't think it would deal with the
>> cross-thread memory access ordering issue.
> As long as accesses to SCM values are atomic, the ordering of
> loads/stores across threads can be arbitrary.
I think someone might be tempted to do something like:
thread 1, on cpu 1, with guile core mutex locked:
(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?
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. 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.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2005-02-09 18:10 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 [this message]
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
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=a1122e084916521c9742dca07890ab6d@raeburn.org \
--to=raeburn@raeburn.org \
--cc=guile-user@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).