Re: ATC, an example please.



On 30 Jun 2005 01:44:52 -0700, e.coli wrote:

> how ATC work?

ATC transfers control, it does not abort any other task. This is why you
have to explicitly kill the task. Another error in your code is that you
wait not for the calculation completion, but for its initiation.

> can you fix this example,please?

Try this:

with Ada.Text_Io;

procedure Atc_Test is
task A_Task is
entry Start;
entry Ready;
end A_Task;

task body A_Task is
begin
loop
accept Start;
Ada.Text_Io.Put_Line("one.start");
for Iteration in 1..100_0000 loop
Ada.Text_Io.Put (".");
end loop;
accept Ready;
Ada.Text_Io.Put_Line("one.end");
end loop;
end A_Task;

begin
A_Task.Start; -- Initiate calculation
select
delay 2.0; -- After time-out expiration,
abort A_Task; -- kill the task!
Ada.Text_Io.Put_Line ("Long calculation abandoned");
then
abort A_Task.Ready; -- Wait for completion
end select;
Ada.Text_Io.Put_Line ("end main");

end Atc_Test;

----------------------
N.B. This is a wrong way to do things. Don't use ATC if you cannot prove
that there is no other way. Don't abort task, which is even more brutal
than ATC.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: Storage management
    ... Aborting blocking I/O is "guaranteed not to work"? ... There is no way Ada could abort I/O if the OS does not allow this. ... I would give 98% that it never will work with ATC. ... could not be aborted with ctrl-C. ...
    (comp.lang.ada)
  • Re: ATC, an example please.
    ... it does abort any tasks inside the abortable region of the ATC. ... the same for aborting a task as they are for aborting ...
    (comp.lang.ada)
  • Re: ATC, an example please.
    ... >> ATC transfers control, it does not abort any other task. ... it does abort any tasks inside the abortable region of the ATC. ...
    (comp.lang.ada)
  • Re: No need for ATC clearance to enter class C airspace
    ... sense to require ATC clearance. ... VFR without flight following around a class C airspace. ... The reg used to state two-way communication and permission to enter. ... entry into the Class C can be refused even with *established* ...
    (rec.aviation.student)