comp.lang.ada
 help / color / mirror / Atom feed
From: "Samuel A. Mize" <smize@magellan.bgm.link.com>
Subject: Re: Tasking Techniques - Opinions?
Date: 1997/06/04
Date: 1997-06-04T00:00:00+00:00	[thread overview]
Message-ID: <3395A448.41C6@magellan.bgm.link.com> (raw)
In-Reply-To: 3394ecbe.215389049@news.pcisys.net


bsanden@acm.org wrote:
> On 4 Jun 1997 01:49:47 GMT, steved@pacifier.com (Steve Doiel) wrote:
...
> >In the current implementation, one module maintains a free pool
> >of packet buffers.  Access to the free pool is done using a
> >protected type.  A second module contains a protected type that
> >contains a FIFO of packet buffers (the send queue).  A third
> >module contains a "send task" that is in a short loop that
> >removes entries from the send queue, transmits the data out the
> >socket and then returns the packet buffer to the free pool.
...
> Sounds perfectly reasonable to me. Ada 83 forced many more tasks into
> the designs than were actually justified by real concurrency. The
> protected objects have made this much more palatable. Letting tasks
> communicate via shared objects is also the traditional way of doing
> these things.

Absolutely true.  However, do be aware that protected types have
significant overhead -- not as much as task rendezvous, but on the
order of ten times a procedure call.

If speed is of the essence, AND protected objects are slowing your
system too much, you may need to look at "atomic" variables (see
pragma Atomic).  For instance, a circular buffer using a reader and
a writer index, where each task needs only read access to the other's
index.  The issues to address in this case:

1 Protected objects give you easy concurrency protection.  Home-rolled
  concurrency protection is hard to get totally right.

2 If one task has to wait for the other -- for instance,if the circular
  buffer is full so the writer has to wait -- you have to determine how
  to make it wait (or do something else for a while), and how to make
  sure that the other task gets a chance to run and consume something
  from the buffer.  You get that for free with protected entries.

3 Depending on your compiler/implementation, atomic variables may
  take almost as much time as protected.  Do some timing tests.

Point 1 is the big motivator.  Getting concurrency totally right is
really really hard.

So, in general, use protected objects.

If speed is critical AND protected objects are slowing it down
too much, AND atomic variables are faster on your system, consider
a more-traditional shared-data approach using atomic objects.

Sam Mize

--
-- Samuel Mize           (817) 619-8622               "Team Ada"
-- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005




  reply	other threads:[~1997-06-04  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-04  0:00 Tasking Techniques - Opinions? Steve Doiel
1997-06-03  0:00 ` Tom Moran
1997-06-07  0:00   ` Steve Doiel
1997-06-04  0:00 ` bsanden
1997-06-04  0:00   ` Samuel A. Mize [this message]
1997-06-05  0:00     ` Jon S Anthony
1997-06-06  0:00       ` Samuel A. Mize
1997-06-07  0:00       ` Robert Dewar
1997-06-10  0:00         ` Jon S Anthony
1997-06-04  0:00 ` Jon S Anthony
1997-06-05  0:00 ` Robert A Duff
replies disabled

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