Hacker News new | ask | show | jobs
by vvnraman 5214 days ago
I would like to know something here. Since there is only 1 stack for a pThread and the stack state is swapped on a context switch for a co-routine within a pThread, wouldn't this be quite expensive if there are a lot of variables on stack for that co-routine? Or is the swapping being carried out in a different manner, eg. caching, pre-allocated stacks, etc..
1 comments

If you don't have large variables allocated on the stack, the copy is quite fast. This is easily avoidable by allocating on the heap.