Do I need synchronization if I use mmap shared memory between two processes?

Viewed 48

I have Linux 2 processes.

One of them need to send "signal" to the other.

Using signal() will be more difficult, because I will need to store pid of the server program etc.

I think, I better use shared memory with shm_open + mmap, so I can use it for different communication in the future.

Question is following - lets suppose I have bool variable on the shared memory.

How I did synchronize the server and client? Will atomic work if these are two different processes? If it works - how it will works?

Here is naive code for it:

client

// bool b;
b = true;

server

// bool b;
if (b){
   refresh();
   b = false;
}
0 Answers
Related