comp.lang.ada
 help / color / mirror / Atom feed
* Strange behavior
@ 2014-09-05 19:30 Laurent
  2014-09-05 19:47 ` sbelmont700
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Laurent @ 2014-09-05 19:30 UTC (permalink / raw)


Hi

I have a strange behavior with this simple tasking example:

https://github.com/Chutulu/chapter_17.git

with Ada.Text_IO;
procedure Two_Cooperating_Tasks is
   
   task type Simple_Task (Message : Character; How_Many : Positive);
   
   task body Simple_Task is
      
   begin -- Simple_Task
      
      for Count in 1 .. How_Many loop
         Ada.Text_IO.Put ("Hello from Task " & Message);
         Ada.Text_IO.New_Line;
         delay 0.1;
      end loop;
      
   end Simple_Task;
   
   Task_A : Simple_Task (Message => 'A', How_Many => 5);
   Task_B : Simple_Task (Message => 'B', How_Many => 5);
   
begin -- Two_Cooperating_Tasks
   
   null;
   
end Two_Cooperating_Tasks;

when I run the program I get this:

/Volumes/Kingston/GPS/Chapter 17/Build/two_cooperating_tasks
Hello from Task BHello from Task A

Hello from Task AHello from Task B

Hello from Task A
Hello from Task B
Hello from Task A
Hello from Task B
Hello from Task AHello from Task B

[2014-09-05 21:17:14] process terminated successfully, elapsed time: 00.68s

If the program runs again the result is again different.

The order of the tasks executing is random and that is ok but why  is it changing and why is the New_Line zapped?

Using gnat 2014 on MacOS 10.9

Thanks

Laurent 


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-09-06  1:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05 19:30 Strange behavior Laurent
2014-09-05 19:47 ` sbelmont700
2014-09-05 20:05   ` Laurent
2014-09-06  0:53     ` Dennis Lee Bieber
2014-09-06  1:35       ` Adam Beneschan
2014-09-05 20:23 ` Jeffrey Carter
2014-09-05 20:48   ` Robert A Duff
2014-09-05 20:34 ` Robert A Duff
2014-09-05 20:40   ` Laurent
2014-09-06  1:10     ` Dennis Lee Bieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox