comp.lang.ada
 help / color / mirror / Atom feed
* Ada Tasks vs Linux processes
@ 2001-04-01 15:27 Frank
  2001-04-01 22:32 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 11+ messages in thread
From: Frank @ 2001-04-01 15:27 UTC (permalink / raw)


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;
-------






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

end of thread, other threads:[~2001-04-04 19:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-01 15:27 Ada Tasks vs Linux processes Frank
2001-04-01 22:32 ` David C. Hoos, Sr.
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

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