IPC interprocess communication between Linux environments (i): IPC overview

Source: Internet
Author: User
Tags posix semaphore

inter-process communication is the transmission or exchange of information between different processes, So what is there between the different processes that can be accessed by both parties? the user space of the process is independent of each other and is generally inaccessible to each other, with the only exception being the shared memory area. However, the system space is a "public place", so the kernel can obviously provide such conditions. In addition, it is a peripheral that can be accessed by both parties. In this sense, two processes can of course also exchange information through ordinary files on disk, or through "registry" or some table entries and records in other databases. Broadly speaking, this is also a means of inter-process communication, but it is generally not counted as "interprocess communication".

IPC is the abbreviation for interprocess communication, which is a way of delivering various messages between different processes running on an operating system. There are several ways to IPC: Pipelines, FIFO (also known as pipes), Message Queuing, sockets, remote Procedure Call (RPC). Pipelines can only be used between processes that have a common ancestor (referred to as a parent-child process relationship), but the FIFO (known pipe) solves the problem, and Message Queuing can be used between affinity and unrelated processes on the same host; A remote procedure call is a way for a program on a system (client host) to invoke a function on another system (server host), developed as an alternative to display network programming, since some information is usually passed between the client and the server (the parameters of the called function and the return value). RPC can be thought of as another form of messaging, while RPCs are available between clients and servers on the same host.


Figure Three ways to share information between processes

The two processes on the left share some information that resides on a file in the file system, and the two processes in the middle share some information residing in the kernel; the two processes on the right have a shared memory area that can be accessed by both parties. Although only two processes are drawn in the figure, the implementation can be any number of processes. All threads within a given process share the same global variables (that is, the concept of a shared memory area is intrinsic to the thread). However, we must focus on synchronous access to global data between each thread. Therefore, synchronization may not be treated as an IPC form, but is used in many IPC forms to control access to certain shared data.

three ways to share information from the three above can be seen in the IPC's three sustainability, that is, how long an IPC object has been in existence .


Figure the continuity of IPC objects


IPC type

Continuity of

Pipeline

Fifo

With process

With process

posix read/write lock

posix Mutex

posix condition variable

fcntl record lock

with process

with process

with process

with process

posix Message Queuing

posix known semaphore

POSIX memory-based semaphore

posix shared memory area

with kernel

with kernel

with process

Span style= "Font-family:microsoft Yahei; Font-size:14px "> with kernel

system v Message Queuing

system v Semaphore

system shared memory area

with kernel

with kernel

with kernel

TCP sockets

UDP sockets

UNIX domain sockets

With process

With process

With process

Diagram of the persistence of various types of IPC objects

There is no type of IPC with the persistence of the file system, three types of Posix IPC may have that continuity, but depend on the implementation. In fact , writing data to a file provides continuity with the file system, but this is not used as an IPC form. Most forms of IPC are not necessary to continue to exist after the system has been re-raised because the process does not exist after it has been self-raised. Furthermore, for a given form of IPC, the requirement to have the continuity of the file system may degrade its performance, while the IPC is a basic design target with high performance.

Reference:

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.