On May 21, 2013, at 7:46 AM, Alexander Burger <a...@software-lab.de> wrote:
> The big question is: Will the system (which system?) do that? If so, how
> do other languages implement green threads, coroutines or continuations?
Some OSs do provide the required functionality (e.g, the fibers API on
Windows). On POSIX, it's usually a matter of using some dirty hack
(setjmp()/longjmp() being the most portable, swapcontext() is also quite
popular). When working in embedded/mobile I have seen a couple of platforms
with broken setjmp()/longjmp() implementations, so that can also be troublesome.
The problem is so complex that perhaps your approach is the simplest. Just take
a look at how nasty the thing can get: