Re: Re: darwin equivalent to linux readahead(2) function ?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pJEWd+dnPCbIZnCpmpPobwudydRChtGX9huk8U5RN1bQ+x8G7jNggvAAxmWHMAps/CVdZyVUhariYpBL6FqnFsUqFF0i8viNDRJPTFt3E2ec1wSOAPpkRhegoLl96+0HwvG0xF6pmybJhrrBpsp05tRNPWqKcYng4MuRtlzgiNk= On 12/18/06, Philippe Devallois <phdevallois@intego.com> wrote: fcntl(inFD,F_RDAHEAD,1); man fcntl Not so complicated ;) Actually, I'm not sure how to use it :-( I tried like that: #include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, const char* argv[]) { FILE* bigfile; int fd; struct stat sb; char buf[4]; bigfile = fopen("bigfile", "r"); if (!bigfile) return 1; fd = fileno(bigfile); if (fstat(fd, &sb)) { fclose(bigfile); return 1; } fcntl(fd, F_RDAHEAD, 1); read(fd, buf, 4); printf("bigfile size is %lld bytes\n", sb.st_size); fclose(bigfile); return 0; } But it seems it's not the way I want it to behave. Here is the (timed) result of the execution: $ time ./rdaheadtest bigfile size is 118053508 bytes real 0m0.055s user 0m0.002s sys 0m0.015s It obviously has NOT loaded the whole 113 MB file into memory because (1) I haven't heard my hard disk at all and (2) my PowerBook G4 is probably not able to load 113 MB in less than 0.055 s. I must be doing something wrong but the fcntl man is not really verbose about F_RDAHEAD and it's usage. That would be nice if you could tell me a bit more on how to actually use it. Regards. Cédric Luthi _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Hope this helps, This email sent to site_archiver@lists.apple.com
participants (1)
-
Cédric Luthi