comp.lang.ada
 help / color / mirror / Atom feed
* tasking in Ada and Annex D question
@ 1999-01-31  0:00 nabbasi
  1999-02-01  0:00 ` Dr. Hubert B. Keller
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: nabbasi @ 1999-01-31  0:00 UTC (permalink / raw)


Hello, 

This is gnat 3.11p, on red hat 5.2.

The README.TASKING says:

"The FSU threads provide a completely accurate implementation of
Annex D requirements, and operating with FSU threads, as far as we
know"


"On Linux the default is the fsu runtime and is selected by the means of soft
links."

Running a small program that creates 2 tasks, each going in 
an infinite loop printing (I/O) message, shows that only
one task gets the chance to run, while the other is blocked
waiting for the other one to yield explicitly? This must
be because the default threads used are FSU (user level?) and 
not the native (kernel level) threads. 

Switching to using native Linux threads intead of FSU as explained 
in the above GNAT document, then now I see that each task  will 
run for some small time, and they will flip/flop between each 
others as expected, i.e. each running in turn.

So, my questions are:

1. How could FSU be an Annex D compliant, if one thread will block
the other like this? (even though one will expect that doing
an IO message will cause a task to yield the CPU). Does Annex D
not have some sort of "quantum" based scheduling? since both
tasks are of equal priority, one will expect that one task will 
run out of its quantum, and the next ready task to become
compute, no? (I really need to study AnnexD too :)

Since the native threads seem to give the behavior one would
expect, wouldn't make more sense that this become the
default when gnat is installed on Linux, and not the FSU one.

thanks,
Nasser

 -- with FSU threads (Annex D), this
-- program prints only "i" or "j" messages
-- meaning only one task runs.
-- but with native threads, both "i" and "j"
-- print, i.e. both tasks run in turn.
-- gnat 3.11p on Linux.

with Ada.Text_Io; use Ada.Text_Io;
procedure Test_Task is
      I : Integer :=0;
      j : Integer :=0;


      task type T1;
      task type T2;

      task body T1 is
      begin
            loop
                I := I+1;
                Put_Line("i=" & Integer'Image(I));
            end loop;
      end T1;

      task body T2 is
      begin
            loop
                j := j+1;
                Put_Line("j=" & Integer'Image(j));
            end loop;
      end T2;

      Task1: T1;
      Task2 : T2;
begin
      null;
end Test_Task;




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

end of thread, other threads:[~1999-02-03  0:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-31  0:00 tasking in Ada and Annex D question nabbasi
1999-02-01  0:00 ` Dr. Hubert B. Keller
1999-02-02  0:00 ` Markus Kuhn
1999-02-02  0:00   ` robert_dewar
1999-02-02  0:00     ` Markus Kuhn
1999-02-02  0:00       ` Niklas Holsti
1999-02-03  0:00         ` Ehud Lamm
1999-02-03  0:00       ` robert_dewar
1999-02-02  0:00 ` robert_dewar
1999-02-02  0:00   ` Roger Racine
1999-02-02  0:00     ` robert_dewar
1999-02-03  0:00       ` Nick Roberts
1999-02-03  0:00         ` Frank Mueller
1999-02-03  0:00         ` Frank Mueller
1999-02-03  0:00         ` Roger Racine
1999-02-03  0:00     ` Tom Moran

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