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