Inter-process communication method, device, system, medium and terminal

By writing and transmitting the addresses of communication between processes in the shared memory area, the problems of large overhead and poor synchronization of inter-process communication resource in the prior art are solved, and efficient message transmission and synchronization are achieved.

CN110399229BActive Publication Date: 2024-12-27TSINGHUA UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201810380885.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-04-25
Publication Date
2024-12-27
Estimated Expiration
2038-04-25

AI Technical Summary

Technical Problem

The existing inter-process communication methods have problems such as inability to synchronize the message content, frequent access to the operating system kernel, resulting in high resource overhead, and affecting latency and throughput.

Method used

By establishing a socket connection between the publishing and the subscriber process, writing the message content to the shared memory area, and transmitting the shared memory area address through the socket, reducing the number of kernel copies and synchronizing the message content.

Benefits of technology

It reduces operating system resource overhead, improves the throughput and synchronization of message transmission, and adapts to complex communication scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110399229B_ABST
    Figure CN110399229B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method, device, medium, system and terminal for communication between processes, wherein the method comprises: receiving a socket connection request sent by a subscriber process, establishing a socket connection with the subscriber process according to the socket connection request; writing the target message content to be published into a shared memory area, and obtaining the address of the target message content in the shared memory area; transmitting the address to the subscriber process through the socket, so that the subscriber process reads the target message content from the shared memory area according to the address, which can reduce the resource overhead of the operating system, reduce the transmission delay of the message content, improve the throughput of the message content transmission, and realize the synchronization of the message content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an inter-process communication method, an inter-process communication device, an inter-process communication system, a computer storage medium and a terminal. Background Art

[0002] Process is the basic unit for resource allocation and scheduling in the operating system. Each process has its own independent resources. In order for processes to access each other's resources and coordinate work, they need to communicate with each other. Interprocess communication (IPC) refers to the transmission or exchange of messages between different processes. In practice, it is found that the current interprocess communication scheme has problems such as the inability to synchronize message content between processes, the need to frequently access the operating system kernel and occupy a large amount of processing resources, and the impact on communication delay and throughput. Therefore, how to better implement interprocess communication has become an important research topic. Summary of the invention

[0003] The technical problem to be solved by the embodiments of the present invention is to provide a communication method, device, medium, system and terminal between processes, which can reduce the resource overhead of the operating system, reduce the transmission delay of the message content, improve the throughput of the message content transmission, and achieve synchronization of the message content.

[0004] On the one hand, an embodiment of the present invention provides a method for communication between processes, the method comprising:

[0005] Receive a socket connection request sent by a subscriber process, wherein the socket connection request carries an identifier of a publisher process and an identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or from a central process;

[0006] Establishing a socket connection with the subscriber process according to the socket connection request;

[0007] Write the target message content to be published into the shared memory area, and obtain the address of the target message content in the shared memory area;

[0008] The address is transmitted to the subscriber process through the socket, so that the subscriber process reads the target message content from the shared memory area according to the address.

[0009] On the one hand, an embodiment of the present invention provides a method for communication between processes, the method comprising:

[0010] Sending a socket connection request to the publisher process to establish a socket connection with the publisher process; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained from the broadcast message sent by the publisher process, or obtained from the central process;

[0011] Receive the address sent by the publishing end process through the socket, where the address is the address of the target message content in the shared memory area obtained after the publishing end process writes the target message content to be published into the shared memory area;

[0012] The target message content is read from the shared memory according to the address.

[0013] On the one hand, an embodiment of the present invention provides an inter-process communication device, the device comprising:

[0014] A connection unit is used to receive a socket connection request sent by a subscriber process, and establish a socket connection with the subscriber process according to the socket connection request; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or obtained from a central process.

[0015] The writing unit is used to write the target message content to be published into the shared memory area, and obtain the address of the target message content in the shared memory area.

[0016] A transmission unit is used to transmit the address to the subscriber process through the socket, so that the subscriber process reads the target message content from the shared memory area according to the address.

[0017] On the one hand, an embodiment of the present invention provides an inter-process communication device, the device comprising:

[0018] A connection unit is used to send a socket connection request to a publishing process to establish a socket connection with the publishing process; the socket connection request carries an identifier of the publishing process and an identifier of the subscriber process; the identifier of the publishing process is obtained from a broadcast message sent by the publishing process, or obtained from a central process.

[0019] The receiving unit is used to receive the address sent by the publishing end process through the socket, wherein the address is the address of the target message content in the shared memory area obtained after the publishing end process writes the target message content to be published into the shared memory area.

[0020] A reading unit is used to read the target message content from the shared memory according to the address.

[0021] On the one hand, an embodiment of the present invention provides an inter-process communication system, the system comprising a publishing end process, a subscribing end process and a shared memory area:

[0022] The publisher process is used to receive the socket connection request sent by the subscriber process, and the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from the broadcast message sent by the publisher process, or obtained from the central process; a socket connection is established with the subscriber process according to the socket connection request; the target message content to be published is written into the shared memory area, and the address of the target message content in the shared memory area is obtained; and the address is transmitted to the subscriber process through the socket.

[0023] The subscriber process is used to send a socket connection request to the publisher process to establish a socket connection with the publisher process; receive an address sent by the publisher process through the socket, and read the target message content from the shared memory according to the address.

[0024] The shared memory area is used to store the target message content written by the publishing end process.

[0025] On the one hand, an embodiment of the present invention provides a computer storage medium, characterized in that the computer storage medium stores one or more first instructions, and the one or more first instructions are suitable for being loaded by a processor and executing the following method:

[0026] Receive a socket connection request sent by a subscriber process, wherein the socket connection request carries an identifier of a publisher process and an identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or from a central process;

[0027] Establishing a socket connection with the subscriber process according to the socket connection request;

[0028] Write the target message content to be published into the shared memory area, and obtain the address of the target message content in the shared memory area;

[0029] The address is transmitted to the subscriber process through the socket, so that the at least one subscriber process reads the target message content from the shared memory area according to the address.

[0030] Alternatively, the computer storage medium stores one or more second instructions, and the one or more second instructions are suitable for being loaded by the processor and executing the following method:

[0031] Sending a socket connection request to the publisher process to establish a socket connection with the publisher process; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from the broadcast message sent by the publisher process, or obtained from the central process;

[0032] Receive the address sent by the publishing end process through the socket, where the address is the address of the target message content in the shared memory area obtained after the publishing end process writes the target message content to be published into the shared memory area;

[0033] The target message content is read from the shared memory according to the address.

[0034] In one aspect, an embodiment of the present invention provides a terminal, comprising: a processor, adapted to implement one or more instructions; and a computer storage medium, wherein the computer storage medium stores one or more first instructions, wherein the one or more first instructions are adapted to be loaded by the processor and execute the following method:

[0035] Receive a socket connection request sent by a subscriber process, wherein the socket connection request carries an identifier of a publisher process and an identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or from a central process;

[0036] Establishing a socket connection with the subscriber process according to the socket connection request;

[0037] Write the target message content to be published into the shared memory area, and obtain the address of the target message content in the shared memory area;

[0038] The address is transmitted to the subscriber process through the socket, so that the at least one subscriber process reads the target message content from the shared memory area according to the address.

[0039] Alternatively, the computer storage medium stores one or more second instructions, and the one or more second instructions are suitable for being loaded by the processor and executing the following method:

[0040] Sending a socket connection request to the publisher process to establish a socket connection with the publisher process; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from the broadcast message sent by the publisher process, or obtained from the central process;

[0041] Receive the address sent by the publishing end process through the socket, where the address is the address of the target message content in the shared memory area obtained after the publishing end process writes the target message content to be published into the shared memory area;

[0042] The target message content is read from the shared memory according to the address.

[0043] In the embodiment of the present invention, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. And the address of the message content in the shared memory area is sent to the subscribing end process in real time through the socket, so that the subscribing end process can obtain the message content written by the publishing end process in real time, and the message content synchronization between the subscribing end process and the publishing end process can be realized. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0045] Figure 1 It is a schematic diagram of the architecture of an inter-process communication system provided by an embodiment of the present invention;

[0046] Figure 2 It is a flowchart of an inter-process communication method provided by an embodiment of the present invention;

[0047] Figure 3 It is a flowchart of another inter-process communication method provided by an embodiment of the present invention;

[0048] Figure 4 It is a flowchart of another inter-process communication method provided by an embodiment of the present invention;

[0049] Figure 5 It is a flowchart of another inter-process communication method provided by an embodiment of the present invention;

[0050] Figure 6 is a schematic diagram of a shared memory area provided by an embodiment of the present invention;

[0051] Figure 7 It is a flowchart of another inter-process communication method provided by an embodiment of the present invention;

[0052] Figure 8 It is a schematic diagram of the structure of an inter-process communication device provided by an embodiment of the present invention;

[0053] Fig. 9 is a schematic diagram of the structure of another inter-process communication device provided by an embodiment of the present invention;

[0054] Fig.10 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0056] A process is a running activity of a program in a computer; in other words, a process is the entity of a program, an instance of a running program; for example, if an instant messaging application is running in a terminal, then the process of the instant messaging application that has been started and is running can be viewed in the terminal. A terminal can run multiple applications at the same time, so there will be multiple application processes in the terminal at the same time; in some scenarios, there is a need for communication between multiple processes in the terminal, for example, if a camera process and a face recognition process are running in the terminal at the same time, then in the human body recognition scenario, communication is required between the camera process and the face recognition process, and the camera process provides the captured face image, and the face recognition process obtains the face image for face recognition processing. In the embodiment of the present invention, the publishing end process refers to a process that provides services by publishing messages, and the subscribing end process refers to a process that subscribes to message services; in the above face recognition scenario, the camera process is used as the publishing end process, and the face recognition process is used as the subscribing end process. At present, the inter-process communication methods mainly include: inter-process communication method based on sockets, inter-process communication method based on message queues and inter-process communication method based on shared memory areas. The following will briefly introduce several methods:

[0057] (1) Inter-process communication method based on sockets: The main advantage of this method is that it can achieve basic compatibility with the network socket interface. The two communicating processes do not need to care whether the other process is in the same computer or in the same network environment, and can provide a unified software module communication interface. However, there are also the following shortcomings: First, socket communication is one-to-one. To achieve M-to-N communication, M×N pairs of sockets are required, which occupies a large amount of system resources; second, the inter-process communication method based on sockets requires the publishing process to copy the message content into the buffer, and then copy the message content from the buffer into the kernel. The subscribing process needs to copy the message content from the kernel into the buffer, and then copy the message content out of the buffer. Frequent copying of message content not only occupies processor resources, but also seriously affects message transmission delay and message transmission throughput.

[0058] (2) Inter-process communication method based on message queue: Compared with the inter-process communication method based on socket, the inter-process communication method based on message queue can realize character stream communication and maintain message boundaries. However, in the process of realizing inter-process communication, the message content still needs to be frequently copied between the buffer-kernel-buffer. In addition, although the message queue supports many-to-many inter-process communication, multiple subscriber processes actually need to compete for the message content. That is, after a subscriber process reads a message content, the message content cannot be read by other subscriber processes. Therefore, it is not suitable for the message content publishing mode.

[0059] (3) Inter-process communication method based on shared memory area: By providing a shared memory area accessible to multiple processes, many-to-many inter-process communication can be achieved. The number of times the message content is copied can be reduced, and the transmission delay of the message content can be reduced. However, the inter-process communication method based on shared memory area also has shortcomings, mainly in the lack of synchronization mechanism, that is, the publishing end process lacks an effective method to notify the subscribing end process that new message content has been written to the shared memory area.

[0060] In summary, both the socket-based inter-process communication method and the message queue-based inter-process communication method have good synchronization mechanisms, but the message content needs to be frequently copied in the buffer-kernel-buffer, which increases the resource overhead of the operating system and causes a large transmission delay of the message content, reducing the throughput of the message content transmission; and in the inter-process communication method based on the shared memory area, although the message content does not need to be copied into the kernel and buffer, it lacks a synchronization mechanism. It can be seen that the various inter-process communication methods of the above single mode either have problems such as large resource overhead of the operating system, high transmission delay of the message content, low transmission throughput of the message content, or lack of synchronization mechanism. The main reason for these problems is due to changes in application scenarios. Early inter-process communication considered more one-to-one communication requirements (i.e., one publishing end process to one subscribing end process), and the message content of the process interaction was simple and single; therefore, the above single mode inter-process communication method is more suitable for simple communication scenarios with low complexity and low throughput in the early stage. However, with the increasing complexity of software systems, more and more complex communication requirements have arisen when software modules are isolated in the form of processes, such as requiring more and more complex message content to be interacted in a one-to-one communication scenario, or requiring many-to-many communication, etc. For example, in a robot system scenario, there are multiple high-definition cameras, and the image data captured by each high-definition camera can be obtained by the processes corresponding to multiple software modules such as face recognition, body recognition, gesture recognition, posture recognition, and object recognition; each high-definition camera is a publishing end process, and the process corresponding to each software module is a subscribing end process; in this robot system scenario, high-throughput many-to-many communication is required. The various inter-process communication schemes mentioned above are no longer suitable for such complex communication scenarios, and cannot achieve high-throughput communication scenarios.

[0061] Based on this, an embodiment of the present invention provides an inter-process communication solution, specifically: when the publishing end process needs to publish message content, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention is flexibly compatible with a variety of mainstream inter-process communication technologies, and combines the advantages of shared memory and sockets to realize inter-process communication. First, a shared memory area is used to store the message content. In this way, the message content only needs to be copied in the shared memory area, and does not need to be copied in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content; secondly, a socket connection is established between the publishing process and the subscribing process. After the publishing process publishes the message content, the address of the message content in the shared memory area can be shared with the subscribing process in real time through the socket. In this way, the subscribing process can obtain the message content written by the publishing process in real time, thereby realizing the synchronization of the message content between the subscribing process and the publishing process. In summary, the embodiment of the present invention solves the problems existing in the single-mode inter-process communication method, effectively reduces the resource overhead of the operating system, improves the transmission delay and transmission throughput of the message content, solves the message synchronization problem between processes, and is more suitable for communication scenarios with high complexity and high throughput.

[0062] In the embodiment of the present invention, the publishing end process refers to the process that publishes the message content, and the subscribing end process refers to the process that reads the message content. The publishing end process and the subscribing end process are relative, that is, in some scenarios, the same process can be used as a publishing end process to publish the message content, and can also be used as a subscribing end process to read the message content published by other processes; for example, in the scenario of face recognition for terminal startup, first, the camera process publishes image data (i.e., message content), the face recognition process reads the image data published by the camera process, and performs face recognition based on the image data to obtain the recognition result; in this case, the camera process is used as the publishing end process, and the face recognition process is used as the subscribing end process; secondly, the face recognition process publishes the recognition result, and the startup process reads the recognition result and controls the terminal to start up. In this case, the face recognition process is used as the publishing end process, and the startup process is used as the subscribing end process. It can be seen that in the above scenario, the face recognition process is used as both a subscribing end process and a publishing end process. It should be noted that in the embodiment of the present invention, the same subscribing end process can subscribe to the message content published by multiple publishing end processes, and the message content published by the same publishing end process can be subscribed by multiple subscribers.

[0063] Based on the above description, an embodiment of the present invention provides an inter-process communication system, which can be set in an operating system of a terminal, where the terminal at least includes a memory, a display or a processor. Figure 1 The communication system includes at least one publishing process and at least one subscribing process. Figure 1 Take two as an example, the publisher process includes publisher process P1 and publisher process P2, and the subscriber process includes subscriber process S1 and subscriber process S2. After each process is started in the operating system, the started publisher process and subscriber process can be viewed by calling the task manager of the terminal.

[0064] The communication system further comprises a shared memory area 10. The shared memory area refers to a large-capacity memory that can be accessed by different central processing units in a multi-processor computer system. Figure 1 The storage space of the shared memory area 10 shown can be allocated from the memory of the terminal, and the capacity of the shared memory area (i.e., the storage size of the storage space) can be automatically set by the terminal according to the throughput, or can be manually set by the user. The shared memory area 10 is equivalent to the intermediate medium for the publisher process and the subscriber process to exchange information; specifically: the publisher process P1 and / or the publisher process P2 can write the message content to be published into the shared memory area 10, and the subscriber process S1 and / or the subscriber process S2 can read the message content written by the publisher process from the shared memory area 10.

[0065] In one embodiment, Figure 1 The communication system shown can be applied to a one-to-one communication scenario; the one-to-one communication scenario refers to a scenario in which communication is performed between a publishing process and a subscribing process. In the one-to-one inter-process communication scenario, the communication between the publishing process P1 and the subscribing process S1 is taken as an example. The working principle of the communication system generally includes: the process of publishing the message content and the process of reading the message content. Figure 2 As shown, the publishing process of the message content includes:

[0066] S11. The publishing end process is initialized.

[0067] The initialization of the publishing process P1 includes: the publishing process P1 processes the socket connection request of the subscriber process S1 and attempts to open the shared memory area. In order not to affect the message content published by the publishing process P1, the socket connection request of the subscriber process S1 can be processed by an independent thread of the publishing process P1, that is, the independent thread establishes a socket connection with the subscriber process S1 according to the socket connection request, and performs an open operation on the shared memory area. If the shared memory area is successfully opened, it waits for the message content to be written. If the opening fails, a new shared memory area is created.

[0068] S12. The publishing end process publishes the target message content.

[0069] The publishing process P1 publishes the target message content, including: allocating space for the target message content in the shared memory area. If the allocation is successful, the message content is written in the shared memory area, and the address of the message content is obtained, and the address of the message content in the shared memory is sent to the subscriber process S1 through the socket.

[0070] S13. The publishing process exits.

[0071] After writing the target message content, the publishing process P1 can exit the shared memory area. Exiting the shared memory area includes: detecting whether the shared memory area needs to be cleared. Specifically, the publishing process P1 detects whether there are other processes (including the publishing process or the subscriber process) that are currently opened and have not exited the shared memory area; if so, it indicates that a process is using the shared memory area, and all message contents stored in the shared memory area will not be cleared; if not, it indicates that no process is currently using the shared memory area, and all message contents stored in the shared memory area can be cleared to release the storage space of the shared memory area.

[0072] like Figure 3 As shown, the process of reading the message content includes:

[0073] S21, the subscriber process is initialized.

[0074] The initialization of the subscriber process S1 includes: the subscriber process S1 sends a socket connection request to the publisher process P1 to establish a socket connection with the publisher process P1. The socket connection establishment operation can be implemented by the central process of the communication system, or by the connection rules of the local socket path and the network socket port, which is not limited in the present invention.

[0075] For example, if the subscriber process in the communication system is started before the publisher process, the publisher process can send a broadcast message to each subscriber process through a local socket path. The broadcast message includes the identifier of the publisher process P1 and the service description information of the publisher process P1. The service description information is used to describe what kind of message content the publisher process P1 can provide. The subscriber process S1 determines whether to subscribe to the message content published by the publisher process P1 based on the broadcast message published by the publisher process. If the subscription is determined, a socket connection request is sent to the publisher process P1. The socket connection request carries the identifier of the publisher process P1 and the identifier of the subscriber process S1. The publisher process P1 establishes a socket connection with the subscriber process S1 based on the socket connection request.

[0076] S22. The subscriber process reads the target message content.

[0077] After the socket connection is established, the subscriber process S1 can receive the address sent by the publisher process through the socket, open the shared memory area, and read the target message content in the shared memory area according to the address. Further, the target message content can be used as a parameter to call the callback function registered in the subscriber process S1, or the address of the target message content can be used as a parameter to call the callback function, so that the subscriber process S1 can implement the corresponding function according to the callback function.

[0078] S23. The subscriber process exits.

[0079] After reading the target message content, you can exit the shared memory area and detect whether the shared memory area needs to be cleared. Specifically, the subscriber process S1 detects whether there are other processes (including the publisher process or the subscriber process) that have been opened and have not exited the shared memory area. If so, it indicates that a process is currently using the shared memory area, and all message contents stored in the shared memory area will not be cleared; if not, it indicates that no process is currently using the shared memory area, and all message contents stored in the shared memory area can be cleared to release the storage space of the shared memory area.

[0080] In the above one-to-one inter-process communication scenario, the publishing process only needs to write the message content to the shared memory area, and does not need to copy the message content to the kernel and buffer of the operating system, which reduces the number of times the message content is copied during the publishing process, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. The address of the message content in the shared memory area is sent to the subscriber process in real time through the socket, so that the subscriber process can obtain the message content written by the publisher process in real time, and the message content synchronization between the subscriber process and the publisher process can be achieved.

[0081] In another embodiment, Figure 1 The communication system shown can be applied to many-to-many communication scenarios; the many-to-many communication scenarios refer to scenarios in which multiple publisher processes communicate with multiple subscriber processes. In the many-to-many inter-process communication scenario, the publisher processes P1 and P2 and the subscriber processes S1 and S2 are taken as examples below. The working principle of the communication system also includes: the process of publishing the message content and the process of reading the message content.

[0082] During the message publishing process, the publisher process P1 establishes socket connections with the subscriber process S1 and the subscriber process S2 respectively; the publisher process P1 can perform an open operation on the shared memory area. If the shared memory area is successfully opened and the target message content D needs to be published currently, the publisher process P1 can allocate storage space for the target message content D in the shared memory area; if the allocation is successful, it indicates that the shared memory area has storage resources, and the target message content D is written in the shared memory area, and the address of the target message content D in the shared memory area is sent to the subscriber process S1 and the subscriber process S2 through the socket. Similarly, the publishing process P2 establishes a socket connection with the subscriber process S1 and the subscriber process S2. The publishing process P2 can perform an open operation on the shared memory area. If the shared memory area is successfully opened and the target message content E needs to be published currently, the publishing process P2 can allocate storage space for the target message content E in the shared memory area; if the allocation fails, the existing message content in the shared memory area is deleted, for example, the message content with the least number of accesses or the message content with the earliest creation time is deleted; after obtaining the storage space allocated for the target message content E in the shared memory area, the target message content E is written in the shared memory area, and the address of the target message content E in the shared memory area is sent to the subscriber process S1 and the subscriber process S2 through the socket.

[0083] During the message reading process, the subscriber process S1 can send a socket connection request to the publisher process P1 and the publisher process P2 to establish a socket connection between the subscriber process S1 and the publisher process P1 and the publisher process P2, and receive the address sent by the publisher process P1 and the publisher process P2 through the socket; the subscriber process S1 can open the shared memory area, and read the message content D from the shared memory area according to the address sent by the publisher process P1, and read the message content E from the shared memory area according to the address sent by the publisher process P2. Similarly, the subscriber process S2 can send a socket connection request to the publisher process P1 and the publisher process P2 to establish a socket connection between the subscriber process S2 and the publisher process P1 and the publisher process P2, and receive the address sent by the publisher process P1 and the publisher process P2 through the socket, the subscriber process S2 opens the shared memory area, and reads the message content D from the shared memory area according to the address sent by the publisher process P1, and reads the message content E from the shared memory area according to the address sent by the publisher process P2. If the opening fails, it means that there is no readable message content in the shared memory area, and the reading of the message content is abandoned.

[0084] In the above-mentioned many-to-many inter-process communication scenario, each publishing process writes the message content to be published into the shared memory area, and transmits the address of the message content in the shared memory area to each subscribing process through the socket, and each subscribing process reads the message content from the shared memory area according to the address; in this way, there is no need to frequently copy the message content in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. In addition, the address of the message content in the shared memory area is sent to the subscribing process in real time through the socket, so that the subscribing process can obtain the message content written by the publishing process in real time, and the message content synchronization between the subscribing process and the publishing process can be achieved.

[0085] Based on the description of the embodiment of the inter-process communication system described above, the embodiment of the present invention provides an inter-process communication method, see Figure 4 , this inter-process communication method can be applied to Figure 1 The inter-process communication system shown in the figure; in this embodiment, the publishing end process is represented by P1, and the subscribing end process is represented by S1; the inter-process communication method may include the following steps S101-S105.

[0086] S101: The subscriber process sends a socket connection request to the publisher process.

[0087] S102: The publishing process establishes a socket connection with the subscribing process according to the socket connection request.

[0088] In steps S101 to S102, in order to enable the publisher process P1 and the subscriber process S1 to exchange information, a socket connection can be established between the publisher process P1 and the subscriber process S1; specifically, the socket connection between the publisher process and the subscriber process can be established by broadcasting messages or by central process coordination.

[0089] In one implementation, if the socket connection between the publisher process P1 and the subscriber process S1 is established by broadcasting a message, steps S101 to S102 include steps S31 to S34:

[0090] S31. The publishing process P1 sends a broadcast message, which includes the identifier of the publishing process P1 and service description information of the publishing process P1. The service description information is used to describe what kind of message content the publishing process P1 can provide.

[0091] S32. The subscriber process S1 determines whether it needs to subscribe to the message content published by the publisher process P1 through the broadcast message of the publisher process P1.

[0092] S33. If it is determined that the message content published by the publishing process P1 needs to be subscribed, a socket connection request is sent to the publishing process P1. The socket connection request carries the identifier of the publishing process P1 and the identifier of the subscriber process S1.

[0093] S34. The publishing process P1 establishes a socket connection with the subscribing process S1 according to the socket connection request.

[0094] In steps S31 to S34, after both the publisher process and the subscriber process are started, the publisher process P1 can broadcast messages, and the subscriber process S1 can determine what kind of message content the publisher process P1 can provide based on the service description information in the broadcast message. The service description information may include message types, such as image, text, or video; and may also include message topics, such as face images, face videos, etc. Further, it is determined whether it is necessary to subscribe to the message content published by the publisher process P1 based on the service description information. If it is determined that subscription is required, a socket connection request carrying the identifier of the publisher process P1 and the identifier of the subscriber process S1 is sent to the publisher process P1, and the publisher process P1 establishes a socket connection with the subscriber process S1 based on the socket connection request.

[0095] In another implementation, if the socket connection between the publishing end process and the subscribing end process is established by central process coordination, then steps S101 to S102 include steps S41 to S42:

[0096] S41. The publishing process P1 can send the identifier of the publishing process P1 and the service description information of the publishing process P1 to the central process; the subscribing process S1 can send the identifier of the subscribing process S1 and the subscription requirements to the central process; the central process can perform pairing according to the received content. For example, if the central process finds that the message content provided by the publishing process P1 just meets the subscription requirements of the subscribing process S1, then the central process can send the identifier of the subscribing process S1 to the publishing process P1, and at the same time send the identifier of the publishing process P1 to the subscribing process S1.

[0097] S42. The publishing process P1 or the subscribing process S1 establishes a socket connection between the two according to the identifier obtained from the central process.

[0098] S103: The publishing end process writes the target message content to be published into the shared memory area, and obtains the address of the target message content in the shared memory area.

[0099] The publishing end process P1 can write the target message content to be published into the shared memory area; the writing process may include: ① The publishing end process P1 detects whether the data volume of the target message content to be published is greater than the preset quantity value; the preset quantity value here can be set according to actual needs; ② If it is greater than the preset quantity value, it indicates that the data volume of the target message content to be published is large, then the target message content to be published can be packaged and the packaged target message content can be written into the shared memory area; ③ If it is less than or equal to the preset quantity value, it indicates that the data volume of the target message content to be published is small, then the target message content can be directly written into the shared memory area. After the target message content is written into the shared memory area, the publishing end process P1 obtains the address of the target message content in the shared memory area.

[0100] S104: The publishing process transmits the address to the subscribing process through the socket.

[0101] In order to achieve message synchronization between the subscriber process S1 and the subscription publisher process P1, the publisher process P1 can transmit the address of the target message content in the shared memory area to the subscriber process S1 through the socket; then, the subscriber process S1 receives the information transmitted by the publisher process P1 through the socket, and can promptly know that the publisher process P1 has published new message content.

[0102] S105: The subscriber process reads the message content from the shared memory area according to the address.

[0103] The subscriber process S1 receives the address of the target message content sent by the publisher process P1 in the shared memory area through a socket; when the subscriber process S1 needs to read the target message content published by the publisher process P1, the target message content can be read from the shared memory area 10 according to the address. In one embodiment, if the shared memory area stores the packaged target message content, the reading process of the subscriber process S1 may include: ① reading the packaged target message content from the shared memory area according to the address; ② unpacking the packaged target message content to obtain the target message content required by the subscriber process S1. In another embodiment, if the shared memory area stores the unpackaged target message content, the subscriber process S1 can directly read the required target message content from the shared memory area according to the address.

[0104] In the embodiment of the present invention, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. And the address of the message content in the shared memory area is sent to the subscribing end process in real time through the socket, so that the subscribing end process can obtain the message content written by the publishing end process in real time, and the message content synchronization between the subscribing end process and the publishing end process can be realized.

[0105] Based on the description of the embodiments of the above inter-process communication system and the inter-process communication method, the embodiment of the present invention provides another inter-process communication method, see Figure 5 , this inter-process communication method can be applied to Figure 1 The inter-process communication system shown in the figure, in this embodiment, the publishing end process is represented by P1, and the subscribing end process is represented by S1; the inter-process communication method includes the following steps S201-S208:

[0106] S201, the publishing process establishes a socket connection with the subscribing process. For the specific implementation process, see Figure 4 Steps S101 to S102 in the illustrated embodiment.

[0107] In order to enable the publisher process P1 and the subscriber process S1 to exchange information, a socket connection can be established between the publisher process P1 and the subscriber process S1. Specifically, the socket connection between the publisher process and the subscriber process can be established by broadcasting messages or by central process coordination.

[0108] S202, the publishing end process determines whether the shared memory area has storage resources. If so, it indicates that the shared memory area has the ability to store the target message content, and the process proceeds to step S203. If not, it indicates that the shared memory area does not have the ability to store the target message content.

[0109] The publishing end process determines whether the shared memory area has storage resources, including steps S51 to S54:

[0110] S51, performing an open operation on the shared memory area.

[0111] S52: If the shared memory area is successfully opened, detect whether the shared memory area can allocate storage space for the target message content.

[0112] S53: If the shared memory area can allocate storage space for the target message content, confirm that the shared memory area has storage resources.

[0113] S54: If the shared memory area is not opened successfully, a new shared memory area with storage resources is created.

[0114] In steps S51 to S54, the shared memory area having storage resources means: the shared memory area is successfully opened, and the shared memory area is able to allocate storage space for the target message content; the shared memory area not having storage resources means: the shared memory area cannot be successfully opened, or the shared memory area can be successfully opened, but the shared memory area cannot allocate storage space for the target message content. Among them, if the shared memory area has been established, the publishing end process P1 can successfully open the shared memory area, if the shared memory area has not been established, the opening fails; therefore, if the opening is successful, it can be detected whether the shared memory area can allocate storage space for the target message content; if the opening fails, a new shared memory area with storage resources can be created. If the remaining storage space capacity of the shared memory area is greater than or equal to the data volume (i.e., length) of the target message content, the publishing end process P1 determines that the shared memory area can allocate storage space for the target message content, otherwise, it is determined that the storage space cannot be allocated for the target message content.

[0115] S203: If storage resources are available, the publishing end process increases the first reference count by a predetermined step length and obtains the state of the message queue lock, which includes an idle state or an occupied state.

[0116] If the shared memory area has storage resources, it indicates that the remaining storage space capacity of the shared memory area is greater than or equal to the data volume of the target message content, and the shared memory area has the ability to store the target message content, and the target message content can be written in the shared memory area. In the embodiment of the present invention, the shared memory area uses a message queue to store the message content, and the shared memory includes a first reference count and a message queue lock; the first reference count is used to indicate the number of publisher processes and subscriber processes that have successfully opened and not exited the shared memory area; that is, if the value of the first reference count is the initial value, it indicates that there is no process that has successfully opened and not exited the shared memory area, and it also indicates that there is no publisher process and subscriber process using the shared memory area; if the value of the first reference count is not the initial value, the first reference count is used to indicate the number of publisher processes and subscriber processes that have successfully opened and not exited the shared memory area, and it also indicates that there are publisher processes and subscriber processes using the shared memory area. Here, the initial value can be set according to actual needs, such as 0, 1, etc. When writing the target message to the shared memory area, the publisher process P1 increases the first reference count by a predetermined step length, and the predetermined step length can also be set according to actual needs, such as 1, 2, etc. Take the initial value as 0 and the predetermined step size as 1 as an example; the shared memory area is not opened by any process, and the first reference count of the shared memory area is the initial value; when the publishing end process P1 opens the shared memory area, the first reference count is increased by 1, and the value of the first reference calculation becomes 1.

[0117] In order to facilitate orderly management of the message queue, it can be set that only one process is allowed to perform editing operations on the message queue at the same time. The editing operations here include: write operations, adding nodes or deleting nodes, etc. This setting can be achieved through the message queue lock. The message queue lock is used to lock the permission for editing operations in the shared memory area. That is to say, if a publishing end process obtains and occupies the message queue lock of the shared memory area 10, and the message queue lock is in an occupied state, then the publishing end process can obtain the editing operation permission in the shared memory area 10 and can write message content to the shared memory area; at this time, other publishing end processes cannot perform editing operations on the shared memory area; only after the message queue lock is released, the released message queue lock is in an idle state, and other publishing end processes can obtain the editing operation permission in the shared memory area 10 by obtaining and occupying the message queue lock. The shared memory area may also include a message queue head node, which is used to record the state of the message content in the message queue; here, the state of the message content includes a state of having message content and a state of not having message content; wherein, having a message content state means that the message content has been written into the message queue; not having a message content state means that the message content has not been written into the message queue. Further, if the state of the message content is a state of having message content, the message queue head node may also be used to record the operation information of each message content written (such as the number of times it has been read). Further, the message queue may include at least one message node, and the message node includes a second reference count, a data structure for storing the message content, and configuration information. The message queue of the shared memory area may be established using a data structure such as a linked list (such as a single circular linked list or a bidirectional circular linked list) or an array. If the message queue of the shared memory area is established by a linked list (such as a single circular linked list or a bidirectional circular linked list), the configuration information includes the linked list configuration information; if the message queue is established by an array, the configuration information includes the array configuration information. Among them, the second reference count is used to indicate the number of subscriber processes currently reading the message content in the message node, the array configuration information and the linked list configuration information can record the exit and entry of the message queue, and the message content included in the message node refers to the message content written by the publisher process.

[0118] Take the example of using a linked list to establish a message queue in a shared memory area; at a certain moment, the state of the shared memory area is as follows: Figure 6As shown, the shared memory area 10 includes a message node 1, a message node 2 and a message node 3; wherein, the value of the second reference count in the message node 1 is 0, indicating that there is currently no subscriber process reading the message content A in the message node 1, the value of the second reference count in the message node 2 is 1, indicating that there is currently a subscriber process reading the message content B in the message node 2, and the value of the second reference count in the message node 3 is 2, indicating that there are currently two subscriber processes reading the message content C in the message node 3. The value of the first reference count of the shared memory area 10 is 5, indicating that there are currently a total of five processes that have successfully opened and have not exited the shared memory area 10. It can be seen from the second reference counts of the above-mentioned message nodes that there are currently a total of three subscriber processes reading the message content. Since only after the subscriber process opens the shared memory area can the message content in the shared memory area be read, therefore, there are currently three subscriber processes that have opened and have not exited the shared memory area, and further, it can be seen that there are currently two publisher processes that have opened and have not exited the shared memory area.

[0119] In step S202, if the shared memory area does not have storage resources, and further the shared memory area cannot allocate storage space for the target message content, it indicates that the remaining storage space capacity of the shared memory area is less than the data volume of the target message content. In a feasible implementation, a space release operation can also be performed on the shared memory area so that the target message content can be written to the shared memory area. The process of performing a space release operation on the shared memory area may include the following steps S61-S62:

[0120] S61: Obtain the message node with the earliest creation time in the message queue.

[0121] S62: If the value of the second reference count of the message node with the earliest creation time is the initial value, delete the message node with the earliest creation time.

[0122] In steps S61-S62, when the shared memory area cannot allocate storage space for the target message content, the publisher process P1 can release the message node with the earliest establishment time; specifically, the message node with the earliest establishment time in the message queue is obtained. If the value of the second reference count of the message node with the earliest establishment time is the initial value, it indicates that there is no subscriber process currently reading the message node with the earliest establishment time, and the message node with the earliest establishment time can be deleted. After deleting the message node with the earliest establishment time, if the shared memory area still cannot allocate storage space for the target message content, the next message node with the earliest establishment time can be obtained, and steps S61-S62 are executed repeatedly to delete the message node until the shared memory area can allocate storage space for the target message content. If the value of the second reference count of the message node with the earliest establishment time is not the initial value, it indicates that there is a subscriber process currently reading the message node with the earliest establishment time, and the publisher process P1 can give up writing messages to the shared memory area, or wait until the value of the second reference count of the message node with the earliest establishment time is the initial value, and then delete the message node with the earliest establishment time.

[0123] The value of the second reference count is an initial value used to indicate that there is no subscription process currently reading the message content in the message node. The initial value may be zero or other values.

[0124] For example, when the shared memory area cannot allocate storage space for the target message content, such as Figure 6 As shown, the message node with the earliest establishment time is message node 1 (since the message queue is a first-in-first-out queue, the tail node 1 in the message queue is the node that enters the message queue the earliest, that is, message node 1 is the message node with the earliest establishment time). The second reference count of message node 1 is 0, that is, the second application count of the message node is the initial value, and message node 1 can be deleted. If the publishing end process P1 is still unable to allocate storage space for the target message content after message node 1 is deleted, the publishing end process P1 can obtain the next earliest established message node (that is, message node 2). Since the second reference count of message node 2 is not the initial value, the message content is written to the shared memory area.

[0125] S204: If the message queue lock is in an idle state, the publishing end process acquires the message queue lock to obtain the write operation permission of the shared memory area.

[0126] If the message queue lock is in an idle state, it indicates that there is currently no publisher process P1 writing message content to the shared memory area. The publisher process P1 can write message content to the shared memory area. In order to avoid the problem that other publisher processes also write message content to the shared memory area during the process of the publisher process P1 writing message content, resulting in disorder of the message content stored in the shared memory area, the publisher process P1 can obtain the message queue lock to obtain the write operation permission of the shared memory, so that the message queue lock is in an occupied state.

[0127] S205: The publishing end process writes the target message content into the message queue of the shared memory area.

[0128] When obtaining the write operation permission of the shared memory area, the publishing process P1 can write the target message content into the message queue of the shared memory area. Specifically, the target message content can be written to the entrance of the message queue, or the message content can be written to the area in the message queue where the message content is not written.

[0129] The process of the publishing end process writing the target message content into the message queue of the shared memory area may include steps S71 to S73:

[0130] S71. Search for the entry of the message queue according to the data structure information.

[0131] S72. Establish a target message node at the entry.

[0132] S73. Write the target message content into the target message node, and set the value of the second reference count of the target message node, where the second reference count of the target message node is used to indicate the number of subscriber processes currently reading the message content in the target message node.

[0133] In steps S71 to S73, in order to comply with the first-in-first-out rule for transmitting message content in the message queue, the publishing process P1 can write the newly written message content into the entry. Specifically, the publishing process P1 can find the entry of the message queue according to the data structure information, establish a target message node at the entry, write the target message content into the target message node, and set the value of the second reference count of the target message node, that is, set the initial value of the second reference count of the target message node, so that the number of subscriber processes that are currently reading the message content of the target message node can be determined subsequently according to the value of the second reference count.

[0134] S206: After writing is completed, the publishing end process releases the message queue lock and obtains the address of the target message content in the shared memory area.

[0135] In order for other publishing processes to obtain the write permission of the shared memory area, or for the publishing process P1 to obtain the write permission of the shared memory area again, the publishing process P1 can release the message queue lock after writing the target message content, so that the message queue lock is in an idle state. After the publishing process P1 writes the target message content, in order to synchronize the written target message content to the subscriber process S1 in real time, the address of the target message content in the shared memory area can be obtained.

[0136] S207: The publishing process transmits the address to the subscribing process through the socket.

[0137] The publishing end process transmits the address to the subscribing end process through the socket, including: writing the address into a handle pool, and transmitting the handle in the handle pool to the subscribing end process through the socket.

[0138] The publishing process P1 can convert the address into a handle, write the handle into the handle pool, and transmit the handle in the handle pool to the subscribing process S1 through the socket. Specifically, the address is the first address (or pointer) of the target message content. The address offset is calculated based on the first address of the message content and the first address of the shared memory area. The address offset is used as the handle and written into the handle pool. The handle in the handle pool is transmitted to the subscribing process S1 through the socket.

[0139] The publishing process can also perform the following steps: when exiting the shared memory area, reduce the first reference count of the shared memory area by a predetermined step size; if the value of the first reference count of the shared memory area is the initial value, clear all message contents stored in the shared memory area or delete the message node in the message queue.

[0140] After writing the target message content into the shared memory area, the publisher process P1 can exit the shared memory area and reduce the first reference count of the shared memory area by a predetermined step. If the value of the first reference count of the shared memory area is the initial value, indicating that there is currently no subscriber process and the publisher process open and has not exited the shared memory area, the publisher process P1 can clear all message contents stored in the shared memory area or delete the message node in the message queue so that the message content can be written to the shared memory area later; if the value of the first reference count of the shared memory area is not the initial value, indicating that there is currently a subscriber process or\and the publisher process open and has not exited the shared memory area, the message in the shared memory area will not be cleared so that the subscriber process can read the message content in the shared memory area.

[0141] S208: The subscriber process reads the message content from the shared memory area according to the address.

[0142] The subscriber process S1 receives the address sent by the publisher process through the socket, including: receiving the handle in the handle pool transmitted by the subscriber process through the socket connection, and obtaining the address according to the handle. The subscriber process S1 can calculate the address of the target message content through the handle sent by the publisher process P1. Specifically, the first address of the target message content is obtained according to the handle (address offset) plus the first address of the shared memory area. The first address of the target message content is the address of the target message content, so that the target message content can be read according to the first address of the target message content.

[0143] As mentioned above, the shared memory uses a message queue to store message content, and the shared memory includes a first reference count; the message queue includes at least one message node, and the message node includes a second reference count and message content; the process of reading the target message content from the shared memory according to the address includes steps S81 to S84:

[0144] S81. Open the shared memory area, and increase the first reference count of the shared memory area by a predetermined step length.

[0145] After the subscriber process S1 receives the address, if the subscriber process S1 determines that it needs to read the target message content currently or in the future, the demand of the subscriber process S1 can be indicated by setting the first reference count of the shared memory area. Specifically, the shared memory area can be opened and the first reference count of the shared memory area can be increased by a predetermined step.

[0146] S82. Obtain a target message node in the message queue according to the address.

[0147] S83. Increase the second reference count of the target message node by a predetermined step length, and read the target message content from the target message node.

[0148] When it is necessary to read the target message content, in order to prevent the target message content from being deleted by other publishing processes or subscriber processes while the subscriber process S1 is reading the target message content, the subscriber process S1 can increase the second reference count of the target message node by a predetermined step and read the target message content from the target message node.

[0149] S84. After the reading is completed, the second reference count calculation of the target message node is reduced by a predetermined step size.

[0150] After the subscriber process S1 finishes reading the target message content, it indicates that the reading operation is completed. The subscriber process S1 can reduce the second reference count of the target message node by a predetermined step size so that the subsequent publisher process can release the space in the shared memory area according to the value of the second reference count.

[0151] The subscriber process may also perform the following steps: when exiting the shared memory area, reducing the first reference count of the shared memory area by a predetermined step; if the value of the first reference count of the shared memory area is the initial value, clearing all message contents stored in the shared memory area or deleting the message node in the message queue.

[0152] After the subscriber process S1 obtains the target message content and does not need to read other message content, the subscriber process S1 can exit the shared memory area and reduce the first reference count of the shared memory area by a predetermined step size. If the value of the first reference count of the shared memory area is the initial value, indicating that there is currently no subscriber process and the publisher process open and has not exited the shared memory area, the subscriber process S1 can clear all message contents stored in the shared memory area or delete the message node in the message queue so that the message content can be written to the shared memory area later; if the value of the first reference count of the shared memory area is not the initial value, indicating that there is currently a subscriber process or\and the publisher process open and has not exited the shared memory area, the message content of the shared memory area will not be cleared, so that the subscriber process can read the message content of the shared memory area.

[0153] In the embodiment of the present invention, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. And the address of the message content in the shared memory area is sent to the subscribing end process in real time through the socket, so that the subscribing end process can obtain the message content written by the publishing end process in real time, and the message content synchronization between the subscribing end process and the publishing end process can be realized.

[0154] The inter-process communication method provided by the embodiment of the present invention can be applied to one-to-one, one-to-many or many-to-many inter-process communication application scenarios. Figure 7, taking a robot scenario as an example, the scenario includes a robot intelligent terminal, and the intelligent terminal includes one or more camera applications, such as a high-definition camera application and a common camera application. When the high-definition camera application and / or the common camera application are started and run in the intelligent terminal, the high-definition camera process and / or the common camera process are started and run synchronously in the intelligent terminal. The intelligent terminal also includes various image applications, including but not limited to: face recognition applications, gesture recognition applications, human body recognition applications, posture recognition applications, object recognition applications, etc.; when these image recognition applications are started and run in the intelligent terminal, the corresponding processes will be started and run synchronously in the intelligent terminal. Take the scenario where the intelligent terminal starts the face recognition application for payment, and the scenario where the human body recognition application is started for personnel tracking as an example; when the face recognition application and the human body recognition application are started and run, the face recognition process and the human body recognition process are run accordingly. The face recognition process and the human body recognition process are used as subscription end processes, and the high-definition camera process and the common camera process are used as publishing end processes. The inter-process communication method includes the following steps S301-S304:

[0155] S301. The publishing process establishes a socket connection with each subscribing process. For details, see step S101 and step S102.

[0156] In order to enable the publishing process and the subscribing process to exchange information, a socket connection between the publishing process and each subscribing process can be established according to demand. For example, in the face payment scenario, in order to improve the accuracy of recognition and the security of payment, the face recognition process can subscribe to the high-definition image data published by the high-definition camera process to perform face recognition; a socket connection between the face recognition process and the high-definition camera process can be established in step S301. Another example: in the human body tracking scenario, since only the basic physical signs of the human body, such as height, body shape and other information, need to be identified when performing human body recognition in this scenario, the human body recognition process can subscribe to the ordinary image data published by the ordinary camera process for human body recognition, and a socket connection between the human body recognition process and the ordinary camera process can be established in step S301. The high-definition image data here refers to image data with pixels higher than or equal to the preset pixel threshold; ordinary image data refers to image data with pixels lower than the preset pixel threshold; the preset pixel threshold can be set according to actual needs.

[0157] S302: The publishing end process writes the acquired image data into a shared memory area, and acquires the address of the image data in the shared memory area.

[0158] When the high-definition camera process receives the instruction to shoot an image, the high-definition camera process can write the high-definition image data shot by the terminal's camera into the shared memory area and obtain the address of the high-definition image data in the shared memory area. Similarly, the ordinary camera process can write the ordinary image data shot by the terminal into the shared memory area and obtain the address of the ordinary image data in the shared memory area.

[0159] S303, the publishing end process transmits the address to each subscribing end process through the socket, for details, see step S104 and step S207.

[0160] For example, the high-definition camera process can transmit the address of the high-definition image data to the face recognition process through the socket, and the ordinary camera process can transmit the address of the ordinary image data to the body recognition process through the socket.

[0161] S304: Each subscriber process reads the message content from the shared memory area according to the address.

[0162] After the face recognition process receives the address sent by the high-definition camera process, it can read the high-definition image data released by the high-definition camera process from the shared memory area. For example, when the smart terminal makes a payment through face recognition, the face recognition process can read the high-definition image data from the shared memory area according to the received address and perform face recognition, and execute subsequent payment operations based on the face recognition results.

[0163] After the human body recognition process receives the address sent by the ordinary camera process, it can read the ordinary image data released by the ordinary camera process from the shared memory area. For example, when the public security department needs to use human body recognition to investigate a case, the human body recognition process in the smart terminal can read the ordinary image data from the shared memory area according to the received address and perform human body recognition to obtain the recognition result, and output the recognition result for subsequent investigation and tracking operations.

[0164] In the embodiment of the present invention, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. And the address of the message content in the shared memory area is sent to the subscribing end process in real time through the socket, so that the subscribing end process can obtain the message content written by the publishing end process in real time, and the message content synchronization between the subscribing end process and the publishing end process can be realized.

[0165] Based on the description of the above inter-process communication method, an embodiment of the present invention provides an inter-process communication device, see Figure 8 The inter-process communication device is applied to an inter-process communication system, the system includes a publishing end process, a subscribing end process and a shared memory area, and the inter-process communication device includes:

[0166] The connection unit 801 is used to receive a socket connection request sent by a subscriber process, and establish a socket connection with the subscriber process according to the socket connection request; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or obtained from a central process.

[0167] The writing unit 802 is used to write the target message content to be published into the shared memory area, and obtain the address of the target message content in the shared memory area.

[0168] The transmission unit 803 is used to transmit the address to the subscriber process through the socket, so that the at least one subscriber process reads the target message content from the shared memory area according to the address.

[0169] Optionally, the connection unit 801 is specifically used to receive a socket connection request sent by the subscriber process, the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or obtained from a central process; and establish a socket connection with the subscriber process according to the socket connection request.

[0170] Optionally, the judging unit 804 is configured to judge whether the shared memory area has storage resources.

[0171] Optionally, the writing unit 802 is used to write the target message content into the shared memory area if the shared memory area has storage resources.

[0172] Optionally, the judgment unit 804 is specifically used to perform an opening operation on the shared memory area; if the shared memory area is successfully opened, detect whether the shared memory area can allocate storage space for the target message content; if the shared memory area can allocate storage space for the target message content, confirm that the shared memory area has storage resources; if the shared memory area is not successfully opened, create a new shared memory area with storage resources.

[0173] Optionally, the write unit 802 is specifically used to increase the first reference count by a predetermined step size and obtain the state of the message queue lock, which includes an idle state or an occupied state; if the message queue lock is in an idle state, obtain the message queue lock to obtain write operation permissions for the shared memory area; write the target message content into the message queue of the shared memory area; after the writing is completed, release the message queue lock.

[0174] Optionally, the writing unit 802 is specifically used to find the entry of the message queue according to the configuration information; establish a target message node at the entry; write the target message content into the target message node, and set the initial value of the second reference count of the target message node, the second reference count of the target message node is used to indicate the number of subscriber processes that are currently reading the message content in the target message node.

[0175] Optionally, the releasing unit 805 is configured to release space in the shared memory area if the shared memory area cannot allocate storage space for the target message content.

[0176] Optionally, the release unit 805 is specifically used to obtain the message node with the earliest establishment time in the message queue; if the value of the second reference count of the message node with the earliest establishment time is an initial value, delete the message node with the earliest establishment time from the message queue.

[0177] Optionally, the calculation unit 806 is configured to reduce the first reference count of the shared memory area by a predetermined step size when exiting the shared memory area.

[0178] Optionally, the clearing unit 807 is configured to clear all message contents stored in the shared memory area or delete the message node in the message queue if the value of the first reference count of the shared memory area is an initial value.

[0179] Optionally, the transmission unit 803 is specifically configured to write the address into a handle pool; and transmit the handle in the handle pool to the subscriber process through the socket.

[0180] In the embodiment of the present invention, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. And the address of the message content in the shared memory area is sent to the subscribing end process in real time through the socket, so that the subscribing end process can obtain the message content written by the publishing end process in real time, and the message content synchronization between the subscribing end process and the publishing end process can be realized.

[0181] Based on the description of the above inter-process communication method, an embodiment of the present invention provides an inter-process communication device, see Fig. 9 The inter-process communication device is applied to an inter-process communication system, the system includes a publishing end process, a subscribing end process and a shared memory area, and the inter-process communication device includes:

[0182] The connection unit 901 is used to send a socket connection request to the publisher process to establish a socket connection with the publisher process; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from the broadcast message sent by the publisher process, or obtained from the central process.

[0183] The receiving unit 902 is used to receive the address sent by the publishing process through the socket, where the address is the address of the target message content in the shared memory area obtained after the publishing process writes the target message content to be published into the shared memory area.

[0184] The reading unit 903 is configured to read the target message content from the shared memory according to the address.

[0185] Optionally, the receiving unit 902 is specifically configured to receive a handle transmitted by the subscriber process through the socket, where the handle is obtained by the publisher process writing the address into a handle pool; and obtain the address according to the handle.

[0186] Optionally, the shared memory uses a message queue to store message content; the shared memory includes a first reference count; the message queue includes a target message node, and the target message node includes at least a second reference count, a data structure for storing the target message content, and configuration information, and the configuration information includes linked list configuration information or array configuration information.

[0187] Optionally, the reading unit 903 is specifically used to perform an opening operation on the shared memory area; if the shared memory area is successfully opened, increase the first reference count of the shared memory area by a predetermined step size; obtain the target message node in the message queue according to the address; increase the second reference count of the target message node by a predetermined step size; read the target message content from the target message node, and after the reading is completed, reduce the second reference count of the target message node by a predetermined step size.

[0188] Optionally, the calculation unit 904 is configured to reduce the first reference count of the shared memory area by a predetermined step size when exiting the shared memory area.

[0189] Optionally, the clearing unit 905 is configured to clear all message contents stored in the shared memory area or delete the message node in the message queue if the value of the first reference count of the shared memory area is an initial value.

[0190] In the embodiment of the present invention, the subscriber process establishes a socket connection with the publisher process, receives the address sent by the publisher process through the socket, and reads the target message content from the shared memory area according to the address. It only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. The address of the message content in the shared memory area is sent to the subscriber process in real time through the socket, so that the subscriber process can obtain the message content written by the publisher process in real time, and the message content synchronization between the subscriber process and the publisher process can be achieved.

[0191] Based on the description of the above inter-process communication method, an embodiment of the present invention provides a terminal, see Fig.10 The terminal can be a smart phone, computer, server, smart watch or smart bracelet, etc. The terminal includes an inter-process communication system, which includes a publishing process, a subscribing process and a shared memory area. See Fig.10 The terminal includes: a processor 101, an input interface 102, an output interface 103 and a computer storage medium 104.

[0192] The computer storage medium 104 may represent a storage device, including a volatile computer storage medium (volatile memory), such as a random-access computer storage medium (random-access memory, RAM); the computer storage medium may also include a non-volatile computer storage medium (non-volatile memory), such as a flash computer storage medium (flash memory), a hard disk drive (HDD) or a solid-state drive (SSD); the computer storage medium 104 may also include a combination of the above-mentioned types of computer storage media.

[0193] The input interface 102 may be used to input data to be processed to the processor 101. In one embodiment, the input interface 102 may include multiple independent interfaces, such as an Ethernet interface, an LCD (Liquid Crystal Display) interface, etc., which are responsible for the communication of different peripheral devices inputting data to the processor 101.

[0194] The output interface 103 can be used to output data to other peripheral devices connected to the terminal, and can output the processing results of the processor 101. The output interface 103 can also include multiple independent interfaces, such as an Ethernet interface, a camera interface, etc., which are responsible for the communication of the processor 101 outputting data to different peripheral devices.

[0195] In one embodiment, the output interface 103 and the input interface 102 may be general purpose input output (GPIO) interfaces.

[0196] The processor 101 can be used to read and execute computer instructions. In one embodiment, the processor 701 can further include a hardware chip. The hardware chip can be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0197] The computer storage medium 104 is also used to store one or more program instructions; the program instructions include a first instruction and / or a second instruction. In one embodiment, the processor 101 can execute an inter-process communication method to provide an inter-process communication service when calling the first instruction. Specifically, the processor 101 calls the first instruction to execute the following steps:

[0198] Receive a socket connection request sent by a subscriber process, wherein the socket connection request carries an identifier of a publisher process and an identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or from a central process;

[0199] Establishing a socket connection with the subscriber process according to the socket connection request; writing the target message content to be published into the shared memory area, and obtaining the address of the target message content in the shared memory area;

[0200] The address is transmitted to the subscriber process through the socket, so that the subscriber process reads the target message content from the shared memory area according to the address.

[0201] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0202] Receive a socket connection request sent by the subscriber process, the socket connection request carrying an identifier of the publisher process and an identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from a broadcast message sent by the publisher process, or obtained from a central process;

[0203] A socket connection is established with the subscriber process according to the socket connection request.

[0204] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0205] Determining whether the shared memory area has storage resources;

[0206] If the shared memory area has storage resources, the target message content is written into the shared memory area.

[0207] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0208] Performing an open operation on the shared memory area;

[0209] If the shared memory area is successfully opened, detecting whether the shared memory area can allocate storage space for the target message content;

[0210] If the shared memory area can allocate storage space for the target message content, confirming that the shared memory area has storage resources;

[0211] If the shared memory area is not successfully opened, a new shared memory area with storage resources is created.

[0212] Optionally, the shared memory area uses a message queue to store message content; the shared memory includes a first reference count and a message queue lock; the processor 101 may call the first instruction and execute the following steps:

[0213] Increment the first reference count by a predetermined step length, and obtain the state of the message queue lock, the state including an idle state or an occupied state;

[0214] If the message queue lock is in an idle state, acquiring the message queue lock to obtain the write operation permission of the shared memory area;

[0215] Writing the target message content into the message queue of the shared memory area;

[0216] After writing is completed, the message queue lock is released.

[0217] Optionally, the message queue includes at least one message node, the message node includes at least a second reference count, a data structure for storing message content, and configuration information, the configuration information includes linked list configuration information or array configuration information; the processor 101 may call the first instruction to perform the following steps:

[0218] Finding an entry to the message queue according to the configuration information;

[0219] Establishing a target message node at the entry point;

[0220] The target message content is written into the target message node, and an initial value of a second reference count of the target message node is set, wherein the second reference count of the target message node is used to indicate the number of subscriber processes currently reading the message content in the target message node.

[0221] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0222] If the shared memory area cannot allocate storage space for the target message content, a space release operation is performed on the shared memory area.

[0223] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0224] Obtain the message node with the earliest creation time in the message queue;

[0225] If the value of the second reference count of the message node with the earliest creation time is an initial value, the message node with the earliest creation time is deleted from the message queue.

[0226] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0227] When exiting the shared memory area, reducing the first reference count of the shared memory area by a predetermined step length;

[0228] If the value of the first reference count of the shared memory area is the initial value, all message contents stored in the shared memory area are cleared or the message nodes in the message queue are deleted.

[0229] Optionally, the processor 101 may call the first instruction to perform the following steps:

[0230] Writing the address into the handle pool;

[0231] The handle in the handle pool is transmitted to the subscriber process through the socket.

[0232] In another implementation, the processor 101 may be able to execute an inter-process communication method to provide an inter-process communication service when calling the second instruction. Specifically, the processor 101 calls the second instruction to execute the following steps:

[0233] Sending a socket connection request to the publisher process to establish a socket connection with the publisher process; the socket connection request carries the identifier of the publisher process and the identifier of the subscriber process; the identifier of the publisher process is obtained by the subscriber process from the broadcast message sent by the publisher process, or obtained from the central process;

[0234] Receive the address sent by the publishing end process through the socket, where the address is the address of the target message content in the shared memory area obtained after the publishing end process writes the target message content to be published into the shared memory area;

[0235] The target message content is read from the shared memory according to the address.

[0236] Optionally, the processor 101 may call the second instruction to perform the following steps:

[0237] Receiving, through the socket, a handle transmitted by the subscriber process, wherein the handle is obtained by the publisher process writing the address into a handle pool;

[0238] The address is obtained according to the handle.

[0239] Optionally, the processor 101 may call the second instruction to perform the following steps:

[0240] Performing an open operation on the shared memory area;

[0241] If the shared memory area is successfully opened, the first reference count of the shared memory area is increased by a predetermined step length;

[0242] Acquire a target message node in the message queue according to the address;

[0243] Increasing the second reference count of the target message node by a predetermined step length;

[0244] The target message content is read from the target message node, and after the reading is completed, the second reference count of the target message node is reduced by a predetermined step length.

[0245] Optionally, the processor 101 may call the second instruction to perform the following steps:

[0246] When exiting the shared memory area, reducing the first reference count of the shared memory area by a predetermined step length;

[0247] If the value of the first reference count of the shared memory area is the initial value, all message contents stored in the shared memory area are cleared or the message nodes in the message queue are deleted.

[0248] It should also be noted that the functions corresponding to the terminal of the present invention can be implemented through hardware design, software design, or a combination of software and hardware, which is not limited here.

[0249] The embodiment of the present invention further provides a computer program product, the computer program product includes a computer storage medium storing a computer program, when the computer program product is run on a computer, the computer executes part or all of the steps of any one of the inter-process communication methods described in the above method embodiments. In one embodiment, the computer program product can be a software installation package.

[0250] In the embodiment of the present invention, the publishing end process establishes a socket connection with the subscribing end process, writes the target message content to be published into the shared memory area, and sends the address of the target message content in the shared memory area to the subscribing end process through the socket. When the subscribing end process needs to read the message content, it can read the message content from the shared memory area according to the address sent by the publishing end process. It can be seen that the embodiment of the present invention only needs to copy the message content in the shared memory area, and does not need to copy it frequently in the kernel and buffer, which reduces the number of times the message content is copied, can reduce the resource overhead of the operating system, and reduce the transmission delay of the message content, and improve the throughput of the message content transmission. And the address of the message content in the shared memory area is sent to the subscribing end process in real time through the socket, so that the subscribing end process can obtain the message content written by the publishing end process in real time, and the message content synchronization between the subscribing end process and the publishing end process can be realized.

[0251] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the above-mentioned program can be stored in a computer storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the above-mentioned storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0252] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A method for communication between processes, characterized in that: include: The publisher process sends the identifier and service description information of the publisher process to the central process; the central process is used to receive the identifier and subscription requirements of the subscriber process sent by the subscriber process, and when it is determined according to the service description information that the message content provided by the publisher process meets the subscription requirements of the subscriber process, the identifier of the subscriber process is sent to the publisher process; Establishing a socket connection with the subscriber process according to the identifier obtained from the central process; If the shared memory area cannot allocate storage space for the target message content, obtain the message node with the earliest creation time in the message queue in the shared memory area; if the value of the second reference count of the message node with the earliest creation time is the initial value, delete the message node with the earliest creation time from the message queue; if the shared memory area can allocate storage space for the target message content, confirm that the shared memory area has storage resources; the value of the second reference count is the initial value, indicating that there is no subscription process currently reading the message content in the message node with the earliest creation time; If the shared memory area has storage resources, a target message node is created in the message queue; if the data volume of the target message content is greater than a preset quantity value, the target message content to be published is packaged and written to the target message node in the message queue in the shared memory area, and the first address of the packaged target message content in the shared memory area is obtained; the message queue allows one process to perform an editing operation on it at the same time, and the message queue allows one or more processes to perform a read operation on the message nodes therein while the editing operation is being performed; the editing operation includes a write operation; Calculate an address offset according to the first address of the processed target message content and the first address of the shared memory area, write the address offset into a handle pool as a handle, and transmit the handle in the handle pool to the subscriber process through the socket, so that the subscriber process determines the first address of the processed target message content according to the first address of the shared memory area and the address offset in the handle, and reads the packaged processed target message content from the shared memory area according to the first address of the processed target message content; When exiting the shared memory area, reducing the first reference count of the shared memory area by a predetermined step length; If the value of the first reference count of the shared memory area is the initial value, all message contents stored in the shared memory area are cleared or the message nodes in the message queue are deleted; the value of the first reference count is the initial value, reflecting that there is no subscriber process and publisher process opened in the shared memory area and the shared memory area has not been exited.

2. The method according to claim 1, characterized in that Before creating the target message node in the message queue, the method further includes: Performing an open operation on the shared memory area; If the shared memory area is not successfully opened, a new shared memory area with storage resources is created; If the shared memory area is successfully opened, it is detected whether the shared memory area can allocate storage space for the target message content.

3. The method according to claim 2, characterized in that The shared memory area uses a message queue to store message content; the shared memory includes a first reference count and a message queue lock; the message queue includes at least one message node, the message node includes at least a second reference count, a data structure for storing message content, and configuration information, the configuration information includes linked list configuration information or array configuration information; The step of creating a target message node in the message queue, and if the data volume of the target message content is greater than a preset quantity value, packaging the target message content to be published, and writing the packaged target message content to the target message node in the message queue in the shared memory area includes: Increment the first reference count by a predetermined step length, and obtain the state of the message queue lock, the state including an idle state or an occupied state; If the message queue lock is in an idle state, acquiring the message queue lock to obtain the write operation permission of the shared memory area; Finding an entry to the message queue according to the configuration information; Establishing a target message node at the entry point; If the data volume of the target message content is greater than a preset quantity value, the target message content to be published is packaged, the packaged target message content is written into the target message node, and an initial value of the second reference count of the target message node is set, where the second reference count of the target message node is used to indicate the number of subscriber processes currently reading the message content in the target message node; After writing is completed, the message queue lock is released.

4. A method for communication between processes, characterized in that: include: A handle in a handle pool sent by a publishing end process through a socket connection is received, wherein the handle is generated by the publishing end process based on an address offset between a first address of a target message content after packaging processing in a shared memory area and a first address of the shared memory area, wherein the target message content after packaging processing is obtained by packaging the target message content to be published when the data volume of the target message content is greater than a preset quantity value, and the target message content after packaging processing is written into a target message node in a message queue in the shared memory area; The target message node is a message node with the earliest establishment time in the message queue in the shared memory area when the shared memory area cannot allocate storage space for the target message content; if the value of the second reference count of the message node with the earliest establishment time is the initial value, the message node with the earliest establishment time is deleted from the message queue; if the shared memory area can allocate storage space for the target message content, it is confirmed that the shared memory area has storage resources; after the shared memory area has storage resources, it is created in the message queue, and the initial value indicates that there is no subscription process currently reading the message content in the message node with the earliest establishment time; the message queue allows one process to perform an editing operation on it at the same time, and the message queue allows one or more processes to perform a reading operation on the message nodes therein while the editing operation is being performed; the editing operation includes a write operation; the socket connection is established by the publisher process and the subscriber process according to the identifier obtained from the central process, and the central process is used to receive the identifier and subscription requirements of the subscriber process sent by the subscriber process, and when it is determined according to the service description information that the message content provided by the publisher process meets the subscription requirements of the subscriber process, the identifier of the subscriber process is sent to the publisher process; Determine the first address of the processed target message content according to the first address of the shared memory area and the address offset in the handle, and read the packaged target message content from the shared memory area according to the first address of the processed target message content; When exiting the shared memory area, reducing the first reference count of the shared memory area by a predetermined step length; If the value of the first reference count of the shared memory area is the initial value, all message contents stored in the shared memory area are cleared or the message nodes in the message queue are deleted; the value of the first reference count is the initial value, reflecting that there is no subscriber process and publisher process opened in the shared memory area and the shared memory area has not been exited.

5. The method according to claim 4, characterized in that The shared memory uses a message queue to store message content; the shared memory includes a first reference count; the message queue includes a target message node, the target message node includes at least a second reference count, a data structure for storing the target message content, and configuration information, the configuration information includes linked list configuration information or array configuration information; The step of reading the packaged target message content from the shared memory area according to the first address of the processed target message content comprises: Performing an open operation on the shared memory area; If the shared memory area is successfully opened, the first reference count of the shared memory area is increased by a predetermined step length; Acquire the target message node in the message queue according to the first address of the processed target message content; Increasing the second reference count of the target message node by a predetermined step length; The target message content is read from the target message node, and after the reading is completed, the second reference count of the target message node is reduced by a predetermined step length.

6. An inter-process communication device, characterized in that: include: A connection unit, used to send the identifier and service description information of the publisher process to the central process through the publisher process; the central process is used to receive the identifier and subscription requirements of the subscriber process sent by the subscriber process, and when it is determined according to the service description information that the message content provided by the publisher process meets the subscription requirements of the subscriber process, the identifier of the subscriber process is sent to the publisher process; and a socket connection is established with the subscriber process according to the identifier obtained from the central process; The release unit obtains the earliest message node in the message queue in the shared memory area if the shared memory area cannot allocate storage space for the target message content; if the value of the second reference count of the earliest message node is the initial value, deletes the earliest message node from the message queue; the value of the second reference count being the initial value indicates that there is no subscription process currently reading the message content in the earliest message node; A judging unit, configured to confirm that the shared memory area has storage resources if the shared memory area can allocate storage space for the target message content; A writing unit, used for creating a target message node in the message queue if the shared memory area has storage resources, and for packaging the target message content to be published if the data volume of the target message content is greater than a preset quantity value, and writing the packaged target message content into the shared memory area, and obtaining the first address of the packaged target message content in the shared memory area; the message queue allows one process to perform an editing operation on it at the same time, and the message queue allows one or more processes to perform a read operation on the message nodes therein while the editing operation is being performed; the editing operation includes a write operation; A transmission unit, used for calculating an address offset according to the first address of the processed target message content and the first address of the shared memory area, writing the address offset into a handle pool as a handle, transmitting the handle in the handle pool to the subscriber process through the socket, so that the first address of the processed target message content is determined according to the first address of the shared memory area and the address offset in the handle, and the packaged processed target message content is read from the shared memory area according to the first address of the processed target message content; a computing unit, configured to reduce a first reference count of the shared memory area by a predetermined step length when exiting the shared memory area; A clearing unit is used to clear all message contents stored in the shared memory area or delete the message node in the message queue if the value of the first reference count of the shared memory area is an initial value; the value of the first reference count is an initial value, reflecting that there is no subscriber process and publisher process opened in the shared memory area and the shared memory area has not been exited.

7. An inter-process communication device, characterized in that: include: A receiving unit, used for receiving a handle in a handle pool sent by a publishing end process through a socket connection, wherein the handle is generated by the publishing end process based on an address offset between a first address of a target message content after packaging processing in a shared memory area and a first address of the shared memory area, wherein the target message content after packaging processing is obtained by packaging the target message content to be published when the data volume of the target message content is greater than a preset quantity value, and the target message content after packaging processing is written into a target message node in a message queue in the shared memory area; The target message node is a message node with the earliest establishment time in the message queue in the shared memory area when the shared memory area cannot allocate storage space for the target message content; if the value of the second reference count of the message node with the earliest establishment time is the initial value, the message node with the earliest establishment time is deleted from the message queue; if the shared memory area can allocate storage space for the target message content, it is confirmed that the shared memory area has storage resources; after the shared memory area has storage resources, it is created in the message queue, and the initial value indicates that there is no subscription process currently reading the message content in the message node with the earliest establishment time; the message queue allows one process to perform an editing operation on it at the same time, and the message queue allows one or more processes to perform a reading operation on the message nodes therein while the editing operation is being performed; the editing operation includes a write operation; the socket connection is established by the publisher process and the subscriber process according to the identifier obtained from the central process, and the central process is used to receive the identifier and subscription requirements of the subscriber process sent by the subscriber process, and when it is determined according to the service description information that the message content provided by the publisher process meets the subscription requirements of the subscriber process, the identifier of the subscriber process is sent to the publisher process; A reading unit, configured to determine the first address of the processed target message content according to the first address of the shared memory area and the address offset in the handle, and read the packaged target message content from the shared memory area according to the first address of the processed target message content; a computing unit, configured to reduce a first reference count of the shared memory area by a predetermined step length when exiting the shared memory area; A clearing unit is used to clear all message contents stored in the shared memory area or delete the message node in the message queue if the value of the first reference count of the shared memory area is an initial value; the value of the first reference count is an initial value, reflecting that there is no subscriber process and publisher process opened in the shared memory area and the shared memory area has not been exited.

8. An inter-process communication system, characterized in that: Including the publishing process, the subscriber process and the shared memory area: The publishing end process is used to send the identifier and service description information of the publishing end process to the central process through the publishing end process; the central process is used to receive the identifier and subscription requirements of the subscriber process sent by the subscriber process, and when it is determined according to the service description information that the message content provided by the publishing end process meets the subscription requirements of the subscriber process, the identifier of the subscriber process is sent to the publishing end process; a socket connection is established with the subscriber process according to the identifier obtained from the central process; if the shared memory area cannot allocate storage space for the target message content, the earliest message node in the message queue in the shared memory area is obtained; if the value of the second reference count of the earliest message node is the initial value, the earliest message node is deleted from the message queue; if the shared memory area can allocate storage space for the target message content, it is confirmed that the shared memory area has storage resources; the value of the second reference count is the initial value, indicating that there is no subscriber process currently reading the message content in the earliest message node; If the shared memory area has storage resources, a target message node is created in the message queue; if the data volume of the target message content is greater than a preset quantity value, the target message content to be published is packaged and written into the target message node in the message queue in the shared memory area, and the first address of the packaged target message content in the shared memory area is obtained; an address offset is calculated according to the first address of the processed target message content and the first address of the shared memory area, the address offset is used as a handle, and is written into a handle pool, and the handle in the handle pool is transmitted to the subscriber process through the socket; the message queue allows one process to perform an editing operation on it at the same time, and the message queue allows one or more processes to perform a read operation on the message nodes therein while the editing operation is being performed; the editing operation includes a write operation; The subscriber process is used to establish a socket connection with the publisher process; receive a handle in the handle pool, determine the first address of the processed target message content according to the first address of the shared memory area and the address offset in the handle, and read the packaged target message content from the shared memory area according to the first address of the processed target message content; when exiting the shared memory area, reduce the first reference count of the shared memory area by a predetermined step length; The subscriber process or the publisher process is further used to reduce the first reference count of the shared memory area by a predetermined step length when exiting the shared memory area; if the value of the first reference count of the shared memory area is the initial value, clear all message contents stored in the shared memory area or delete the message node in the message queue; the value of the first reference count being the initial value reflects that there is no subscriber process and publisher process in the shared memory area that is open and has not exited the shared memory area; The shared memory area is used to store the packaged target message content written by the publishing end process.

9. A computer storage medium, characterized in that The computer storage medium stores at least one first instruction, and the at least one first instruction is suitable for being loaded by a processor and executing the inter-process communication method as described in any one of claims 1-5; or, the computer storage medium stores at least one second instruction, and the at least one second instruction is suitable for being loaded by a processor and executing the inter-process communication method as described in any one of claims 1-5.

10. A terminal, characterized in that: include: a processor adapted to implement at least one instruction; as well as, A computer storage medium storing at least one first instruction, wherein the at least one first instruction is suitable for being loaded by a processor and executing the inter-process communication method as described in any one of claims 1 to 3; or, the computer storage medium storing at least one second instruction, wherein the at least one second instruction is suitable for being loaded by a processor and executing the inter-process communication method as described in any one of claims 4 to 5.

11. A computer program product, comprising a computer storage medium storing a computer program, and when the computer program product is run on a computer, the computer executes the method according to any one of claims 1 to 5.