Reputation: 13
int main(){
int fd = open("aaaaaa.txt", O_CREAT | O_RDWR, 0666);
write(fd, "a", 1);
system("more aaaaaa.txt");
unlink("aaaaaa.txt");
close(fd);
return 0;
}
I want to ask why this data is written to the file immediately(by 'more' I can see this), instead of being directly written to the kernel page cache(not really write in file) and after a period of time,then page cache be really written to file by flusher thread .
Upvotes: 1
Views: 106
Reputation: 58927
It is written to the kernel page cache. And more
reads from the kernel page cache. The kernel page cache is shared by all processes, because it is in the kernel.
Upvotes: 1