Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

工作线程和m的绑定逻辑 #3

Open
kunkun1011 opened this issue Apr 21, 2022 · 0 comments
Open

工作线程和m的绑定逻辑 #3

kunkun1011 opened this issue Apr 21, 2022 · 0 comments

Comments

@kunkun1011
Copy link

get_tls(CX)
MOVQ g(CX), BX; BX存器里面现在放的是当前g结构体对象的地址

#ifdef GOARCH_amd64
#define get_tls(r) MOVQ TLS, r
#define g(r) 0(r)(TLS*1)
#endif


0(r)(TLS1),这个表达式的执行逻辑是:(0+TLS+TLS)吗,这样取到的地址不是错的吗,请教下大佬这个问题


get_tls(BX) //获取fs段基址到BX寄存器
LEAQ runtime·g0(SB), CX //CX = g0的地址
MOVQ CX, g(BX) //把g0的地址保存在线程本地存储里面,也就是m0.tls[0]=&g0

接着上面的问题,为啥g(BX)取到的是m0.tls[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant