comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Eachus <rieachus@comcast.net>
Subject: Re: open a file non-blocking ?
Date: Sun, 25 Feb 2018 18:53:02 -0800 (PST)
Date: 2018-02-25T18:53:02-08:00	[thread overview]
Message-ID: <ccc5626a-784f-4fb5-81ec-033ebd9db7d2@googlegroups.com> (raw)
In-Reply-To: <6c0d9514-97e0-4c5e-9b7d-b247c2ca0ced@googlegroups.com>

On Saturday, February 24, 2018 at 2:42:30 PM UTC-5, pat...@spellingbeewinnars.org wrote:
 
> 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 program, then create a dozen tasks which can all write to the file.  (Actually such programs were written and run in the early days of Ada to figure out what minimal behavior you could expect.  Whether your implementation is nice, and sequentializes calls to Text_IO for the same file or device, may depend 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 useful?  The hard part there is defining what is useful, and that is for the requirements if you are lucky.

There is a lot of literature on non-blocking I/O which trys to minimize semaphores 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 easier, practical approach is to allow all of the queued actions in one thread to 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 the intersection isn't busy, but you also don't want the delay too short.  This is practice syncronization protocols without fence instructions are academic theory.) 

There is no way you can require an Ada library to avoid some blocking (my favorite 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 reason?

  parent reply	other threads:[~2018-02-26  2:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 19:42 open a file non-blocking ? patrick
2018-02-25  7:57 ` Dmitry A. Kazakov
2018-02-25 12:38   ` patrick
2018-02-26  2:53 ` Robert Eachus [this message]
2018-02-26  9:33   ` Dmitry A. Kazakov
2018-02-26 16:41   ` Jeffrey R. Carter
2018-02-26 16:55     ` Dmitry A. Kazakov
2018-02-27 17:14       ` patrick
2018-02-27 17:32         ` Dmitry A. Kazakov
2018-02-27 23:33           ` patrick
2018-02-28  1:13         ` Dennis Lee Bieber
replies disabled

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