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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With