Листинг №1
Процедуры приема и передачи сообщений управляющей транспьютерной
программы, осуществляющей построение поверхности Манделброта (Mandelbrot)
{ The Send thread runs in this procedure. }
PROCEDURE Send (X_Inc : CGA_LoRes_X; Y_Inc : CGA_Y);
VAR
X : CGA_LoRes_X;
Y : CGA_Y;
C: Command;
BEGIN
WHILE TRUE DO BEGIN
{ Wait here for instructions from Main thread }
Chan_In_Message (12, C.Details, Int_Chan);
X := 0;
WHILE X < Max_CGA_LoRes_X DO BEGIN
C.T.Tlx := X;
C.T.Brx := X + X_Inc-1;
Y := 0;
WHILE Y < Max_CGA_Y DO BEGIN
C.T.Tly := Y;
C.T.Bry := Y + Y_Inc-1;
{ Send off the command packet }
Net_Send (Size(C), C, True);
Y := Y + Y_Inc
END;
X := X + X_Inc
END
END
END;
{ The Receive thread runs in this procedure }
PROCEDURE Receive (VAR Tally_Done : Tally);
VAR
Len, I, N: Integer;
Complete: Boolean;
X: CGA_LoRes_X;
Y: CGA_Y;
Col: Colour;
R: Results;
Thr: T_Num;
BEGIN
WHILE TRUE DO BEGIN
Len := Net_Receive (R, Complete);
I := 1;
FOR Y := R.T.Tly TO R.T.Bry DO BEGIN
FOR X := R.T.Tlx TO R.T.Brx DO BEGIN
N := R.Counts[I]; I := I+1;
{ Received 0 means 1; 255 means 256; etc }
N := N + 1;
{ Work out colour from N and thresholds }
Col := 0;
FOR Thr := 1 TO 3 DO
IF N > Thresholds[Thr] THEN Col := Thr;
{ Display the dot }
CGA_LoRes_Plot (X, Y, Col)
END
END;
{ Increment tally of packets displayed }
Tally_Done := Tally_Done + 1;
END