From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: open a file non-blocking ?
Date: Mon, 26 Feb 2018 10:33:47 +0100
Date: 2018-02-26T10:33:47+01:00 [thread overview]
Message-ID: <p70k9q$g8i$1@gioia.aioe.org> (raw)
In-Reply-To: ccc5626a-784f-4fb5-81ec-033ebd9db7d2@googlegroups.com
On 26/02/2018 03:53, Robert Eachus wrote:
> 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?
True, but I think the question was not about completely avoiding
blocking, rather about having I/O asynchronous. Ada has a higher-level
mechanism of timed entry call. Why not to use it for a library interface?
select
File.Queue_Write (Data, Write_Request);
or delay 0.1;
raise Device_Busy_Error;
end select;
...
select
File.Wait_Write (Write_Request);
or delay 1.0;
raise Device_Timeout_Error;
end select;
There are issues with having such interfaces. One is that protected
types are not proper tagged types. Another is that there is no multiple
entry calls. Normally you would want to wait for a combination of I/O
events + termination event + timeout.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2018-02-26 9:33 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
2018-02-26 9:33 ` Dmitry A. Kazakov [this message]
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