On Sat, Mar 18, 2017 at 12:03 PM, T L <tapir....@gmail.com> wrote:
>
> At the end of sync/atomic package docs, it says
>
> On x86-32, the 64-bit functions use instructions unavailable before the
> Pentium MMX.
>
>
> On non-Linux ARM, the 64-bit functions use instructions unavailable before
> the ARMv6k core.
>
>
> So when running Go programs which call the 64-bit atomic functions on above
> mentioned machines, programs will crash?

Yes, I think you will that in those cases the program will die of a
`SIGILL` signal.


> If it is true, is it good idea to add a compiler option to convert the
> 64-bit function calls to mutex calls?

It's possible, but I don't think it's a good idea.  When was the last
time you saw an x86 that did not support the Pentium MMX instruction
set?


> And is it possible to do the conversions at run time?

That too is possible.


> And I read from somewhere which says Go authors are some regretted to expose
> the atomic functions,
>
> for these functions are intended to be used in standard packages internally.
>
> So is it a good idea to recommend gophers to use mutex over atomic and
> convert some mutex calls to atomic calls atomically by compiler?

Mutexes and atomic operations are different.  You can implement atomic
operations using mutexes, but you can't easily implement mutexes using
atomic operations.  A better way to think of it is that efficient
mutexes require atomic operations to work, but the mutex code is not
just the atomic instructions.  For example, there is no common used
atomic instruction that implements a mutex lock that suspends the
goroutine until the mutex is unlocked.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to