guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread-unsafe initialization problems in Guile


From: Mark H Weaver
Subject: Re: Thread-unsafe initialization problems in Guile
Date: Tue, 05 Mar 2013 22:24:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hi Noah,

I wrote:
>   In each of these cases, we have two options: (1) synchronize on every
>   access of the lazily-initialized variable (including reads), or (2)
>   abandon lazy initialization.

Noah Lavine <address@hidden> writes:
> 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?

If we were to do that, we'd have to add memory barriers in two places:
(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).

     Regards,
       Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]