June 2017
Intermediate to advanced
478 pages
13h 14m
English
As we saw in Chapter 12, Learning About Processes and Threads, POSIX shared memory requires mmap to access the memory segment. In this case, you set the MAP_SHARED flag and use the file descriptor from shm_open():
int shm_fd; char *shm_p; shm_fd = shm_open("/myshm", O_CREAT | O_RDWR, 0666); ftruncate(shm_fd, 65536); shm_p = mmap(NULL, 65536, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
Read now
Unlock full access