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,FREEMAIL_FROM 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!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 04 Jul 2004 12:42:44 -0500 Date: Sun, 04 Jul 2004 13:42:43 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Advantages References: <2k86nbF18idtrU1@uni-berlin.de> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-m25hIg0l/LNeE9YC5+eKWcwx5eOrmZU9DjBHDFA4GBRVM9iaZO04q5PCfg2IP8jthodmfEoS8H4WMdF!MyibJIT4B7bVlmIv1Jl8yEnb/DdauLHEKO4gZIr24D0D1ZM0uR/vENb1AGL3dg== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: g2news1.google.com comp.lang.ada:2060 Date: 2004-07-04T13:42:43-04:00 List-Id: Brian May wrote: > The implication of what you say is you can't have a deadlock in Ada > across different packages, that will compile, if you use protected > objects in this manner to access variables > > Not true! As others have already pointed out. True. The wording of the standard is subtle to allow for things like asynchronous I/O operations, or protected operations in the library distributed with the compiler that 'know' about special properties of the target system. Or more important, OS calls that are potentially blocking, but where the protected object is coded so that the call is only made when it cannot block. As Randy says, the wording of the message from GNAT is not as clear as it could be: "You blockhead! This program can deadlock!" That message, of course, is not appropriate in some of the special cases where the user can tell that deadlock/Program_Error will never occur. And of course "can" not "will" in the message is correct--the compiler can't tell if the operations that will deadlock will be called--at least not at compile time. Of course, if you are designing real-time systems, this is what you should care about. The Ada compiler cannot tell you that your program will deadlock. What it can tell you, by the absense of warnings, is that your program will not have any deadlocks directly involving protected objects. There are similar rules elsewhere in the language involving tasks. > I would imagine that there are other cases where the compiler can't > warn you. No, the compiler can always warn you. Of course, if you want, you can use protected objects to implement P and V, then wrap potentially blocking actions inside the semaphores implemented that way. But that is going out of your way to get back to the situation without Ada protected objects. The intent in Ada really is that protected objects used correctly will not create deadlocks. Used correctly of course, means among other things absent bounded errors. If you want to encapsulate a potentially blocking operation in a protected object, that is what entries and entry barriers are for. You either have an entry where the barrier condition is that the potentially blocking action inside the entry will not block, or you can use a requeue statement if you determine that the action will block. Either way, the user of the abstraction can use a timed or conditional entry call, so that the caller will either not block, or not block for more than a predetermined time. -- Robert I. Eachus "The flames kindled on the Fourth of July, 1776, have spread over too much of the globe to be extinguished by the feeble engines of despotism; on the contrary, they will consume these engines and all who work them." -- Thomas Jefferson, 1821