-
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
协程共享栈的问题 #8
Comments
看代码终于明白了。以example_copustack.cpp为例,它在一个线程中分配了128个栈,则128n(n>=0)号协程都使用0号栈,128n+1使用1号栈,以此类推。 |
这个优化点,主要在于,栈的内存峰值不一定是栈切换时发生的。 |
这个感觉优化有限,因为并不能控制一定在4k的时候切换,如果切换的时候就是8k,那不是还浪费了8k的空间存储? |
1.不会存在浪费 |
学习了,非常感谢! |
close |
看了源码和这篇文章《揭秘:微信是如何用libco支撑8亿用户的》,对共享栈那里有点不能理解啊!
尤其这里“libco也提供了stackless的协程共享栈模式,可以设置若干个协程共享同一个运行栈。”,谁能结合代码讲一下?co_swap就行
The text was updated successfully, but these errors were encountered: