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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.143.82 with SMTP id r79mr7348537iod.120.1519613582906; Sun, 25 Feb 2018 18:53:02 -0800 (PST) X-Received: by 10.157.68.9 with SMTP id u9mr414638ote.5.1519613582817; Sun, 25 Feb 2018 18:53:02 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!o66no1699615ita.0!news-out.google.com!10ni2416ite.0!nntp.google.com!w142no1705480ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 25 Feb 2018 18:53:02 -0800 (PST) In-Reply-To: <6c0d9514-97e0-4c5e-9b7d-b247c2ca0ced@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:7466:f44c:da21:40b1; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:7466:f44c:da21:40b1 References: <6c0d9514-97e0-4c5e-9b7d-b247c2ca0ced@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: open a file non-blocking ? From: Robert Eachus Injection-Date: Mon, 26 Feb 2018 02:53:02 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3108 X-Received-Body-CRC: 1796787466 Xref: reader02.eternal-september.org comp.lang.ada:50645 Date: 2018-02-25T18:53:02-08:00 List-Id: On Saturday, February 24, 2018 at 2:42:30 PM UTC-5, pat...@spellingbeewinna= rs.org wrote: =20 > There does not seem to be an option to open a file non-blocking. Is there= a way? If you really want to play with pathologies, open a file in your main progr= am, then create a dozen tasks which can all write to the file. (Actually s= uch programs were written and run in the early days of Ada to figure out wh= at minimal behavior you could expect. Whether your implementation is nice,= and sequentializes calls to Text_IO for the same file or device, may depen= d on the device... If you want to, for example, log errors and have them appear one per line, = it is not too hard to do. If you want IO without blocking but which is use= ful? The hard part there is defining what is useful, and that is for the r= equirements if you are lucky. There is a lot of literature on non-blocking I/O which trys to minimize sem= aphores and mutexes. That is more about algorithms that avoid or minimize = fence instructions (SFENCE, MFENCE, and WFENCE) when you are trying to get = task synchronization above a few hundred million times a second. The easie= r, practical approach is to allow all of the queued actions in one thread t= o occur before it gives up the lock. There may be real-time limits so that= only 30 or whatever number can go through. (Think of a traffic light used= to merge lanes of traffic. You don't want the delay too long, for when th= e intersection isn't busy, but you also don't want the delay too short. Th= is is practice syncronization protocols without fence instructions are acad= emic theory.)=20 There is no way you can require an Ada library to avoid some blocking (my f= avorite example is a printer that runs out of paper). Do you want that to = be a blocking event? What about spinning down a disk drive for whatever re= ason?