Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. pragma Task_Dispatching_Policy(FIFO_Within_Priorities);
  2.  
  3. with Ada.Text_IO; use Ada.Text_IO;
  4. with Ada.Real_Time; use Ada.Real_Time;
  5.  
  6. procedure PeriodicTasks is
  7.  
  8. Start : Time;
  9.  
  10. package Duration_IO is new Ada.Text_IO.Fixed_IO(Duration);
  11. package Int_IO is new Ada.Text_IO.Integer_IO(Integer);
  12.  
  13. task type T(Id: Integer; Length: Integer; Period : Integer) is
  14. pragma Priority(Id);
  15. end;
  16.  
  17. task body T is
  18. Next : Time;
  19. Done : Time;
  20. begin
  21. Next := Start;
  22. loop
  23. Next := Next + Seconds(Period);
  24. -- Some dummy function
  25. Done := Clock + Seconds(Length);
  26.  
  27. while Clock < Done loop
  28. null;
  29. end loop;
  30.  
  31. Duration_IO.Put(To_Duration(Clock - Start), 3, 3);
  32. Put(" : ");
  33. Int_IO.Put(Id, 2);
  34. Put_Line("");
  35. delay until Next;
  36. end loop;
  37. end T;
  38.  
  39. -- Example Task
  40. Task_T1 : T(1, 1, 3);
  41. Task_T2 : T(2, 1, 4);
  42. Task_T3 : T(3, 1, 6);
  43. begin
  44. Start := Clock;
  45. null;
  46. end PeriodicTasks;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement