Guest User

Untitled

a guest
Jul 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. --
  2. --
  3. --
  4.  
  5. with Ada.Text_IO, Ada.Float_Text_IO;
  6. with Ada.Numerics.Float_Random;
  7. use Ada.Float_Text_IO, Ada.Text_IO;
  8.  
  9. procedure TwoTasking is
  10. task type TenLooper (Id : Character) is
  11. end TenLooper;
  12.  
  13. task body TenLooper is
  14. Seed : Ada.Numerics.Float_Random.Generator;
  15. begin
  16. Ada.Numerics.Float_Random.Reset (Seed, Character'Pos (Id));
  17. for I in 1 .. 10 loop
  18. declare
  19. Offset : Duration := Duration (Ada.Numerics.Float_Random.Random (Seed));
  20. begin
  21. Put_Line ("Derp: " & Id & " :: " & Integer'Image (I));
  22. Put_Line ("Delaying: " & Duration'Image (Offset));
  23. delay Offset;
  24. end;
  25. end loop;
  26. end TenLooper;
  27.  
  28. Task_1 : TenLooper ('A');
  29. Task_2 : TenLooper ('B');
  30. begin
  31. Put_Line ("..waiting for tasks to complete");
  32. end TwoTasking;
Add Comment
Please, Sign In to add comment