Let’s use POSIX shared memory like shmget() – a common call to coordinate inter-process communication. How is calling shmget() and coordinating communication on the shared memory segment any different than how Linux implements shared memory and synchronization between threads in a single process. Is one of them more light-weight?
Let’s use POSIX shared memory like shmget() – a common call to coordinate inter-process
Share
SHM is for IPC in multiple processes. In modern OS, each process cannot see each others’ memory space. Using common key for
shmget()to get the share memory and usingshmat()to map share memory page to local memory address inside each process. The mapped shared memory address might be different due to different memory usage and shared libraries loaded into each process space. And the SHM key, size are predefined and fixed among those process.For threads’ memory, we might not call it shared memory because threads are all in a single process memory space addressing. They can see and read/write in the same process space.