How can I freeze a task?
I mean, if I have a task
task body My_Task is
begin
accept Start;
loop
Put ("1");
Put ("2");
Put ("3");
...
Put ("n");
end loop;
end My_Task;
is there a way that I can "freeze" the task in its current state? If, for instance, the execution finished executing Put ("2");, how can I freeze it and later I can turn it to continue? I want to provoque a freeze from outside the task, and also from outside, order it to continue.
Update
I could sure implement, if I had the spec like
type State_Type is
(RUN,
FROZEN);
task type My_Task (State : State_Type) is
entry Start;
end My_Task;
the body
task body My_Task is
begin
accept Start;
loop
Put ("1");
Put ("2");
Put ("3");
...
Put ("n");
loop
if State = RUN then exit; end if;
end loop;
end loop;
end My_Task;
but it would not be the case because I had to wait for the nth Put instruction line (i.e., the task would not be actually frozen, because the inside loop would be running).
exitimmediately (ifState = RUN), or it will loop indefinitely doing nothing. - Keith ThompsonState, but also nothing could change its value (because it's a discriminant; ARM 3.7(30)). - Simon Wright