From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Ada Tasks vs Linux processes
Date: Sun, 1 Apr 2001 17:32:13 -0500
Date: 2001-04-01T17:32:13-05:00 [thread overview]
Message-ID: <b%Nx6.4387$mA.1548299@newsrump.sjc.telocity.net> (raw)
In-Reply-To: 2OHx6.4154$NR.335287@news3.oke.nextra.no
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" <franjoe@frisurf.no> 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;
> -------
>
>
>
next prev parent reply other threads:[~2001-04-01 22:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-04-01 15:27 Ada Tasks vs Linux processes Frank
2001-04-01 22:32 ` David C. Hoos, Sr. [this message]
2001-04-02 17:30 ` tmoran
2001-04-02 18:00 ` Robert A Duff
2001-04-02 18:20 ` Ehud Lamm
2001-04-02 22:17 ` Jeffrey Carter
2001-04-04 16:36 ` tmoran
2001-04-04 17:18 ` Gary Scott
2001-04-04 19:18 ` tmoran
2001-04-02 19:57 ` Frank
2001-04-03 11:28 ` Matthias Kretschmer
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox