c954013.a

来自「用于进行gcc测试」· A 代码 · 共 522 行 · 第 1/2 页

A
522
字号
               -- dealing with the first message and the second message is               -- is on the input queue               abort Next_Message_Task.all;  -- Note: we are still in the                                              -- declare block for the                                              -- second message task               -- Make absolutely certain that all the actions               -- associated with the abort have been completed, that the               -- task has gone from Abnormal right through to               -- Termination.  All requeues that are to going to be               -- cancelled will have been by the point of Termination.               while not Next_Message_Task.all'terminated loop                  delay ImpDef.Minimum_Task_Switch;                  end loop;               -- We now signal the Credit task that the abort has taken place               -- so that it can check that the entry queue is empty as the               -- requeue should have been cancelled               TC_Prt.Set_Abort_Has_Completed;            else               -- The main part of the test is complete. Send one Debit message               -- as further exercise of the Distributor to ensure it has not               -- been affected by the cancellation of the requeue.               Build_Debit_Record ( Next_Transaction );                           Next_Message_Task.Accept_Transaction ( Next_Transaction );              end if;         end;   -- declare      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Line_Driver");   end Line_Driver;      task body Message_Task is      TC_Original_Transaction_Code : Transaction_Code;        This_Transaction : acc_Transaction_Record := new Transaction_Record;   begin            accept Accept_Transaction (In_Transaction : acc_Transaction_Record) do         This_Transaction.all := In_Transaction.all;      end Accept_Transaction;            -- Note the original code to ensure correct return      TC_Original_Transaction_Code := This_Transaction.Code;                                                                        -- Queue up on Distributor's Input queue      Distributor.Input ( This_Transaction );      -- This task will now wait for the requeued rendezvous       -- to complete before proceeding                                                   -- After the required computations have been performed      -- return the Transaction_Record appropriately (probably to an output      -- line driver)      null;            -- stub            -- For the test check that the return values are as expected      if TC_Original_Transaction_Code /= This_Transaction.Code then         -- Incorrect rendezvous         Report.Failed ("Message Task: Incorrect code returned");      end if;      if This_Transaction.Code = Credit then         if This_Transaction.Return_Value     /= Credit_Return or               This_Transaction.TC_Message_Count /= 1             or not            This_Transaction.TC_Thru_Dist                      then                Report.Failed ("Expected path not traversed");         end if;         TC_Credit_Message_Complete.Set_True;      else         if This_Transaction.Return_Value     /= Debit_Return  or               This_Transaction.TC_Message_Count /= 1             or not            This_Transaction.TC_Thru_Dist                      then                Report.Failed ("Expected path not traversed");         end if;         TC_Debit_Message_Complete.Set_True;      end if;   exception      when others =>          Report.Failed ("Unexpected exception in Message_Task");   end Message_Task;   -- Dispose each input Transaction_Record to the appropriate   -- computation tasks   --   task body Distributor is   begin      loop         select            accept Input (Transaction : acc_Transaction_Record) do               -- Show that this message did pass through the Distributor Task               Transaction.TC_Thru_Dist := true;               -- Pass this transaction on the the appropriate computation               -- task               case Transaction.Code is                   when Credit =>                     requeue Credit_Computation.Input with abort;                  when Debit =>                      requeue Debit_Computation.Input with abort;               end case;            end Input;         or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Distributor");   end Distributor;                                             -- Computation task.   --   Note:  After the computation is performed in this task and the    --          accept body is completed the rendezvous in the original   --          message task is completed.                                 task body Credit_Computation is      Message_Count   : integer := 0;   begin      loop         select             accept Input ( Transaction : acc_Transaction_Record) do               -- Perform the computations required for this transaction               --               null;     -- stub               -- The rest of this code is for Test Control               --               if not Transaction.TC_Thru_Dist then                   Report.Failed                          ("Credit Task: Wrong queue, Distributor bypassed");               end if;               if Transaction.code /= Credit then                  Report.Failed                         ("Credit Task: Requeue delivered to the wrong queue");               end if;               -- for the test plug a known value and count               Transaction.Return_Value := Credit_Return;               -- one, and only one message should pass through               if Message_Count /= 0 then                  Report.Failed ("Aborted Requeue was not cancelled -1");               end if;               Message_Count := Message_Count + 1;               Transaction.TC_Message_Count := Message_Count;                                       -- Having done the basic housekeeping we now need to signal               -- that we are in the accept body of the credit task.  The               -- first message has arrived and the Line Driver may now send               -- the second one               TC_Prt.Set_First_Has_Arrived;               -- Now wait for the second to arrive               while Input'Count = 0 loop                  delay ImpDef.Minimum_Task_Switch;                  end loop;               -- Second message has been requeued - the Line driver may                -- now abort the calling task               TC_Prt.Set_Second_Has_Arrived;               -- Now wait for the Line Driver to signal that the abort of               -- the first task is complete - the requeue should be cancelled               -- at this time               while not TC_Prt.Abort_Has_Completed loop                  delay ImpDef.Minimum_Task_Switch;                  end loop;                              if Input'Count /=0 then                  Report.Failed ("Aborted Requeue was not cancelled -2");               end if;               -- We can now complete the rendezvous with the first caller            end Input;         or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Credit_Computation");   end Credit_Computation;   -- Computation task.   --   Note:  After the computation is performed in this task and the    --          accept body is completed the rendezvous in the original   --          message task is completed.                                 task body Debit_Computation is      Message_Count   : integer := 0;   begin      loop         select            accept Input (Transaction : acc_Transaction_Record) do               -- Perform the computations required for this message               --               null;      -- stub               -- The rest of this code is for Test Control               --               if not Transaction.TC_Thru_Dist then                   Report.Failed                          ("Debit Task: Wrong queue, Distributor bypassed");               end if;               if Transaction.code /= Debit then                  Report.Failed                         ("Debit Task: Requeue delivered to the wrong queue");               end if;               -- for the test plug a known value and count               Transaction.Return_Value := Debit_Return;               -- one, and only one, message should pass through               Message_Count := Message_Count + 1;               Transaction.TC_Message_Count := Message_Count;            end Input;                     or            terminate;         end select;      end loop;   exception      when others =>          Report.Failed ("Unexpected exception in Debit_Computation");   end Debit_Computation;begin -- c954013   Report.Test ("C954013", "Abort a task that has a call requeued");   Line_Driver.Start;   -- start the test   -- Wait for the message tasks to complete before calling Report.Result.   -- Although two Credit tasks are generated one is aborted so only   -- one completes, thus a single flag is sufficient   -- Note: the test will hang here if there is a problem with the    -- completion of the tasks   while not (TC_Credit_Message_Complete.Value and               TC_Debit_Message_Complete.Value) loop      delay ImpDef.Minimum_Task_Switch;      end loop;   Report.Result;end C954013;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?