[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some introductory docs about C level threading
From: |
Ken Raeburn |
Subject: |
Re: Some introductory docs about C level threading |
Date: |
Wed, 9 Feb 2005 13:10:59 -0500 |
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.
- Re: Some introductory docs about C level threading, (continued)
- Re: Some introductory docs about C level threading, Ken Raeburn, 2005/02/01
- Re: Some introductory docs about C level threading, Kevin Ryde, 2005/02/01
- Re: Some introductory docs about C level threading, Ken Raeburn, 2005/02/01
- Re: Some introductory docs about C level threading, Kevin Ryde, 2005/02/06
- Re: Some introductory docs about C level threading, Ken Raeburn, 2005/02/08
- Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/09
- Re: Some introductory docs about C level threading, Kevin Ryde, 2005/02/09
- Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/10
- Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/09
- Re: Some introductory docs about C level threading,
Ken Raeburn <=
- Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/10
- Re: Some introductory docs about C level threading, Ken Raeburn, 2005/02/10
- Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/09
- Re: Some introductory docs about C level threading, Doug Evans, 2005/02/09
- Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/10
- Re: Some introductory docs about C level threading, Kevin Ryde, 2005/02/09
Re: Some introductory docs about C level threading, Marius Vollmer, 2005/02/09
Re: Some introductory docs about C level threading, Robert Uhl, 2005/02/14