On Sun, Aug 14, 2016 at 2:25 AM, gaurav <gauravagarw...@gmail.com> wrote:
>
> How do I get to know the Thread (or CpuCore) id on which the goroutine is
> running?

Go does not expose this information.  In Go it's also unreliable
because the language makes no guarantees about when a goroutine may
move from one thread, or CPU, to another.

> In the get() call of this counter, I need to sum up array values; how does
> one ensure that the  latest values written to the array are visible to the
> goroutine calling the get() method? Are the values written using atomic
> package made visible to all cores immediately? Or else, does
> atomic.LoadInt32()guarantee to return the latest values? I think the problem
> is that atomic package does not say anything about visibility of memory
> updates across cores.

The lack of documentation is https://golang.org/issue/5045.  It's not
the case that values written are visible to all cores for ordinary
memory access, but they are visible if you use atomic.LoadNN.  What is
unclear is what that says about other memory writes, but I think the
current implementation, and all plausible future implementations,
treat Store as a store-release and treat Load as a load-acquire.

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