From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3a3dffa82925efee X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Advantages Date: Fri, 2 Jul 2004 11:13:44 +0200 Message-ID: <1glr9ihu1h1iz.1o8okajpq7o67$.dlg@40tude.net> References: <2k86nbF18idtrU1@uni-berlin.de> <3p5Ec.13759$Av3.4246@nwrdny01.gnilink.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 2bc/QMgypgtGXFytC2SXDQS8qL66cKjU7zNsSNkEE9+VgbOdk= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:2043 Date: 2004-07-02T11:13:44+02:00 List-Id: On Fri, 02 Jul 2004 10:49:52 +1000, Brian May wrote: >>>>>> "Randy" == Randy Brukardt 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 > > > > 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