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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Read-write mutex sometimes fails on deadlock Date: Wed, 15 Nov 2017 17:05:02 -0600 Organization: JSA Research & Innovation Message-ID: References: <4502cd60-b843-4ace-99da-d716fc455635@googlegroups.com> <14ca8f28-a689-4431-9122-81a1c504569c@googlegroups.com> <1810768e-7846-43ca-9871-b2468a060c37@googlegroups.com> Injection-Date: Wed, 15 Nov 2017 23:05:03 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="25707"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: feeder.eternal-september.org comp.lang.ada:48922 Date: 2017-11-15T17:05:02-06:00 List-Id: I wrote: ... > If the new aspect Nonblocking is used, the delay is statically illegal. > (That *really* should have been the default, but it took us 20 years to > figure out the right set of rules -- too late to mandate.) "New" here means Ada 2020; it was just approved at our most recent ARG meeting and isn't yet in the draft RM. So it might not be in your favorite compiler for a while. The aspect is a big win for most things, as it makes turns the "potentially nonblocking" rules into static checks, so the portability issues [can you use Text_IO in a protected object or not?] and "tripping hazards" (Program_Error being raised unexpectedly) are eliminated. To show how this works, let's look at the Eachus example using the aspect Nonblocking: protected type Mutex with Nonblocking is entry Write(D: in Data): function Read return Data; private The_Data: Data := No_Data; end Mutex; protected body Mutex is entry Write (D: in Data) is begin The_Data := D; Some_Data := True; Print(D); -- Illegal unless Print is declared with Nonblocking = True. delay 0.1; -- Illegal. end Write; function Read return Data is return The_Data; end Read; end Mutex; So this code only will compile if it is guarenteed to work on all implementations. (The original code would have raised Program_Error on Janus/Ada for the delay, Print may or may not have worked.) Randy.