Pipe: Pipe is a half-duplex communication mode in which data can only flow in one direction and can only be used between related processes. Process kinship usually refers to the parent-child process relationship. Namedpipe: NamedPipe is also a half-duplex communication method, but it allows communication between unrelated processes. Semophore: A semaphore is a counter that can be used to control access to a shared resource by multiple processes. It is often used as a locking mechanism to prevent other processes from accessing a shared resource while one process is accessing it. Therefore, it is mainly used as a means of synchronization between processes and between different threads within the same process. ** messagequeue (messagequeue) : ** message queues are linked lists of messages, stored in the kernel and identified by messagequeue identifiers. The message queue overcomes the disadvantages of little signal transmission, pipe carrying only plain byte stream and limited buffer size. Sinal: A complex form of communication used to inform the receiving process that an event has occurred. ** Shared memory: ** Shared memory maps a segment of memory that can be accessed by other processes. This shared memory is created by one process but can be accessed by multiple processes. Shared memory is the fastest IPC method and is specifically designed for the low efficiency of other interprocess communication methods. It is often used in conjunction with other communication mechanisms, such as signal two, to achieve synchronization and communication between processes. Socket: Socket is also an interprocess communication mechanism. Unlike other communication mechanisms, socket can be used to communicate between different processes. Two, communication between threads ** locking mechanism: ** including mutex, condition variables, read and write lock
Mutex provides an exclusive way to prevent data structures from being modified concurrently
Read/write locks allow multiple threads to read shared data at the same time, while write operations are mutually exclusive. Condition variables can block the process atomically until a particular condition is true. Conditions are tested under the protection of a mutex. Condition variables are always used with mutex.
Communication between threads is mainly for thread synchronization, so threads do not have the same communication mechanism for data exchange as in process communication.