libjit
[Top][All Lists]
Advanced

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

Re: [Libjit] [PATCH] windows: fix race condition in _jit_thread_init()


From: Aleksey Demakov
Subject: Re: [Libjit] [PATCH] windows: fix race condition in _jit_thread_init()
Date: Tue, 21 Jan 2014 23:23:07 +0700

On Tue, Jan 21, 2014 at 10:39 PM, Ben Noordhuis <address@hidden> wrote:
> I *think* using _ReadWriteBarrier() like that will work in practice
> but I see two caveats:
>
> a) It's a deprecated function.
>

I guess it might be deprecated in favour of C/C++ 11 standards. But I
don't think it will be removed any time soon, so we should be more
concerned about the support from the older compilers rather than from
newer.

> b) I'm not sure whether it's a full memory fence and compiler barrier.
>

I believe on any SMP architecture the CPU cache eventually gets
updated everywhere, so when checking the value of single memory
location that does not have any ordering requirements wrt other
locations there is no need for hardware memory fence, we just need to
ensure that the compiler won't optimize it in some unexpected way. So
we need only compiler fence in this case.

However using Interlocked API here has the benefit that we won't
introduce dependency on any other API. And initialization happens just
once, so there are no real performance issues here too. So on the
second though I will apply your patch as is. Thanks again for
submitting it.

Regards,
Aleksey



reply via email to

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