Inter-process communication Overview

Source: Internet
Author: User
Objective of inter-process communication:
  • Data transmission: A process needs to send its data to another process. The data volume sent is between one byte and several megabytes. D1
  • Share Data: multiple processes want to operate on shared data. If a process modifies the shared data, other processes should immediately see it. D2
  • Notification event: a process needs to send a message to another process or a group of processes to notify it of an event (for example, to notify the parent process when the process is terminated ). D3
  • Resource Sharing: multiple processes share the same resource. To achieve this, the kernel needs to provide a lock and synchronization mechanism. D4
  • Process control: some processes want to completely control the execution of another process (such as the debug process). At this time, the control process wants to block all the traps and exceptions of another process, and be able to know its status changes in time. D5

Processes coordinate their behavior through communication with the kernel and other processes. Linux supports multiple inter-process communication (IPC) mechanisms. Signals and pipelines are two of them. In addition, Linux also supports the System v ipc Mechanism (named after the first unix version ).

Brief history of inter-process communication in Linux:

The process communication methods in Linux are basically inherited from the process communication methods on the UNIX platform. The two main forces that have made significant contributions to the development of UNIXAt&tBell Labs andBSD(UC Berkeley's Berkeley Software release center) has different emphasis on inter-process communication. The former improves and expands the inter-process communication methods in the early days of UNIX to form a "System v ipc", and the communication process is limited to a single computer; the latter skips this restriction and forms a socket-based inter-process communication mechanism. In Linux, the two are inherited, as shown in:

Early UNIX Process Communication: Includes pipelines, named pipelines (FIFO), and signals (signal ).

System v ipc: Includes System V Message Queue (Message), System V semaphore (semaphore), and System V shared memory (shared memory ).

Posix ipc: Includes POSIX Message Queue (Message), POSIX semaphore (semaphore), and POSIX shared memory (shared memory ).

Introduction to several main methods for inter-process communication in Linux:
  1. Pipeline (PIPE) and famous Pipeline (Named Pipe): pipeline can be used for communications between kinship processes. Famous pipelines overcome the pipe's no-name restrictions. Therefore, in addition to the functions of pipelines, it also allows communication between unrelated processes;
  2. Signal: a signal is a complex communication method used to notify the receiving process of an event. In addition to inter-process communication, the process can also send a signal to the process itself; in addition to the early UNIX signal semantic function Sigal, Linux also supports the signal function sigaction whose semantics complies with the posix.1 standard (in fact, this function is based on BSD, BSD in order to achieve reliable signal mechanism, it can also unify external interfaces and implement the signal function again using the sigaction function );
  3. Message Queue: A chain table of messages, including the POSIX Message Queue System V message queue. A process with sufficient permissions can add messages to the queue. A process with the read permission can read messages from the queue. The message queue overcomes the disadvantages of low signal carrying information, and the pipeline can only carry unformatted byte streams and limited buffer size.
  4. Shared Memory: Allows multiple processes to access the same memory space. It is the fastest available IPC format. It is designed to reduce the running efficiency of other communication mechanisms. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and mutual exclusion between processes.
  5. Semaphore (semaphore) is mainly used for synchronization between processes and between different threads of the same process.
  6. Socket: a more general inter-process communication mechanism that can be used for inter-process communication between different machines. It was initially developed by the BSD branch of the UNIX system, but now it can be transplanted to other UNIX-like systems: both Linux and System V variants support sockets.

 

Inter-process communication Overview

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.