The coroutine implementation is equivalent to 1-shot continuations. By adding the ability to deep-copy coroutines, Jogo would have full continuation support. The question is: How could this be done efficiently? The naïve solution would simply copy the whole coroutine stack. A more efficient implementation would use copy-on-write, perhaps doing something tricky with SIGSEGV and copy-on-write memory pages to detect writes. The deep-copy would be started by the fork function:
The coroutine implementation is equivalent to 1-shot continuations. By adding the ability to deep-copy coroutines, Jogo would have full continuation support. The question is: How could this be done efficiently? The naïve solution would simply copy the whole coroutine stack. A more efficient implementation would use copy-on-write, perhaps doing something tricky with SIGSEGV and copy-on-write memory pages to detect writes. The deep-copy would be started by the
fork
function:This would output: