Joined: Feb. 2007
||Posted: Sep. 27 2007,14:33
void process_file(char *filename)
struct stat buf;
fd = open(filename,O_RDONLY);
if (fstat(fd, &buf)<0)
/* don't readahead on nfs */
readahead(fd, (loff_t)0, (size_t)buf.st_size);
/* posix_fadvise(fd, (off_t) 0, (off_t) 0, POSIX_FADV_NORMAL|POSIX_FADV_WILLNEED);
/* be nice to other processes now */
int main(int argc, char **argv)
for (i=1; i<argc; i++)
Here's the c code of the most recent version of readahead I found (1.01-2 - ubuntu1), from Ubuntu's Gutsy repository.
It takes only 3kb when compiled with -Os and stripped, and needs only glibc and the kernel headers.
I can't right now compile it on DSL, and the ones compiled on my Aero are most certainly not DSL compatible..
Readahead is commonly used to speed up the boot, by using it in the background during a cpu-headed process (like the hwconfig with the green bar, it doesn't read anything and takes some time that could be used) to load the files needed by the next part of the boot into cache.
It works, I tested with Mplayer (reading that 8mb binary takes some seconds, but when I loaded it into cache with readahead, surprise it started instantly) and remembered to clean the cache between tests.
There's no such thing as life. Those mean little jocks invented it ;)
Windows is not a virus. A virus does something!