From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5f0b2f174ad085de,start X-Google-Attributes: gid103376,public From: nabbasi@earthlink.net Subject: tasking in Ada and Annex D question Date: 1999/01/31 Message-ID: <793jl9$hf@drn.newsguy.com>#1/1 X-Deja-AN: 439282901 Organization: Newsguy News Service [http://www.newsguy.com] Newsgroups: comp.lang.ada Date: 1999-01-31T00:00:00+00:00 List-Id: 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;