lkml.org 
[lkml]   [1999]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Clearing the I/O caches? (for benchmark tests)
Date
From
This is part of lmbench and seems to work somewhat.

#ifdef linux
/*
* flushdisk() - linux block cache clearing
*/

#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <linux/fs.h>

int
flushdisk(int fd)
{
int ret = ioctl(fd, BLKFLSBUF, 0);
usleep(100000);
return (ret);
}

#endif

#ifdef MAIN
int
main(int ac, char **av)
{
#ifdef linux
int fd;
int i;

for (i = 1; i < ac; ++i) {
fd = open(av[i], 0);
if (flushdisk(fd)) {
exit(1);
}
close(fd);
}
#endif
exit(0);
}
#endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

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