comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Ada Protected Object Tutorial #1
Date: 1999/12/18
Date: 1999-12-18T00:00:00+00:00	[thread overview]
Message-ID: <wcc902st1ee.fsf@world.std.com> (raw)
In-Reply-To: slrn85nr62.4ps.kaz@ashi.FootPrints.net

kaz@ashi.footprints.net (Kaz Kylheku) writes:

> This is practical. The condition variable wait might be done inside a
> protected kernel. It would be impractical to have, say, a UNIX kernel
> call back into application code to determine if some predicate is true.

Please explain that in more detail.  I'm not sure what you're getting at
(efficiency, security, something else...).

> >in even more unnecessary context switches, and/or bugs if the
> >programmer neglects to build the evaluation of the boolean condition
> >into a loop around the condition-variable "wait" operation.
> 
> That loop around a condition variable wait is needed to resolve
> spurious wakeups and race conditions.

But the point is that with an Ada protected object, the loop is *not*
necessary -- when the task wakes up after waiting for some barrier
condition, it already owns the lock, and the condition is necessarily
True, because no other task can sneak in and modify things.

To be more precise, I should say that when an entry body is executed,
its barrier condition is True -- this execution can be done by any
task/thread, so it doesn't necessarily involve "waking up" as I said
above.  The point is that there's a piece of code depending on (say) the
fact that "this queue is empty", and when that code runs, the system
ensures that the queue is, in fact, empty -- that piece of code need not
check.

I understand why the loop is needed with Posix threads.

> I believe that providing guarantees against this sort of occurence introduces
> overhead; that is, the cure may be worse than the ailment, particularly
> on multiprocessors.

I'm not convinced.  It seems to me that repeatedly checking the same
condition is a cost, and the extra context switches (because one thread
can't check barriers on behalf of other threads) is another cost, which
Ada avoids.  Am I missing something?

- Bob




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

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-15  0:00 Ada Protected Object Tutorial #1 James S. Rogers
1999-12-16  0:00 ` Kaz Kylheku
1999-12-16  0:00   ` James S. Rogers
1999-12-17  0:00     ` Laurent Guerby
1999-12-16  0:00   ` John English
1999-12-16  0:00     ` Ed Falis
1999-12-16  0:00       ` Usenet Poster Boy
1999-12-17  0:00     ` Karel Th�nissen
1999-12-17  0:00       ` Mike Silva
1999-12-17  0:00       ` Laurent Guerby
1999-12-18  0:00         ` Karel Th�nissen
1999-12-18  0:00           ` Laurent Guerby
1999-12-18  0:00         ` Kaz Kylheku
1999-12-18  0:00           ` Robert A Duff
1999-12-18  0:00             ` Kaz Kylheku
1999-12-18  0:00           ` Laurent Guerby
1999-12-18  0:00             ` Kaz Kylheku
1999-12-19  0:00               ` Laurent Guerby
1999-12-20  0:00                 ` Stanley R. Allen
1999-12-21  0:00               ` Robert I. Eachus
     [not found]             ` <33qr5scnbs04v391ev4541p5bv48hklg3q@4ax.com>
1999-12-20  0:00               ` Robert A Duff
1999-12-24  0:00       ` Kenneth Almquist
1999-12-17  0:00   ` Robert A Duff
1999-12-17  0:00     ` Vladimir Olensky
1999-12-17  0:00   ` Tucker Taft
1999-12-18  0:00     ` Kaz Kylheku
1999-12-18  0:00       ` Robert A Duff [this message]
1999-12-18  0:00         ` Kaz Kylheku
1999-12-19  0:00           ` swhalen
1999-12-19  0:00             ` Kaz Kylheku
1999-12-19  0:00               ` Robert Dewar
1999-12-19  0:00               ` Laurent Guerby
1999-12-20  0:00       ` Vladimir Olensky
1999-12-26  0:00         ` Ehud Lamm
1999-12-26  0:00           ` Robert Dewar
1999-12-26  0:00             ` Kaz Kylheku
1999-12-27  0:00               ` Robert Dewar
1999-12-27  0:00                 ` Richard D Riehle
1999-12-27  0:00                   ` Robert Dewar
1999-12-31  0:00                     ` Richard D Riehle
1999-12-27  0:00                 ` Jean-Pierre Rosen
1999-12-27  0:00               ` Robert Dewar
2000-01-02  0:00             ` Tucker Taft
1999-12-17  0:00 ` Robert A Duff
1999-12-18  0:00   ` Kaz Kylheku
replies disabled

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