Листинг №3
Процедуры
рабочей задачи
PROCEDURE Worker;
VAR
X: CGA_LoRes_X;
Y: CGA_Y;
Count, N: Integer;
Complete: Boolean;
Gap, X_Coord, Y_Coord,
AC, BC, Sq, A2, B2, A, B: ShortReal;
BEGIN
WHILE TRUE DO BEGIN { Endless loop }
{ Wait here till packet arrives }
N := Net_Receive (C, Complete);
{ Unpack some of the parameters }
X_Coord := C.Details.X_Coord;
Y_Coord := C.Details.Y_Coord;
Gap := C.Details.Gap;
{ Top-left and bottom-right corners specified which part to do }
N := 1;
FOR Y := C.T.Tly TO C.T.Bry DO BEGIN
BC := Y_Coord - Y*Gap;
FOR X := C.T.Tlx TO C.T.Brx DO BEGIN
AC := X*Gap + X_Coord;
A := AC; B := BC; Sq := 0; Count := 0;
{ Do calculation until > 2 away, or count reaches 256 }
A2 := A*A; B2 := B*B;
WHILE (Sq < 4) AND (Count < 256) DO BEGIN
B := 2*A*B + BC;
A := A2 - B2 + AC;
A2 := A*A; B2 := B*B;
Sq := A2 + B2;
Count := Count + 1;
END;
{ Store 0 means 1; stored 255 means 256 }
R.Counts[N] := Count - 1;
N := N + 1
END
END;
{ Send top-left and bottom-right coordinates back to MANDELM
as well, to identify the data... }
R.T := C.T;
Net_Send (Size(Tile)+N, R, True)
END { of endless loop }
END;