process-to-process communication

1. What is a process?

A process is an operation of a program in a computer on a certain data set. It is the basic unit for system resource allocation and the basis of the operating system structure. The process entity consists of program segment, data segment and process control block (PCB) . Among them, PCB is the only sign of the existence of the process! The PCB contains some information describing the process: Process Identifier (PID) and User Identifier (UID).

2. Process = program?

A process is not equal to a program. A process is the running process of a process entity and is a dynamic concept. The program is a set of ordered instruction sets and is a static concept. Executing the same program multiple times corresponds to different processes!

3. What are the ways to realize inter-process communication?

There are six main ways to realize inter-process communication: shared memory mechanism, message passing mechanism, pipeline communication mechanism, signal, semaphore, pv and socket. (Temporarily only explain the first three, follow-up updates...)

1. Shared memory mechanism

insert image description here

A shared memory mechanism is a mechanism that allows two or more processes (unrelated or related) to access the same logical memory . It is a very efficient way of sharing and passing data. Memory shared between different processes is usually arranged as the same piece of physical memory.

2. Message passing mechanism

insert image description here

The message delivery mechanism (called message queue in Linux ), the essence of the message queue is a linked list of messages stored in memory, and the message is essentially a user-defined data structure . If a process reads a message from the message queue, the message will be deleted from the message queue. For example, if process A wants to send a message to process B, process A can return normally after putting the data in the corresponding message queue, and process B can read data from the message queue by itself when needed. The same is true for the B process to send a message to the A process.

3. Pipeline communication mechanism

insert image description here

Communication Pipeline means that the sending process sends a large amount of data into the pipeline in the form of a character stream, and the receiving process can receive data from the pipeline, and the two use the pipeline to communicate. Whether it is a SQL Server user or a PB user, as a C/S structure development environment, they all have a common method in the realization of network communication-named pipes. Due to the non-uniqueness of the current operating system, each system has its own communication protocol, which leads to difficulties in communication between different systems. Although the TCP/IP protocol has developed into the standard of the Internet, it still cannot guarantee the smooth progress of the C/S application program. As a communication method, named pipe has its unique advantages, which is mainly reflected in that it does not completely depend on a certain protocol, but is applicable to any protocol-as long as it can realize communication.
A single pipe can only achieve half-duplex communication, and two pipes can achieve full-duplex communication.

Guess you like

Origin blog.csdn.net/wddkxg/article/details/131427172