lkml.org 
[lkml]   [1998]   [Jan]   [28]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateWed, 28 Jan 1998 08:58:57 +0100 (MET)
FromGabriele Grilli <>
SubjectContiguous files and I/O buffered
Hi!

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  )
                   (-------------------------------)

\
 
 \ /
  Last update: 2005-03-22 12:41    [W:0.688 / U:0.160 seconds]
©2003-2008 Jasper Spaans