in reply to Restarting Threads

I was informed that save() restore() is not a common concept.... In running our simulations we need the ability to simulate to a point and save the state of the run.

Are you talking about:

Or

To my knowledge, neither is currently available for ithreads, but (at least in an off-the-top-of-my-head, completely speculative theory), both might be possible. Either would be a considerable amount of work.

My basic idea is to use demerphq's Data::Dumper::Streamer module with it's ability to serialise datastructures (including (some?) coderefs), to disk and restore them; and apply it to the thread's defstash (You'll need to search for that term manually).

I've no idea if this is actually possible, or what the results would be if you attempted to restore the default stash without all of Perl's internal stacks etc., but it might be fun to explore the possibilities.

Update: On Win32, the fork emulation effectively clones a thread, state, run context et al. If this is your target platform, that might also form the basis of an attack. If you forked the thread and left the clone suspended--you could resume it at a later point.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Restarting Threads
by Helter (Chaplain) on Apr 24, 2006 at 18:02 UTC
    Of the choices the java-style hibernate is what we do. For example if we have a long sequence we do every run we will run that sequence once, save and then use the snapshot to get to the "good/interesting" verification faster.

    Target platform is Linux so your last point goes away :-(

    Just to clarify (with only a few minutes of reading...much more to do), your thought is to use the Streamer module to stream the run of the thread as it goes, then when we do a restore() grab the previous state...Interesting.
    Again, much more to read, but is there a defstash for the top level thread, or are Perl threads not done that way?

    Off to read some! Thanks!