#fork and deterministic resumption of the resulting process

Michael van der Gulik mikevdg at gmail.com
Fri Feb 8 10:16:23 UTC 2008


On Feb 8, 2008 10:38 PM, Michael van der Gulik <mikevdg at gmail.com> wrote:

>
>
>
>
> go
>     | anArray numProcesses step |
>     anArray := Array new: 60000. "Assume an even larger number for
> realistic examples"
>     numProcesses := 32.
>     step := anArray size // numProcesses.
>     1 to: anArray size by: step do: [ :i |
>         [
>             i to: (i+numProcesses-1) do: [ :j |
>                 anArray at: j put: j ]
>         ] fixTemps fork.
>     ].
>     ^ anArray.
>
> However, it doesn't work except for small numbers. I'd be happy if
> somebody would be able to provide a fixed version; I can't work it out.
>
>

That was a really obvious, stupid bug. Try again:

    anArray := Array new: 3200000.
    numProcesses := 64.
    step := anArray size // numProcesses.
    1 to: anArray size by: step do: [ :i |
        [
            i to: i+step-1 do: [ :j |
                anArray at: j put: j ]
        ] fixTemps fork.
    ].


Gulik.

-- 
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080208/75593793/attachment.htm


More information about the Squeak-dev mailing list