Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma Task_Dispatching_Policy(FIFO_Within_Priorities);
- with Ada.Text_IO; use Ada.Text_IO;
- with Ada.Real_Time; use Ada.Real_Time;
- procedure PeriodicTasks is
- Start : Time;
- package Duration_IO is new Ada.Text_IO.Fixed_IO(Duration);
- package Int_IO is new Ada.Text_IO.Integer_IO(Integer);
- task type T(Id: Integer; Length: Integer; Period : Integer) is
- pragma Priority(Id);
- end;
- task body T is
- Next : Time;
- Done : Time;
- begin
- Next := Start;
- loop
- Next := Next + Seconds(Period);
- -- Some dummy function
- Done := Clock + Seconds(Length);
- while Clock < Done loop
- null;
- end loop;
- Duration_IO.Put(To_Duration(Clock - Start), 3, 3);
- Put(" : ");
- Int_IO.Put(Id, 2);
- Put_Line("");
- delay until Next;
- end loop;
- end T;
- -- Example Task
- Task_T1 : T(1, 1, 3);
- Task_T2 : T(2, 1, 4);
- Task_T3 : T(3, 1, 6);
- begin
- Start := Clock;
- null;
- end PeriodicTasks;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement