Cancel a process in Ada that uses a secure object that requests

I am experiencing some problems with my program.

I have a process that calls a function (Take_Job) that must remain locked until it passes (MINIMUM_WAIT). If this does not happen, a message appears informing you of this situation.

for Printer_Id in Type_Printer_Id loop
   select
      delay MINIMUM_WAIT
      Pragma_Assert (True, "");
   then abort
      Take_Job (Controller,
                     Printer_Id,
                     Max_Tonner,
                     Job,
                     Change_Tonner);
      Pragma_Assert
        (False,
           "Testing of Take_Job hasn't been successful. It should have remained blocked.");
   end select;
end loop;

The Take_Job function calls a record in the protected object:

procedure Take_Job (R                 : in out Controller_Type;
                         Printer      : in     Type_Printer_Id;
                         Siz          : in     Typo_Volume;
                         Job          :    out Typo_Job;
                         Excep_Tonner :    out Boolean) is
begin
   R.Take_Job(Printer, Siz, Job, Excep_Tonner);
end Take_Job;

Where "R" is a protected object.

- . , "" , . Ada , " ", " " , .

entry Take_Job(Printer_Id: in Type_Printer_Id; Remaining: in Type_Volume; Job: out Type_Job; exceptionTonner: out Boolean)
when True is
begin
   Copy_Remaining(Printer_Id) := Remaining;
   requeue Take_Job_Delayed(Printer_Id);
end Take_Job;

:

entry Take_Job_Delayed(for J in Type_Printer_Id)(Printer_Id: in Type_Printer_Id; Remaining: in Type_Volume; Job: out Type_Job; exceptionTonner: out Boolean)
when False is -- I've done this on purpose
begin
   null; -- Actually, there would be a lot of code here
end Take_Job_Delayed;

, - MINIMUM_WAIT "Pragma_Assert (True," ")". "" Take_Job "False", . Take_Job , Pragma_Assert . "True" "when" Take_Job_Delayed "False", , , Pragma_Asserts .

? , "requeue" - , ?

+4
1

with abort;

entry Take_Job(Printer_Id: in Type_Printer_Id;
               Remaining: in Type_Volume;
               Job: out Type_Job;
               exceptionTonner: out Boolean)
when True is
begin
   Copy_Remaining(Printer_Id) := Remaining;
   requeue Take_Job_Delayed(Printer_Id) with abort;
end Take_Job;

. ARM 9.5.4 Burns and Wellings, "Concurrency Ada" .

+5

Source: https://habr.com/ru/post/1527889/


All Articles