|
From: | Noah Lavine |
Subject: | Re: Thread-unsafe initialization problems in Guile |
Date: | Tue, 5 Mar 2013 22:39:10 -0500 |
Hi Noah,
Noah Lavine <address@hidden> writes:If we were to do that, we'd have to add memory barriers in two places:
> I've only read the most recent article you posted, but if I understand
> correctly, there is a third option: (3) somehow find a way to generate
> a portable memory barrier instruction. Is that currently possible?
(1) after writing to the lazily-initialized variable, and (2) before
reading from it. While memory barriers are somewhat more efficient than
mutexes, they are still very expensive.
As for portability, C11 is the first C standard to support memory
barriers. For now, our best bet would probably be to use libatomic_ops,
which is also used by libgc.
> Probably option (2) is best if we can do it.Agreed. Unfortunately, in these cases option (2) would significantly
increase the number of modules that need to be loaded at initialization
time. That's why I reluctantly chose option (1).
[Prev in Thread] | Current Thread | [Next in Thread] |