Continuations are a generalization of threads, which means NekoVM nearly supports continuations already...
> I noticed that Lua supports coroutines (a potential use of continuations), > which they claim are useful for implementing multi-tasking on devices > which do not supporting pre-emptive multi-threading, or for lower overhead > multi-tasking: > > http://lua-users.org/lists/lua-l/2007-11/msg00248.html > http://www.lua.org/manual/5.1/manual.html#5.2 > > Let's assume that even without the optimization below, that continuations > save an entire copy of the stack, then this overhead (other than latency > on initial save) will be insignificant for implementing coroutines when > the running time of the coroutines is long compared to time to save stack, > because the stacks will not be resaved each time the coroutines call each > other (alternating execution, i.e. cooperative multitasking). One (e.g. NekoVM's) way to implement multi-threading is to have a separate stack (VM machine) for each thread, then place all state (variables) on the stack (and/or do thread locks on shared state and resources). Thus continuations are just a generalization where a pre-existing stack can be (copied and) forked, and where the switch to the alternate stack of execution is explicitly issued by the program. Thus to support continuations, apparently NekoVM only needs the add a parameter to neko_vm_alloc() so that it can copy the stack and registers of a pre-existing instance: http://nekovm.org/doc/mt If the threads will not be pre-emptively switched because continuatons are explicitly resumed, then the thread locks are probably unnecessary in most cases. -- Neko : One VM to run them all (http://nekovm.org)
