Can I do cooperative multi-tasking?
Posted: Thu Jun 05, 2014 2:10 am
Is there a possibility of a function that lets me pivot the execution, in the way of saving the current environment (i.e., stacks etc) into a pdl of such, then pop and continue with a saved environment?
Thus, I imagine a function, say (pivot store), that firstly makes a blob (copy) of the current exection state, then pushes that onto the given "store" (list of blobs) or, if nil, onto an internal store, then pops a blob from the internal store, before restoring this as execution state, which thus continues. (Of course, the continuation should be as an immediate return from that other call of "pivot", rather than pushing the blob again)
That kind of primitive would open the gate for cooperative multi-tasking, and allow programs with thousands of light-weight "virutally concurrent" pursuits, such as large scale simulations, as well as other domains where "parallel pursuits" design is desired.
I've started with the coding, but I'm not fully on top of the extent of things to include in the execution state blob, and wanted to check here for pointers and thoughts first.
Thus, I imagine a function, say (pivot store), that firstly makes a blob (copy) of the current exection state, then pushes that onto the given "store" (list of blobs) or, if nil, onto an internal store, then pops a blob from the internal store, before restoring this as execution state, which thus continues. (Of course, the continuation should be as an immediate return from that other call of "pivot", rather than pushing the blob again)
That kind of primitive would open the gate for cooperative multi-tasking, and allow programs with thousands of light-weight "virutally concurrent" pursuits, such as large scale simulations, as well as other domains where "parallel pursuits" design is desired.
I've started with the coding, but I'm not fully on top of the extent of things to include in the execution state blob, and wanted to check here for pointers and thoughts first.