Clusters, grids and Squeak
David T. Lewis
lewis at mail.msen.com
Tue Apr 19 11:01:00 UTC 2005
On Tue, Apr 19, 2005 at 10:55:17AM +0100, Darren Hobbs wrote:
> What might work is starting one headfull image to act as task
> coordinator, and devise a way to launch a bunch of very cut-down
> headless 'worker' images. The kind of client code that I'm imagining
> might look like this:
>
> 95 timesRepeat: [GridWorkerProcess new].
> GridScheduler allWorkersDo:[MyComputeIntensiveGridTask new].
Try this:
| myWorkers p1 p2 worker messageFromSupervisor |
myWorkers := (1 to: 95) collect: [:e |
p1 := OSPipe nonBlockingPipe.
p2 := OSPipe nonBlockingPipe.
worker := UnixProcess forkHeadlessSqueakAndDoThenQuit:
[(Delay forMilliseconds: 200) wait.
messageFromSupervisor := p1 reader upToEnd.
p2 writer nextPutAll: messageFromSupervisor.
p2 writer nextPutAll: ' received by worker ',
OSProcess thisOSProcess pid asString.
p2 close].
p2 closeWriter.
p1 nextPutAll: e asString, ': hello to worker from coordinator ',
OSProcess thisOSProcess pid asString.
p1 close.
Array with: worker with: p2].
myWorkers do: [:w |
Transcript show: w first asString, ': ', w second upToEnd; cr.
w second close].
Dave
More information about the Squeak-dev
mailing list
|