Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Help needed on F_NOCACHE
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="srinivasanapj" data-source="post: 963910" data-attributes="member: 136149"><p>Hello Everybody,</p><p></p><p>I am Srinivasa Raghavan and new to this group.</p><p></p><p>I am facing problem with non caching the file.</p><p>the code looks like the below:</p><p></p><p>main()</p><p>{</p><p>int fd;</p><p>char buf[512] = {'\0'};</p><p>fd = fopen("Sample.bin",O_RDONLY);</p><p></p><p>fcntl(fd, F_NOCACHE, 1);</p><p>fcntl(fd, F_RDAHEAD, 1);</p><p></p><p>read(fd, buf, sizeof(buf));</p><p>close(fd);</p><p></p><p>if(buf[0] == 'x' )</p><p> print("non-cached\n");</p><p>else</p><p> printf("cached\n")</p><p>}</p><p></p><p>the problem was, the F_NOCACHE doesn't not work properly, and all the time I get the message cached only. The firware will always update the value 'x' in sample.bin.</p><p></p><p>the above code works if I put the entire stuff (open, fcntl, read and close) in an indefinite loop (take long time to come out) like the below.</p><p>main()</p><p>{</p><p>while(1)</p><p>{</p><p>open...</p><p>fcntl(.., F_NOCACHE)</p><p>read(....</p><p>close..</p><p></p><p>if(buf[0] == 'x')</p><p>break;</p><p>}</p><p></p><p>I am really stuck with this for a week time, I want to know the exact behaviour of F_NOCACHE, and any information will be highly appreciated.</p><p></p><p>Thanks in advance,</p><p>Srinivasa Raghavan</p></blockquote><p></p>
[QUOTE="srinivasanapj, post: 963910, member: 136149"] Hello Everybody, I am Srinivasa Raghavan and new to this group. I am facing problem with non caching the file. the code looks like the below: main() { int fd; char buf[512] = {'\0'}; fd = fopen("Sample.bin",O_RDONLY); fcntl(fd, F_NOCACHE, 1); fcntl(fd, F_RDAHEAD, 1); read(fd, buf, sizeof(buf)); close(fd); if(buf[0] == 'x' ) print("non-cached\n"); else printf("cached\n") } the problem was, the F_NOCACHE doesn't not work properly, and all the time I get the message cached only. The firware will always update the value 'x' in sample.bin. the above code works if I put the entire stuff (open, fcntl, read and close) in an indefinite loop (take long time to come out) like the below. main() { while(1) { open... fcntl(.., F_NOCACHE) read(.... close.. if(buf[0] == 'x') break; } I am really stuck with this for a week time, I want to know the exact behaviour of F_NOCACHE, and any information will be highly appreciated. Thanks in advance, Srinivasa Raghavan [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Help needed on F_NOCACHE
Top