linux--Inter-process communication summary __linux

Source: Internet
Author: User
Tags message queue semaphore
Piping

Pipelines are also called anonymous pipes (pipe), a half-duplex mode of communication in which data can flow only one-way. If you want to do duplex communication, you need to establish two pipelines. Pipelines can only be used between relational processes, such as a parent-child process or a sibling process.
The characteristics of the pipeline:
One-way communication.
Dependent on the file system. The pipeline's lifecycle is destroyed (with the process) as the process exits.
Pipelines can only be used for blood-related processes, typically for parent-child processes.
The way in which the pipe is being read and written to data flow.
Synchronous access.
Reference blog: Linux interprocess communication – Pipe naming pipe

The FIFO differs from the pipe in that it provides a path name associated with it and is present in the file system in a FIFO file format. In this way, even if there is no affinity process with the FIFO creation process, as long as the path is accessible, it is possible to communicate with each other through the FIFO (between the processes that can access the path and the FIFO creation process), so that processes that are not related through FIFO can also exchange data.
Named pipe features:
1.FIFO is present as a special device file;
2. Data can be shared between processes in different ancestral processes;
3. FIFO will continue to be saved after use.
Reference blog: Linux interprocess communication – Named pipe signal

The signal is a simulation of the interrupt mechanism at the software level, in principle, a process receives a signal and the processor receives an interrupt request can be said to be the same. The signal is asynchronous, a process does not have to do anything to wait for the signal to arrive, in fact, the process does not know exactly when the signal arrived. There are two sources of signal events: hardware sources (such as the keyboard or other hardware failures); Software sources, the most common system functions to send signals are kill, Raise,alarm and Setitimer as well as sigqueue functions, and software sources include some illegal operations. Message Queuing

Message queues are composed of a list of messages, stored in the kernel and identified by message queue identifiers.
Characteristics of Message Queuing:
1. Message Queuing is a linked list of messages that has a specific format that is stored in memory and identified by the message queue identifier.
2. Message Queuing allows one or more processes to write and read messages to it.
3. The lifecycle of message queues comes with the kernel.
4. Message Queuing enables two-way communication.
Reference blog: Linux interprocess communication – Message queue semaphore

Semaphores differ from other processes in a way that provides access control mechanisms for shared resources between processes. The equivalent of a flag in memory in which a process can determine whether certain shared resources can be accessed, and the process can modify the flag. In addition to access control, it can be used for process synchronization.
Reference blog: Linux interprocess communication-semaphore shared memory

Shared memory is the mapping of memory that is accessed by other processes, which is created by one process and accessible by multiple processes. Shared memory is the fastest way to IPC, and is designed specifically for the low efficiency of other inter-process communications. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and communication between processes.
Reference blog: Linux interprocess communication – Shared memory sockets

Sockets are also a way of interprocess communication, which differs from other methods in that it can communicate (and its main purpose) the process of communicating between different hosts.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.