Inter-process Communication mode
How data is passed
1.pipe
Must be used between related processes, usually with "ls | grep abc "and so on, that's what this is," | " My guess is that two system calls are implemented, one is pipe (popen), the other is dup2, has not seen the source of bash or sh, just guess.
2.fifo
A pipeline file is generated in the file system.
3.socket
There is a UNIX domain socket that can be used as interprocess communication, but it is said that POSIX Message Queuing performs better than SYSTEMV Message Queuing, and SYSTEMV Message Queuing performance is better than UNIX domain sockets.
4.posix Message Queuing
When the program is selected for SYSTEMV Message Queuing, most of it can be replaced with POSIX Message Queuing because of his better performance.
5.SYSTEMV Message Queuing
GCC is available without a link library, and POSIX threads and message queues need to link pthread libraries and RT libraries, respectively.
6.SYSTEMV Shared Memory
Transfer data in a more flexible way.
Synchronization mode
1. Signal
2.SYSTEMV Signal Volume
Unlike the pthread semaphore, it requires a key to identify each semaphore resource between different processes.
How to communicate between threads
How you can pass the data
1. Global variables
2. Heap Memory
3. Methods of transmitting data available between processes
Synchronization mode
1.pthread Mutual Exclusion Lock
There are three types of spin lock, read/write lock, mutual exclusion lock
2.pthread condition Variable
A model with a mutex to complete a producer and consumer
3.pthread Signal Volume
A model that can be individually implemented for both producers and consumers
4. How synchronization is available between any processes
1, reference: Proficient in Linux C programming (although the name is very cottage, but think this book is very full, as a data access feeling many times, than Apue are strong. Some people on the internet have said that the book has many mistakes, at least not yet seen a place where I am sure it is wrong.
2, about a global int variable read and write is not required to lock the problem. I've seen a lot of posts discussing this question, but I haven't seen a convincing answer. Use it yourself in some relatively simple case x is not locked, such as only two threads share a variable, one thread is read only, the other thread is only written. Some say it's easy to cause core dump, but at least I haven't seen it.
3, writing is not very professional, many places have not been a special number of verification, for reference only.
Summary of communication methods between process and thread