[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some introductory docs about C level threading
From: |
Marius Vollmer |
Subject: |
Re: Some introductory docs about C level threading |
Date: |
Thu, 10 Feb 2005 13:05:04 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
Ken Raeburn <address@hidden> 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.
- 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, 2005/02/10
- Re: Some introductory docs about C level threading,
Marius Vollmer <=
- 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