Ada tasking on multi-core

July 17th, 2008 at 0:37 · Filed Under Ada · 12 Comments 

With a multi-core processor such as the Intel’s Core Duo, the Ada tasking can be easily demonstrated compared to single core Pentium processor. Consider the following Ada code:


with Ada.Text_IO; use Ada.Text_IO;

procedure Tasking is

   task A;
   task B;

   task body A is
   begin
      for I in 1 .. 10 loop
         Put_Line ("A");
      end loop;
   end A;

   task body B is
   begin
      for I in 1 .. 10 loop
         Put_Line ("B");
      end loop;
   end B;

begin
   Put_Line ("Begin parallel tasking...");
   Put_Line ("The end!");
end Tasking;

The above program produces the following result which easily reflects the parallel execution.


A
B
Begin parallel tasking...
A
B
The end!
A
B
A
B
A
B
A
B
A
B
A
B
A
B
A
B