开发者

Coroutines with a growing stack in C

开发者 https://www.devze.com 2023-02-23 06:17 出处:网络
I want to use coroutines in C (Linux), but I don\'t want to waste lots of space for each one. I\'m wondering about allocating the space for the stack with mmap开发者_如何转开发() given MAP_GROWSDOWN,

I want to use coroutines in C (Linux), but I don't want to waste lots of space for each one. I'm wondering about allocating the space for the stack with mmap开发者_如何转开发() given MAP_GROWSDOWN, but I read somewhere that it was broken, do you know any more about this?


but I don't want to waste lots of space for each one

Don't worry about it. Your coroutine can have a large stack but it will not cause any performance or resource problems unless the stack is actually used. The logical pages of memory will not be assigned physical pages until that point. And if it is used, well you needed it then didn't you?

Just use a decent sized stack and have done with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号