february
february

Reputation: 13

I don't know why write system call seems not been delay

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

Answers (1)

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

Related Questions