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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,68494635acddb77e X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!d45g2000hsc.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: File output and buffering Date: Sat, 23 Aug 2008 15:00:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4e375604-970f-41ab-9691-dd9abd3e75b9@d45g2000hsc.googlegroups.com> References: <1jt8nguvzf1hw$.189glcey6hmht.dlg@40tude.net> <84805bfc-26f4-4507-9024-9e3558c9cb32@m73g2000hsh.googlegroups.com> <104g44sstk0to$.1lektfatijska$.dlg@40tude.net> <4db7770e-a53b-436b-bc87-b487fdec430b@e39g2000hsf.googlegroups.com> <1n1jam128sz9v$.3jl0ijmar2gb.dlg@40tude.net> <6242f0d9-4874-427d-bf45-c5f5c36c75f2@k7g2000hsd.googlegroups.com> NNTP-Posting-Host: 85.3.213.83 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1219528814 21681 127.0.0.1 (23 Aug 2008 22:00:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 23 Aug 2008 22:00:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d45g2000hsc.googlegroups.com; posting-host=85.3.213.83; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7513 Date: 2008-08-23T15:00:14-07:00 List-Id: On 23 Sie, 22:34, Dennis Lee Bieber wrote: > > Then we have a different notion of "synchronously". > > When I write something to the file, the operation is synchronous when > > the program *waits* for the transfer to complete. > > =A0 =A0 =A0 =A0 If I may slip in, since this thread has wandered into com= parisons > that even I can't follow... > > =A0 =A0 =A0 =A0 Define "complete" So that the program can immediately terminate and still have the data reliably stored. Think about log files of various kinds (including database write ahead logs) and the importance of having something confirmed. > =A0 =A0 =A0 =A0 Most I/O systems I've encountered are buffered by the OS.= .. Of course - and not only that. There are buffers everywhere, even in hard drives. The semantics of output operation from the program point of view can be, however, described in terms of reasonably understood best-effort or pushing data as far as it makes sense. For example, if the hard drive can guarantee reliable storage at the level of its own buffers, then it can confirm reception of the data without actually storing them on plates. From the point of view of the program, the I/O operation can be considered as finished, because from that point nothing can mess things up. > As far > as an application is concerned, an I/O "write" operation is "complete" > when the OS accepts the packet for buffering. Exactly - provided that the packet was *copied* to OS buffers as opposed to just passing pointer to programs data. In practical terms: Ada.Text_IO.Put_Line (File, "Hello"); Ada.Text_IO.Flush (File); -- here we can crash without losing data I consider the output operation above (triggered or ensured by Flush) to be *synchronous with respect to the program*. When the Flush operation returns the control back to the program, the data is already stored in the external file (as AARM calls it), whatever that means, even if the "external file" includes several layers of buffers. From the program's perspective, it is "done". If you want to contrast the above with asynchronous version, the output operation can be initiated by the program but the program would be allowed to continue without any guarantee related to the amount of data being stored (and with some provisions to get the status later on). Short coverage of what all this means in the context of databases: http://www.orafaq.com/node/93 It is really well written. I hope that you get what I'm trying to say here. Well, at least I'm sure that I'm not inventing anything new. -- Maciej Sobczak * www.msobczak.com * www.inspirel.com Database Access Library for Ada: www.inspirel.com/soci-ada