Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!athene!pcg From: pcg@cs.aber.ac.uk (Piercarlo Grandi) Newsgroups: comp.unix.internals Subject: Re: What does sync() _really_ do? Message-ID: Date: 22 Dec 90 17:15:27 GMT References: <341@cti1.UUCP> Sender: pcg@aber-cs.UUCP Organization: Coleg Prifysgol Cymru Lines: 48 Nntp-Posting-Host: odin In-reply-to: mpledger@cti1.UUCP's message of 17 Dec 90 12:15:50 GMT On 17 Dec 90 12:15:50 GMT, mpledger@cti1.UUCP (Mark Pledger) said: mpledger> steinar@ifi.uio.no (Steinar Kj{rnsr|d) writes: [ ... whether sync guarantees freeing of buffers from the cache, or not like he thinks ... ] mpledger> If memory serves me right, sync() does not CLEAR the file mpledger> buffers, but only writes all dirty buffers to disk and clears mpledger> the dirty bit flag in the file buffer header structure. Your mpledger> right that there is no guarantee the dirty buffers will be mpledger> wiped out. Yep. The *only* portable way to make sure that the buffers associated to a file's block are freed is to unmount the filesystem on which the file resides. Here is the simple minded but effective technology I use to measure peak read/write rates thru the filesystem, e.g. for the purpose of determining the optimal logical interleave. First a simple program: main() { int i; char b[32*1024]; for (i = 0; i < 64; i++) read(0,b, sizeof b); /* or write(1,b,sizeof b); */ } compiled as ./write and ./read, then I choose a spare partition, and I do mkfs /dev/rdsk/0s2 4836:1216 6 156 # or any other parameters mount /dev/dsk/0s2 /mnt time ./write >/mnt/x umount /dev/dsk/0s2 # To flush the ... mount /dev/dsk/0s2 /mnt # ... buffer cache time ./read