comp.lang.ada
 help / color / mirror / Atom feed
From: Andy Askey <askeya@res.raytheon.com>
Subject: Tasking and blocked threads
Date: 1999/09/09
Date: 1999-09-10T02:00:21+00:00	[thread overview]
Message-ID: <37D849AE.AC5EA4F1@res.raytheon.com> (raw)

This is really a Apex Ada95 specific question, but maybe someone on here
has experience in this area.

I wrote the following simple program to determine the difference between
the STANDARD Ada95 model and the THREADED Ada95 model with Apex 3.0.0b
on a Solaris 2.6 OS.  The output from the STANDARD model swaps between
tasks alternating grouped lines of output.  A bunch of "in task one"
lines are followed by a bunch of "YOMOMMA!!!!!" lines.  I was told that
this was due to time slicing in the STANDARD model. 

When I compiled with the THREADED model, I observed pretty much the same
thing.  Even though the bunches of lines of text looked a little
different with the THREADED model, it was obvious that the program was
switching between the main and task one threads.  My question: why are
both threads getting CPU time?  (I verified with "Show Imports" that I
was using the THREADED views (see text following the code.)

I added delay statements to see if one task would block the other, but
it did not.  I added a Task_Two package and execution control was passed
between all three threads. I thought I understood from previous answers
that this was not expect behavior.  Does this mean I can write an Ada95
program with several independent tasks and not worry about one task
blocking another?  (Stealing CPU cycles yes, but not really blocking.)

Thanx.
Andy

--
-- File Name: task_one.1.ada
-- 
package Task_One is
    task One;
end Task_One;
--
-- File Name: task_one.2.ada
--
with Ada.Text_Io;
package body Task_One is
    task body One is
    begin
        loop
            ada.text_io.Put_Line ("in task one");
        end loop;
    end One;
end Task_One;

--
-- File Name: mainproc.2.ada
--
with Task_One;
with Ada.Text_Io;
procedure Mainproc is
begin
    loop
        ada.text_io.Put_Line ("YOMOMMA!!!!!");
    end loop;
end Mainproc;


-------------

 testout.ss/threaded.wrk
 Explicit Imports
   lrm.ss         sun4_solaris2.ada95.thread.3.0.0.rel  all_units
   numerics.ss    sun4_solaris2.ada95.thread.3.0.0.rel  all_units
   posix.ss       sun4_solaris2.ada95.thread.3.0.0.rel  all_units
   predefined.ss  sun4_solaris2.ada95.thread.3.0.0.rel  all_units
   rational.ss    sun4_solaris2.ada95.thread.3.0.0.rel  all_units
   systems_programming.ss  sun4_solaris2.ada95.thread.3.0.0.rel 
all_units
-- 
---------------------------------------------------
|                 Andy Askey                      |
|              Software Engineer                  |
|           Raytheon Systems Company              |
|   670 Discovery Drive, Huntsville, AL  35806    |
|   Phone: (256) 971-2367  Fax: (256) 971-2306    |
|        andrew_j_askey@res.raytheon.com          |
---------------------------------------------------




             reply	other threads:[~1999-09-09  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-09  0:00 Andy Askey [this message]
1999-09-10  0:00 ` Tasking and blocked threads Robert A Duff
1999-09-10  0:00 ` Ted Dennison
1999-09-11  0:00 ` Martin Dowie
replies disabled

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