On Thu, Jul 18, 2024 at 11:29 AM Leah Stapleton <leahstapleton...@gmail.com> wrote: > > In the document HACKING.md > (https://github.com/golang/go/blob/master/src/runtime/HACKING.md), it states > that we can determine if we're running on the user or system stack by running > `getg() == getg().m.curg`. > > However if the output of that equality check is true, does that mean we're on > user or system stack?
The user stack. > getg can return the current g but when executing on the system stack it > returns the current M's g0. > > I assume that a true means we're on the user stack because it says "To get > the current user g, use getg().m.curg". However, there's no where that I can > see that says that m.curg can't be the system stack, so please clarify. As it says, getg().m.curg is the current user g. It's never a g0. A g0 is never a user g. Each g has its own stack. A g0 has a fixed system thread stack, a user g has a Go-managed user stack. 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/CAOyqgcXZPp%3DNb1aBHxKLsO31XppeyJVHTtK5TyS3mss7wDW9YA%40mail.gmail.com.