lkml.org 
[lkml]   [2003]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: how to turn off, or to clear read cache?
On Wed, Aug 20, 2003 at 06:57:15PM +0200, M?ns Rullg?rd wrote:
> Luciano Miguel Ferreira Rocha <luciano@lsd.di.uminho.pt> writes:
> > Will it clear the cache?
>
> It will probably clear some cache to make room for cache from hda.
>
> perl -e '@f[0..100000000]=0'
>
> will do it faster.

Using fillmem will do it better :)

Jeff




/* fillmem.c usage: "fillmem <number-of-megabytes>" */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

#define MEGS 140 /* default; override on command line */
#define MEG (1024 * 1024)

int main (int argc, char *argv[])
{
void **data;
int i, r;
size_t megs = MEGS;

if ((argc >= 2) && (atoi(argv[1]) > 0))
megs = atoi(argv[1]);

data = malloc (megs * sizeof (void*));
if (!data) abort();

memset (data, 0, megs * sizeof (void*));

srand(time(NULL));

for (i = 0; i < megs; i++) {
data[i] = malloc(MEG);
memset (data[i], i, MEG);
printf("malloc/memset %03d/%03lu\n", i+1, megs);
}
for (i = megs - 1; i >= 0; i--) {
r = rand() % 200;
memset (data[i], r, MEG);
printf("memset #2 %03d/%03lu = %d\n", i+1, megs, r);
}
printf("done\n");
return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:47    [W:0.066 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site