1) Use the Ftok () function to obtain an ID number.
2) Shmget () function to open/point to a piece of shared memory
3) Shmat () maps this memory area to the virtual address space of the process.
4) The SHMDT () function removes the use of this memory by this process
5) Shmctl () controls the use of this shared memory
1) mmap () system calls enable shared memory between processes by mapping the same common file. After the normal file is mapped to the process address space, the process can access the file like normal memory without having to
Call Read (), write (), and so on
2) system call Munmap () unlocks a mapping relationship in the process address space, addr is the address returned when calling Mmap (), and Len is the size of the map area. When the mapping relationship is lifted, access to the original mapped address causes a segment error to occur
3 General process changes to shared content in the mapping space are not directly written back to the disk file, and are often performed after the call to Munmap (). You can implement the content of the file on disk by calling Msync () to match the contents of the shared memory area
Linux Shared memory