Overview of Linux interprocess communication

Overview of Linux interprocess communication

The process communication mechanism under Linux is basically inherited from the UNIX platform. It mainly includes the following types of communication mechanisms:

  • The initial UNIX inter-process communication: including unnamed pipes, named pipes and signals
  • System V inter-process communication: including System V message queues, semaphores, and shared memory
  • Socket inter-process communication: including socket
  • POSIX inter-process communication: including POSIX message queues, semaphores and shared memory

There are mainly the following methods of communication between processes that are used more in Linux:

  1. Unnamed pipes and named pipes (fifo): Unnamed pipes can be used for communication between processes with kinship (such as parent-child process communication); in addition to having functions similar to unnamed pipes, unnamed pipes are also allowed to be used by unrelated processes
  2. Signal (signal): A signal is a simulation of the interrupt mechanism at the software level. It is a more complex communication method used to notify the process of an event. The process of receiving a signal is similar to that of the processor receiving an interrupt request processing
  3. Message queue (message queue): is a linked list of messages, including System V message queue and POSIX message queue. It overcomes the shortcomings of the limited amount of information in the first two communication methods. Processes with write permissions can send messages to messages according to certain rules. Add new messages to the queue; processes with read permissions can read messages from the message queue
  4. Shared memory (shared memory): is the most effective way of inter-process communication. This allows multiple processes to access the unified block memory space, and different processes can see the update of the data in the shared memory in the other process in time. This communication method needs to rely on some synchronization mechanism, such as mutual exclusion locks and semaphores, etc.
  5. Semaphore: Mainly used as a means of synchronization and mutual exclusion between processes and between different threads of the same process
  6. Socket (socket): It is a more extensive inter-process communication mechanism, which breaks the limitation that the processes of mutual communication are limited to a single computer. Can be used for process communication between different hosts in the network

Guess you like

Origin blog.csdn.net/Chuangke_Andy/article/details/108305663