-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
想问一下为什么这里要将函数返回地址保存起来呢? #91
Comments
@hnes 谢谢答复,其实主要比较疑惑的就是函数返回地址本身就作为栈帧的一部分,却特意将其保存起来之后再恢复这个行为不太能理解,也谢谢您的推荐,最近在研究协程,会仔细阅读下您的代码和资料 |
@asdf1352 不用客气,有问题的话欢迎继续交流 :) |
libco需要实现拷贝栈,然而在协程切换之前,需要拷贝保存的内容到底有多长是不知道的。所以必须在栈切换的时候保存好栈指针前面的所有内容。 |
@yuanzhubi 原来如此,只在看独立栈没看拷贝栈的情况,谢谢大佬 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
libco/coctx_swap.S
Line 51 in 8ce6dfe
对这一处不太明白,既然每一个协程都有自己的栈帧,函数返回地址又是保存在栈帧中的,不同于共享的寄存器,栈是相互独立的,为什么这里还要把返回地址压栈?,比如说我考虑成
`
#if defined(i386)
leal %esp, %eax //sp
movl 4(%esp), %esp
leal 32(%esp), %esp //parm a : ®s[7] + sizeof(void*)
`
这样会有什么问题呢?
The text was updated successfully, but these errors were encountered: