comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: RE: Protected Type Question.
Date: Tue, 12 Dec 2000 02:51:32 GMT
Date: 2000-12-12T02:51:32+00:00	[thread overview]
Message-ID: <9143rh$fe8$1@nnrp1.deja.com> (raw)
In-Reply-To: B6A1A9B09E52D31183ED00A0C9E0888C469931@nctswashxchg.nctswash.navy.mil

In article
<B6A1A9B09E52D31183ED00A0C9E0888C469931@nctswashxchg.nctswash.na
vy.mil>,
  comp.lang.ada@ada.eu.org wrote:
> Concerning your comment
> "and is very poor programming style".
> Since it is taken directly from the LRM,
> are you saying the LRM is written in
> poor programming style?  The fact that I
> split it into a package spec and body
> is poor programming style?  Elaborate
> please.

The example in the RM is intended to illustrate
the semantics of protected types. Since everyone
is assumed to be familiar with simple semaphores
(even though they are a deprecated form of
synchronization), this example is good for the
purpose of illustration, but that does not mean
that you should assume this code is useful in
a given situation. The examples in the RM are
all for the purposes of helping people understand
the syntax and semantics of Ada, they are not
intended as suggestions for what you should
actually write in programs.

> Concerning, "though of course no one would
> use it in the form given (it is obviously
> subject to priority inversion".  Our system
> is a message correction system that is not
> required to be real-time, other than it can't
> be too slow.  All our tasks are at the same
> priority so there isn't any inversion.  But
> for argument's sake, lets say I need this type
> of "semaphore" for protecting critical regions
> within a system that contains prioritized tasks.
> What would be your suggestion for "correcting"
> the form so that is not subject to priority
> inversion and bad programming style?

Well there are many many ways to organize task
synchronization. Most likely if you have no
real time requirements, you can use classical
rendezvous style and end up with something
that is FAR safer and easier to read and
maintain. One of the other dangers of semaphores
is that you can forget to claim or release, causing
chaos, or indeed forget both, resulting in race
conditions. By synchronizing at a higher
structural level, these dangers are avoided.

Any good Ada book will discuss the general
topic of synchronization and design. Burns and
Welling is a useful source of more detailed

> design suggestions, but there are many sources.
> I don't want insults, I want assistance.  If
> I can offer something to someone less
> experienced or less knowledgeable, I try to do
> so, and hopefully with a little more mercy.

No one is insulting anyone, I just made the
technical comment that semaphores are NOT the
preferred form of task synchronization these
days, and to use protected types to implement
semaphores is definitely an example of
abstraction inversion. These are hardly
contentious points of view :-)

> Anyone can say something is lousy, but few
> can offer a better way.  Which one are you?
> Which one do you want to be?

There is no way to answer to how you should
do things, given that you gave no hint at all
of what your problem structure is. You would
have done better using some of your energy in
writing your long answer to describe what your
problem is!

We can't offer help if we don't know what you
are trying to do.




Sent via Deja.com http://www.deja.com/
Before you buy.



  reply	other threads:[~2000-12-12  2:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-12  1:45 Protected Type Question Beard, Frank
2000-12-12  2:51 ` Robert Dewar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-01-03 20:58 protected type question shoko
2004-01-04  0:50 ` James Rogers
2004-01-04  1:04 ` Robert I. Eachus
2000-12-13 23:23 Protected Type Question Beard, Frank
2000-12-12  6:43 Beard, Frank
2000-12-12  5:49 Beard, Frank
2000-12-12 10:54 ` Robert Dewar
     [not found] <B6A1A9B09E52D31183ED00A0C9E0888C46992F@nctswashxchg.nctswash.navy.mil>
2000-12-12  3:39 ` tmoran
1996-03-20  0:00 Bill Pritchett
1996-03-20  0:00 ` Robert Dewar
replies disabled

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