On Wed, Sep 9, 2020 at 11:55 PM Yonatan Gizachew <emeg...@gmail.com> wrote:
>
> Thank you for the explanation. For example, please have a look at the this bt.
> __tls_get_addr is called after runtime.getg. So, what does __tls_get_addr 
> return at this time, a pointer to runtime.g or runtime.g itself?

If I recall correctly, __tls_get_addr (which is of course a general
utility that has nothing particularly to do with Go) will return the
address of runtime.g for the thread that calls it.

Ian



> On Thursday, September 10, 2020 at 12:15:04 PM UTC+9 Ian Lance Taylor wrote:
>>
>> On Wed, Sep 9, 2020 at 7:39 PM Yonatan Gizachew <eme...@gmail.com> wrote:
>> >
>> > This might be trivial, but could you explain me the relationship between 
>> > the following?
>> > 1. value returned by __tls_get_addr
>>
>> This is the address of the TLS control block. The exact definition
>> depends on the architecture. All TLS variables are at some offset
>> from this value.
>>
>> > 2. runtime.g
>>
>> A TLS variable that holds the current goroutine, a pointer to a g struct.
>>
>> > 3. runtime.g0
>>
>> A global variable that holds the g struct used for the initial goroutine.
>>
>> > 4. runtime.m0
>>
>> A global variable that holds the m struct used for the initial thread.
>>
>> > 5. runtime.m
>>
>> gccgo no longer uses this. In earlier releases it was a TLS variable
>> that holds the current thread, a pointer to an m struct. In current
>> releases gccgo uses g->m for this.
>>
>> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/20dd490b-f972-4af7-bf4c-f2ab8188c5c1n%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXTEX8i6j6qdcr4jEdOo%2Beix8zoepn4by8nuO%2BirqXF8w%40mail.gmail.com.

Reply via email to