[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

GNAT: 1) Debugging an ADA program. 2) ADA tasks do not run concurrently ?



This is a multipart MIME message.
 (1)
I have managed to debug an ADA program that had no tasks with gdb.
However, when I tried a program that contain tasks, gdb says that a SIGUSR1 
was received whenever I am trying to run the program.
Is this expected ? What should I do in order to continue the debugging session 
?
(After I debugged it with intermediate printing of key variables it seems to 
operate as expected when run from the command line. Still, I want to run it in 
gdb in order to learn how to debug it with a real debugger.)

 (2)
Although the program seems all right, my tasks seems to run in a sequential 
order, and not concurrently. Is this expected ? How to fix it ?
I have written a program (ADA code) to demonstrate the sequential nature (as 
opposed to parallel) of the tasks:
-- This program attempts to run 2 tasks "concurenntly".
-- Each task prints some uniqe character, (A and B) on the
-- screen, to demonstrate its progress (actually, these
-- tasks do nothing useful besides printing their mark
-- on the screen).
-- If the tasks are actualy run concurrently then these
-- marks should be interleaved.

with Text_Io;  use Text_Io;
procedure demo is

        -- The first task. Will print the "A" character to
        -- demonstrate its progress.

        task print_A is
                entry run;
        end print_A;

        task body print_A is
        begin
                select
                        accept run do
                                for count in 1..60 loop
                                        delay 1.0;
                                        put(" -A- ");
                                end loop;
                        end run;
                or
                        terminate;
                end select;
        end print_A;

        -- The second task. Will print the "B" character to
        -- demonstrate its progress. Otherwise, it is
        -- identical to the first.

        task print_B is
                entry run;
        end print_B;

        task body print_B is
        begin
                select
                        accept run do
                                for count in 1..60 loop
                                        delay 1.0;
                                        put(" *B* ");
                                end loop;
                        end run;
                or
                        terminate;
                end select;
        end print_B;

begin
        print_A.run;
        print_B.run;
        New_Line;

end demo;


Reply to: