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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d5977aa20216d24a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-01 15:32:16 PST Path: supernews.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!e420r-sjo4.usenetserver.com!news-out.usenetserver.com!newshub2.rdc1.sfba.home.com!news.home.com!enews.sgi.com!telocity-west!TELOCITY!newsrump.sjc.telocity.net!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada References: <2OHx6.4154$NR.335287@news3.oke.nextra.no> Subject: Re: Ada Tasks vs Linux processes MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: X-Trace: MTE4IGhvQVN0aFVVZXIgckVMaUNJclktUkVBREVSUyAyMTYuMjI3LjQRLhI5IAZTdUgsIDAxIEFw!cgYyMDAxIDE1OhUxOjM1BlBEVA== X-Abuse-Info: Please forward ALL headers when reporting abuse. X-Complaints-To: abuse@telocity.net NNTP-Posting-Date: Sun, 01 Apr 2001 15:31:35 PDT Date: Sun, 1 Apr 2001 17:32:13 -0500 Xref: supernews.google.com comp.lang.ada:6322 Date: 2001-04-01T17:32:13-05:00 List-Id: The behavior is as expected. The three processes you see are the manager thread, the initial thread (i.e., the main program), and your task object. You will note that the PGIDs for all three processes are identical -- i.e., they are all members of the same shared process group -- in other words, the additional processes are so-called "lightweight" processes, sharing by and large, all of the resources of the parent process. By being distinct OS processes, the scheduling of the tasks is done by the OS instead of the Ada runtime, and one task (process) can block (e.g., waiting for IO) without blocking the others. As far as delay 0.0 is concerned, it should yield the CPU to another task, if there's one ready to run. Generally, though, I use delay Duration'Small instead of delay 0.0; "Frank" wrote in message news:2OHx6.4154$NR.335287@news3.oke.nextra.no... > Hi! > > I have made a package with a task type, I instanciate this task "as a > variable" in a test program. > It compiles ok. > > When I perform "ps -ef" while this program runs, I find three processes > named "mytest". > > I have preconceived idea :-) that I should have only two processes. Have I > done something in my code that causes this behaviour, or is this the way it > is? > > > I'm using the "select ..or ..or delay n" statement below, and I have choosen > to use "delay 0.0" to make the process continue with the business logic > below without any waiting for any rendezvous. Does delay 0.0 have a > predefined behaviour? > > > Source code supplied below > Frank > > ----------- > package PA_TEST is > > task type TTSK_TEST is > entry INIT; > entry DO_STUFF; > entry DIE; > end; > > end PA_TEST; > --------- > with TEXT_IO; > package body PA_TEST is > > task body TTSK_TEST > is > RUNNING : BOOLEAN := FALSE; > begin > > accept INIT do > TEXT_IO.PUT_LINE ("TTSK_TEST.INIT"); > RUNNING := TRUE; > end INIT; > > while RUNNING loop > select > accept DO_STUFF do > TEXT_IO.PUT_LINE ("TTSK_TEST.DO_STUFF"); > end DO_STUFF; > > or > accept DIE do > TEXT_IO.PUT_LINE("TTSK_TEST.DIE"); > RUNNING := FALSE; > end DIE; > > or > delay 0.0; -- In order to "fall through" select statement. > > end select; > > -- Business logic > -- ----"-------- > -- ----"-------- > > end loop; > > TEXT_IO.PUT_LINE("PA_TEST(Terminates)"); > end; > begin > TEXT_IO.PUT_LINE("PA_TEST(MAIN)"); > end PA_TEST; > --------- > with PA_TEST, TEXT_IO; > procedure MYTEST is > A_TASK : PA_TEST.TTSK_TEST; > WAIT : STRING(1..1); > begin > TEXT_IO.PUT_LINE("TEST"); > > A_TASK.INIT; > > TEXT_IO.PUT_LINE ("Enter a character and press ENTER, please"); > TEXT_IO.GET(WAIT); > > A_TASK.DIE; > > end MYTEST; > ------- > > >