Example 2 – Tasking in ADA

task ALARM is

entry AWAKE;

task body ALARM is

begin

loop

select

accept AWAKE;

or

delay 50.0;

SIGNAL_ALARM;

end select;

end loop;

end ALARM;


 

The above code shows that whether an operator is awake or not. If the operator is awake, then the AWAKE button is pressed every 50 sec. if not, the after a delay of 50 seconds, an ALARM will be sounded indicating the operator is away or AWAKE button is not pressed.

If the operator pressing the AWAKE button at 0 seconds or even at 49 seconds, the SIGNAL_ALARM procedure wont be executed at all. because the AWAKE button should be pressed once every 50 sec.

Comments

Popular Posts