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

Листинг №2

Главная процедура мастер-задачи

{ The Main thread runs in this procedure }  
PROCEDURE Main;  
VAR  
   { Workspace for Send and Receive threads }  
   Send_WS, Receive_WS: ARRAY [1..WS_Size] OF Byte;  
   User_Input: Set_Details;  
   T: T_Num;  
   Range: ShortReal;  
   Tally_Done, Previous_Tally: Tally;  
BEGIN  
   { Text mode, clear screen and sign on }  
   …  
   { Initialise the channel for communicating with Send }  
   Chan_Init (Int_Chan);  
   { Start the other threads }  
   Tally_Done := 0;  
   Thread_Start_Send (Send, Send_WS, WS_Size, Thread_Urgent,  
                 2, X_Increment, Y_Increment);  
   Thread_Start_Receive (Receive, Receive_WS, WS_Size, Thread_Urgent,  
                 1, Tally_Done);  
   { Main Loop }  
   WHILE TRUE DO BEGIN  
      …  
      { Reset count of finished packets to zero: the Receive thread  
        will count it back up as the packets come in...              }  
      Tally_Done := 0;  
      { Send the instructions to Send }  
      Chan_Out_Message (12, User_Input, Int_Chan);  
      { Until all the packets have been done, just keep updating the  
        display when necessary                                       }  
      Previous_Tally := 0;  
      WHILE Tally_Done < Packets DO BEGIN  
         WHILE Tally_Done = Previous_Tally DO Thread_Deschedule;  
         CGA_Update;  
         Previous_Tally := Tally_Done;  
      END;  
      …  
   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
Популярные статьи
КомпьютерПресс использует