'How can processes communicate through shared memory in linux? [closed]

If I create a shared memory with the function shm_get and mmap, and then write some data into the shared memory, how can this process notify another reader process to fetch the data in the shared memory, or what's the best way to notify another reader process to fetch the data? Futher more, how can the writer process know that the reader process is fetching data from the shared memory so that it won't update the data in the shared memory while the reader process is fetching data from the shared memory? Hope someone can solve the problem I've encountered.

I wonder if I can use the signal 、 pipe or the mutex to notify another process,but it seems a little strange, as If I want to communicate through shared memory, I have to use another communication method at the same time.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source