From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: Ada Protected Object Tutorial #1
Date: 1999/12/21
Date: 1999-12-21T22:57:00+00:00 [thread overview]
Message-ID: <3860075D.FFB0130A@mitre.org> (raw)
In-Reply-To: slrn85nvtm.4ps.kaz@ashi.FootPrints.net
Kaz Kylheku wrote:
> What do you do if you need a protected procedure to call out into
> some other module which then calls back?
>
> Using explicit locks, I just unlock, do the call, lock again
> thereby avoiding deadlock.
Although I think that the other issues have been explained
throughly, there are a couple of special things about using protected
objects in this situation.
First note that we are discussing protected OBJECTs. A protected object
can and will have state variables which are protected by the object.
But, since a protected object can and will run in multiple threads, per
thread locking is no help.
However, if you want to do allow potentially recursive calls on a
per thread basis, it is not that hard to do, and surprisingly the
overhead is trivial. Have the calling task pass in its
identity--Ada.Task_ID.Current_Task--and save it when locking. Of course
the easy implementation is to use a value of Null_Task_ID to mean
unlocked.
But there is a much more interesting case. Assume you have an
array of state variable sets, including Task_IDs. For example, you are
interfacing to a (local) database on behalf of many client tasks. Each
task can have a transaction in process, with the protected object
serializing interaction with the data, while the calling tasks can
interleave other (potentially blocking) actions into the transaction.
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
next prev parent reply other threads:[~1999-12-21 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 [this message]
[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 ` Tucker Taft
1999-12-18 0:00 ` Kaz Kylheku
1999-12-18 0:00 ` Robert A Duff
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 ` Robert Dewar
1999-12-27 0:00 ` Jean-Pierre Rosen
1999-12-27 0:00 ` Richard D Riehle
1999-12-27 0:00 ` Robert Dewar
1999-12-31 0:00 ` Richard D Riehle
2000-01-02 0:00 ` Tucker Taft
1999-12-17 0:00 ` Robert A Duff
1999-12-17 0:00 ` Vladimir Olensky
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