Private Writes Vanish
Process A and process B both map the first page of the same file.
/* process A */
int fd = open("data", O_RDWR);
char *p = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
close(fd);
p[0] = 'X';
/* process B */
int fd = open("data", O_RDWR);
char *q = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
q[1] = 'Y';
msync(q, 4096, MS_SYNC);
After both run, what is on disk at offsets 0 and 1?
Sign in to answer questions and track your progress
Sign In