Параллельные алгоритмы

Листинг №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  

возврат

Наш канал на Youtube

1999 1 2 3 4 5 6 7 8 9 10 11 12
2000 1 2 3 4 5 6 7 8 9 10 11 12
2001 1 2 3 4 5 6 7 8 9 10 11 12
2002 1 2 3 4 5 6 7 8 9 10 11 12
2003 1 2 3 4 5 6 7 8 9 10 11 12
2004 1 2 3 4 5 6 7 8 9 10 11 12
2005 1 2 3 4 5 6 7 8 9 10 11 12
2006 1 2 3 4 5 6 7 8 9 10 11 12
2007 1 2 3 4 5 6 7 8 9 10 11 12
2008 1 2 3 4 5 6 7 8 9 10 11 12
2009 1 2 3 4 5 6 7 8 9 10 11 12
2010 1 2 3 4 5 6 7 8 9 10 11 12
2011 1 2 3 4 5 6 7 8 9 10 11 12
2012 1 2 3 4 5 6 7 8 9 10 11 12
2013 1 2 3 4 5 6 7 8 9 10 11 12
Популярные статьи
КомпьютерПресс использует