Strange Process Question
Colin Putney
cputney at wiresong.ca
Thu Aug 17 15:49:48 UTC 2006
On Aug 17, 2006, at 7:35 AM, Rich Warren wrote:
> Can I suspend myProc and save it to disk (seperately from quitting
> and saving the whole image)? Can I load it into different objects
> and resume it? Can I sneaker net it to a different machine and load
> it in a completely different copy of Squeak? Or will bad things
> happen?
In theory, yes, you can. A Process is just objects, and if you
reconstruct those objects in another Squeak image exactly as they are
here, it should resume just fine. In practice, however, it's
difficult to get it to work.
One of the issues is getting all the objects you need. A Process is
basically a linked list of activation contexts (stack frames). You
can walk that list and do whatever you like with the contexts - this
is how Seaside implements continuations, for example. So lets say
you're serializing them to disk. Each context contains references to
its local variables, so you've got to serialize those as well. And of
couse, those objects have their own internal states and references to
other objects. Activation contexts also refer to the CompiledMethods
that are being executed, so you've got to make sure they get
serialized, along with all their literal objects. Often those
literals include classes, with all *their* compiled methods... once
all those objects are included in your serialization, you're likely
to have the entire image.
You might take a few shortcuts, like just including stubs that stand
in for CompiledMethods, so you can hook them up to their equivalent
versions when you rematerialize the process in the new image. In that
case, though, there's the risk that the new image won't be quite like
the old one, and there will be a different version of the method
present, or it might be missing all together. In that case the
process wouldn't be able to resume properly.
So again, in theory possible, in practice difficult. Gets easier if
you can narrow the scope of what you want to do - Projects are a good
example of this.
> As a quick experiment, I tried to "save and quit" squeak while I
> had a suspended process. Squeak locked up completely. I only tried
> it once, however. So that may have just been a bit of random
> misfortune. But it's the only time squeak has ever locked up on me.
Beats me. There should be no problem saving Squeak with a suspended
process, though.
Colin
More information about the Squeak-dev
mailing list
|