Moving objects...

Travis Griggs tgriggs at keyww.com
Fri Jul 23 16:12:49 UTC 1999


Peter Smet wrote:

> I have been reading a book on mobile objects, and some of the limitations of
> the technique. It made me wonder about how Squeak and Smalltalk deal with
> these issues (rather better I suspect). Firstly, Java will not allow threads
> to be serialized. Is the same true of Processes in Squeak? Can these be
> saved and restored to their execution state in a different image? This is
> important for the idea of mobile software agents. The reason this is
> probably difficult in Java is because it uses native threads.
> <snip>

Peter,

Thanks for this post. I have been Smalltalking for a number of years now, I've
used BOSS a bit, and I've done a decent amount of multi processing in ST, but
the notion of mixing the two had never occured to me until today. Since, I have
VW here at work up and running, I ran an experiment there, which was precisely
as you asked. Create a process, boss it, reincarnate it. The following workspace
chunk for VW does just that:


| proc ws bos proc2 |
Transcript show: 'First, we''ll start up our little hi-bye process and let it
run for 10 seconds...stay tuned.'; cr.
proc := [| bool | bool := false.
[bool := bool not. bool ifTrue: [Transcript show: 'Hi'; tab] ifFalse:
[Transcript show: 'Bye' ; tab]. (Delay forSeconds: 1) wait] repeat] fork.
(Delay forSeconds: 10) wait.

Transcript cr; show: 'Now we''ll save him (while he''s running) to a file called
test.bos' ; cr.
ws := 'test.bos' asFilename writeStream.
bos := BinaryObjectStorage onNew: ws.
[bos nextPut: proc] ensure: [bos close].
(Delay forSeconds: 1) wait.

Transcript cr; show: 'Now... let''s reincarnate him and start him up along his
original self :)' ; cr.
bos := BinaryObjectStorage onOld: 'test.bos' asFilename readStream.
[proc2 := bos next] ensure: [bos close].
((Processor instVarAt: 1) at: proc2 priority) add: proc2.
(Delay forSeconds: 5) wait.
Transcript cr; show: 'Look Ma! two processes!
  ...hmmm... wonder if Java could do this one...'; cr.

(Delay forSeconds: 5) wait.
proc terminate.
proc2 terminate.
Transcript show: 'Kind of cool, huh? All cleaned up now.'; cr.


How totally cool. I'll give this a whirl with Squeak tonite (if somebody else
hasn't already by then). I imagine it ought to work. The ramifications of what
one could do with this are pretty cool. I could use sockets to stream active
processes out across the net to other machines. To those who do agents and stuff
like that, maybe this is old hat, but it was an "aha" for me... just had to
share.

(I cross posted to c.l.s. because this was just so cool).

--
Travis Griggs (a.k.a. Lord of the Fries)
Member, Fraven Skreiggs Software Collective
Key Technology
P-P-P-Penguin  Power!





More information about the Squeak-dev mailing list