When executing fflush(..) and setbuf(.., NULL) to obtain
unbuffered I/O, does the system really avoid buffering? For example,
let us consider the two code fragments:
for(i=0; i<number_of_blocks; i++) /* fragment A */
{
fread(temp, block_size, 1, fin);
fwrite(temp, block_size, 1, fout); /* different output file */
}
and
for(i=0;i<number_of_blocks; i++) /* fragment B */
{
fread(temp, block_size, 1, fin);
fwrite(temp, block_size, 1, fin); /* output file is the input file */
}
Why does fragment A go faster than B? Is there any smart allocation
policy in the filesystem so as to make contiguous file allocation
available to the programmer?
(-------------------------------)
( Gabriele Grilli )
( via Fattoio 12/4 )
( Castelnuovo dei Sabbioni )
( 52020 Arezzo Italia )
( E-mail:grilli@math.unifi.it )
(-------------------------------)