comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Advantages
Date: Fri, 2 Jul 2004 11:13:44 +0200
Date: 2004-07-02T11:13:44+02:00	[thread overview]
Message-ID: <1glr9ihu1h1iz.1o8okajpq7o67$.dlg@40tude.net> (raw)
In-Reply-To: sa4k6xnutan.fsf@snoopy.apana.org.au

On Fri, 02 Jul 2004 10:49:52 +1000, Brian May wrote:

>>>>>> "Randy" == Randy Brukardt <randy@rrsoftware.com> writes:
> 
>     Randy> That's correct. And it makes sense to allow I/O, as many
>     Randy> implementation don't in fact do anything blocking. But I
>     Randy> would expect that the implementation would treat things
>     Randy> that are *known* to be blocking (like a delay statement)
>     Randy> differently - there can be no legitimate reason for doing
>     Randy> that. In a ceiling locking implementation, blocking would
> 
> <hat mode="devils advocate">
> 
> You want to send a message to a hardware device. The requirements
> specify that one message should be sent to the device, followed by a
> fixed delay, then another message. During this entire period of time,
> exclusive access is required to the device, because other threads
> could otherwise interfere.
> 
> Lets also assume that sending the message is a blocking function that
> will block until either an acknowledgement or error is returned by the
> device.
> 
> What is the safest way of implementing this under Ada?
> 
> Three blocking statements, that require exclusive access to a
> resource.
> 
> You could have a protected type emulate a semaphore, but then we are
> back to using primitive operations (and related mistakes) that Ada was
> meant to avoid.
> 
> You could have these 3 statements run from a procedure within a
> protected type (along with procedures to do other things), but you not
> suppose to make calls that potentially block from a protected type.
> 
> Just curious as to the recommended way of dealing with this
> situation...

There is no recommended way, there are only ways.

Just to add to what Jeffrey Carter said. A protected action can be split
into "floating" pieces using the requeue statement.

For example, you can initiate I/O in one entry point, then requeue to
another which barrier will fire upon completion. You might argue that it is
rather a complicated way, especially if requeue with abort should be
supported and there is a large number of different states, but it works.
(It much resembles a finite state machine.)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2004-07-02  9:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-27  7:04 Advantages Andrew Carroll
2004-06-27 15:16 ` Advantages Nick Roberts
2004-06-27 21:22   ` Advantages Pascal Obry
2004-06-28  0:51   ` Advantages Robert I. Eachus
2004-06-28  1:59     ` Advantages Brian May
2004-06-29  0:24       ` Advantages Randy Brukardt
2004-06-29  3:32         ` Advantages Hyman Rosen
2004-06-29 18:41           ` Advantages Randy Brukardt
2004-07-02  0:49             ` Advantages Brian May
2004-07-02  1:31               ` Advantages Jeffrey Carter
2004-07-02  9:13               ` Dmitry A. Kazakov [this message]
2004-07-02 12:27               ` Advantages Marin David Condic
2004-07-04 17:42       ` Advantages Robert I. Eachus
2004-06-28 12:08   ` Advantages Marin David Condic
2004-06-27 18:32 ` Advantages Jim Rogers
  -- strict thread matches above, loose matches on Subject: below --
2004-06-28  9:52 Advantages Lionel.DRAGHI
     [not found] <20040628005515.0A1E74C4160@lovelace.ada-france.org>
2004-06-28  6:23 ` Advantages Andrew Carroll
2004-06-28 14:44   ` Advantages Jacob Sparre Andersen
2004-07-04 18:11   ` Advantages Robert I. Eachus
2004-06-26  6:28 Advantages Andrew Carroll
2004-06-25 19:41 Advantages Andrew Carroll
     [not found] <20040624170516.B4DFC4C4110@lovelace.ada-france.org>
2004-06-25 12:24 ` Advantages Andrew Carroll
2004-06-25 12:22   ` Advantages Peter Amey
2004-06-26 20:43   ` Advantages Marin David Condic
replies disabled

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