[comp.lang.ada] Shared Data

larry@VLSI.JPL.NASA.GOV (03/11/89)

> From: gcs81765@zach.fit.edu ( TSIGLER)
> I would like to learn about tasks sharing global data (critical sections).

I found it interesting where I found a discussion of this & how much time
was spent on it.

I first looked in Designing_Large_Real-Time_Systems_with_Ada by Nielsen &
Shumate.  They say that it's very dangerous & don't do it.  If you do, use
a task to monitor & limit its use.  They give two, short slightly differing
examples.  Total pages used: less than three, two pages being very similar,
the other page repetitions of "Don't do it" in various places. 

Next I looked in Ada:_Concurrent_Programming by Gehani.  This also
discouraged sharing & gave a couple of exclusion rules to use if you do. 
He also suggests using the SHARED pragma for scalars so that the compiler
will automatically protect the shared scalar.  (The Neilsen & Shumate just
came out, but the Gehani is dated 1984; there may be a newer edition that
discusses this more.)

System_Design_with_Ada by Buhr gives an example that uses shared data and
in the post-mortem points out the dangers of using it in half a page. 
Programming_with_Ada by Barnes says don't do it unless you consult your
local real-time specialist.  Software_Engineering_with_Ada by Booch
doesn't mention it; his Software_Components_with_Ada spends about one
page, including an example where shared access is guarded.

Several texts that are intended to be simple introductions to Ada barely
even mention tasking, much less shared data.

The most complete discussion I found was in Ada_as_a_Second_Language by
Cohen.  It used eight pages.  After appropriate warnings, he gives several
alternatives & examples, including using the SHARED pragma (which is
limited to non-composite data).  He also discusses some of the tradeoffs
involved.

More complete (and thus difficult) discussions of shared data & tasks will
probably be found in books, newsletters, & other journals that don't
specialize in Ada.  If you have access to a top-notch biblio searching
facility try that but I'm not too optimistic.  If you haven't such access,
look first at the table of contents of the last two years of IEEE Trans. 
on SW Egr and ACM Trans. on Prog. Lang. & Systems. 

                                      Larry @ VLSI.JPL.NASA.GOV