Home > Software engineering >  How did share data and synchronization between two processes
How did share data and synchronization between two processes

Time:01-13

I have two programs A and B share data when I'm using the Shared memory, A 12 threads are written, each write A shall inform B A and B, according to A written make different operations, data sharing and there is no problem, but how to notify B immediately when I was in A written response, because the real-time demand is higher, the way I tried to use news but the message is A bit slow,

CodePudding user response:

1. Pipe: slow speed, capacity is limited, only can a parent and child process communication

2. The FIFO: can all interprocess communications, but slow

3. The message queue, capacity is limited by the system, and attention should be paid to read for the first time, want to consider the problems of last time without reading data

4. The semaphore: cannot transfer complex message, only used for synchronous

5. The Shared memory area: can easily control capacity, fast speed, but keep synchronization, such as a process at the time of writing, another process to pay attention to the problem of reading and writing, equivalent to the threads in a thread safety, of course, the Shared memory area can also be used for communication between threads but it isn't necessary, already Shared between threads within the same process of a block of memory

CodePudding user response:

Memory sharing how synchronous?
  • Related