4 ms·
Kind of interesting. Allocate a stack for the coroutine on context switch and memcpy the current stack into it. Pointers into the stack get invalidated on cont
by JonChesterfield 4y ago
Kind of interesting. Allocate a stack for the coroutine on context switch and memcpy the current stack into it.
Pointers into the stack get invalidated on context switch which kills most of the advantage of a stackful coroutine. Alloc+copy per context switch makes context switching more expensive which kills the rest of the advantage. It does seem simpler than dealing with unknown size stacks though.
I see the attraction of allocating the stack on first yield but not on every yield.