*BSD News Article 28244


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!ensta!bsdtest.ensta.fr!bouyer
From: bouyer@bsdtest.ensta.fr (Manuel Bouyer)
Newsgroups: comp.os.386bsd.questions
Subject: Re: linux's I/O calls faster than NetBSD's ?
Date: 8 Mar 1994 20:24:07 GMT
Organization: Ecole Nationale Superieure de Techniques Avancees, Paris
Lines: 94
Distribution: world
Message-ID: <2limt7$16k@homea.ensta.fr>
References: <2lhv9r$pbt@homea.ensta.fr>
NNTP-Posting-Host: bsdtest.ensta.fr

In article <2lhv9r$pbt@homea.ensta.fr>, i wrote:
|>     Hi,
|> We have made some comparaisons between NetBSD 0.9 and Linux, and it appears that 
|> Linux's disk i/o calls are much faster in some case (time gives 4 seconds versus 4
|> minutes for a programs which make direct acces writing and reading on a file, on
|> exactly the same hardware).
|> It seems that Linux bufferize the file, as NetBSD always write it on the hard
|> disk.
|> 
|> Am i wrong ? Is there any way to change this ?
|> 

I should have post the program too. Here it is:

/*  PROGRAMME   STADIS7  */
/* test d'entrees/sorties ********************/
/* acces direct **********/
/* on force les acces directs physiques en adoptant
   un grand fichier  qu'on atteint aleatoirement
                         **************************/
/* ici on utilise un fichier 1001*1001 et on fait
   2*5000 operations de lecture et ecriture ******/
#define NNT 5000
#define N1 1000
#define N2 1000
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

main()
{
   register int i, k1, k2;
   int ic = 0, il;
   int *pt1 = &ic, *pt2 = &il;
   int ln, lm, lt, temps;
   FILE *fopen(), *fichp;

   temps = time(0);
   printf("DEBUT\n");

   if ( fichp = fopen("stad1", "w+b"));
      else {
            printf(" ERREUR D'OUVERTURE \n");
            exit(0);
            }

   for (i = 1; i <= NNT; i++) {
      k1 = rand() / (double)RAND_MAX * (N1+1) + 1;
      k2 = rand() / (double)RAND_MAX * (N2+1) + 1;
      ln = ((k1- 1) * (N2+1) + k2) * sizeof(int);

      if (fseek(fichp, ln, 0)) {
                                 printf(" ERREUR  FSEEK \n");
                                 exit(0);
                               }
      *pt2 = i;

      if (fwrite(pt2, sizeof(int), 1, fichp) - 1) {
                                  printf(" ERREUR D'ECRITURE \n");
                                  exit(0);
                                  }

      if (fseek(fichp, ln, 0))  {
                                 printf(" ERREUR  FSEEK \n");
                                 exit(0);
                               }
      if (feof(fichp)) {
                        printf(" FIN DE FICHIER DETECTEE .. NE PEUT LIRE\n");
                        exit(0);
                        }

      if (fread(pt1, sizeof(int), 1, fichp) - 1) {
                                 printf(" ERREUR DE LECTURE \n");
                                 exit(0);
                                 }
   }
   printf("%10ld\n", *pt1);

   if (fclose(fichp)) {
                       printf(" ERREUR DE FERMETURE \n");
                       exit(0);
                      }

   printf("C'EST TERMINE............\n");

  printf(" TEMPS ECOULE EN SECONDES: %ld \n", time(0) - temps);

}


--
Manuel Bouyer, Ecole Nationale Superieure de Techniques Avancees, Paris
email: bouyer@ensta.fr
--