*BSD News Article 70586


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!news.mel.connect.com.au!news.mira.net.au!inquo!in-news.erinet.com!izzy.net!aanews.merit.net!newsxfer.itd.umich.edu!newsxfer2.itd.umich.edu!netnews.worldnet.att.net!ix.netcom.com!news
From: hmccurdy@ix.netcom.com (Hugh McCurdy)
Newsgroups: comp.unix.programmer,comp.os.linux.development.apps,comp.unix.solaris,comp.unix.bsd
Subject: Re: How to flush write buffer ?
Date: Tue, 11 Jun 1996 00:57:41 GMT
Organization: Netcom
Lines: 39
Distribution: inet
Message-ID: <4pigbq$qgb@dfw-ixnews3.ix.netcom.com>
References: <4pg906$8su@sjx-ixn3.ix.netcom.com> <4phgrp$3hd@dawn.mmm.com>
NNTP-Posting-Host: syr-ny3-12.ix.netcom.com
X-NETCOM-Date: Mon Jun 10  7:58:34 PM CDT 1996
X-Newsreader: Forte Free Agent 1.0.82
Xref: euryale.cc.adfa.oz.au comp.unix.programmer:38285 comp.os.linux.development.apps:17399 comp.unix.solaris:71377 comp.unix.bsd:16799

damercer@mmm.com (Dan Mercer) wrote:


>: As for write(), write is a system call().  That means that when
>: write() returns, the data is logically written to disk.  This means
>: that the data is now available for another process to read the data.

>No,  write returns when the data is written to the system buffers.  If
>you want to make sure you don't get control back until the data is
>written to disk,  you should use the synchronous write (swrite)
>command.  This will,  of course,  greatly slow down yor app.

I must be using "logically" incorrectly or something.  To me a
"logical write" would be a write that would allow other processes to
have access to the data written.  If a process attempted to read the
data just "written" it would succeed.  Not only that, but if the data
was still in the buffer, the kernel would pass back the data from the
buffer instead of going to the hard disk.

I fully realize that a write (under normal circumstances) doesn't
necessarily do a phyical write to the hard disk.

I apologize if I wasn't clear or I have misused the term "logical
write."  But I thought the following paragraph would have made it all
clear (why would I have written the following paragraph if I thought a
normal write call must do a physical write?)

>: The O_SYNC (or in some systems O_SYNCW) argument (hopefully) forces
>: the write() call to block (not return) until the data has been
>: physically written to the disk.  I think you knew this part.







Hugh McCurdy