Communication method, device and system, edge computing equipment and storage medium

By establishing a message queue in the shared memory space and parsing the queue head to obtain pointer information, the problem of low efficiency in inter-process communication in the existing technology is solved, and efficient inter-process communication and concurrency are achieved.

CN121597431APending Publication Date: 2026-03-03KINGFAR INTERNATIONAL INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411132081.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing technologies for inter-process communication based on MQTT are not very efficient.

Method used

A message queue is established in the shared memory space. The pointer information is obtained by parsing the queue head, and the message body is read from or written to the message storage area. The pointer information is used to achieve efficient access.

Benefits of technology

It improves the efficiency and concurrency of inter-process communication, combining the efficient access characteristics of shared memory with the high scalability and decoupling of message queues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597431A_ABST
    Figure CN121597431A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a communication method, device and system, an edge computing device and a storage medium, a message queue is established in a shared memory space, and a data structure of the message queue is defined, so that a process can obtain pointer information by analyzing a queue head of the message queue, and the information of the message queue can be obtained based on the pointer information. The message body is read or written in from the message storage area, the characteristic that the shared memory can achieve efficient access and the advantages of high expandability and decoupling of the message queue are combined, the inter-process communication efficiency is improved, and the inter-process communication concurrency is improved by means of the asynchronous characteristic of the message queue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the fields of data processing and human factors intelligence technology, specifically relating to a communication method, device and system, edge computing device and storage medium. Background Technology

[0002] Inter-process communication often uses the Message Queuing Telemetry Transport (MQTT) protocol, which is a lightweight message transmission protocol. The MQTT communication mechanism is based on a central broker. Clients do not communicate directly with each other, but instead publish and subscribe to messages through the broker.

[0003] However, inter-process access based on MQTT suffers from inefficiency. Summary of the Invention

[0004] This application provides a communication method, apparatus and system, edge computing device and storage medium. The technical solutions provided by this application are intended to solve the problem of low efficiency in inter-process access in the prior art.

[0005] In a first aspect, embodiments of this application provide a communication method, including:

[0006] Parse the queue head of the message queue to obtain pointer information. The message queue is established in a shared memory space and includes a queue head and a message storage area. The queue head includes the pointer information, and the message storage area is used to store the message body.

[0007] Based on the pointer information, the message body is read from or written to the message storage area.

[0008] Optionally, the pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer;

[0009] The step of reading or writing the message body from the message storage area based on the pointer information includes:

[0010] Based on the size of the message to be written, the initial position of the first write end pointer is modified to the end position, and the difference between the end position and the initial position is equal to the size of the message to be written;

[0011] The message to be written begins to be written from the initial position of the first write start pointer until the message to be written is completed, at which point the initial position of the first write start pointer is updated to the end position of the message to be written.

[0012] Optionally, before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes:

[0013] Acquire the mutex lock;

[0014] After writing the message to be written from the initial position of the first write start pointer until the message to be written is completed, and updating the initial position of the first write start pointer to the end position of the message to be written, the method further includes:

[0015] Release the mutex.

[0016] Optionally, before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes:

[0017] The initial position of the first write start pointer is determined to be the same as the initial position of the first write end pointer.

[0018] Optionally, before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes:

[0019] If the initial position of the first write start pointer is not the same as the initial position of the first write end pointer, then the initial position of the first write start pointer and the initial position of the first write end pointer are set to be the same.

[0020] Optionally, setting the initial position of the first write start pointer and the initial position of the first write end pointer to be the same includes:

[0021] Update the initial position of the first write start pointer to the initial position of the first write end pointer, or update the initial position of the first write end pointer to the initial position of the first write start pointer.

[0022] Optionally, before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes:

[0023] The size of the message to be written is determined to be less than or equal to the size of the message storage area.

[0024] Optionally, the pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer;

[0025] The step of reading or writing the message body from the message storage area based on the pointer information includes:

[0026] The message body is read from the initial position of the second end-of-write pointer until the reading ends at the initial position of the first end-of-write pointer. The initial position of the second end-of-write pointer is the same as the initial position of the first end-of-write pointer in the previous reading.

[0027] Optionally, the step of continuing until the initial position of the first end-of-write pointer is read out further includes:

[0028] Obtain the initial position of the first write end pointer from the head of the queue, and determine that the initial position of the first write end pointer does not exceed the boundary of the read messages; and / or, obtain the initial position of the first write end pointer from the head of the queue, and determine that the initial position of the first write end pointer exceeds the boundary of the read messages, then discard the read messages.

[0029] Optionally, the step of reading the message body from the initial position of the second write end pointer until the reading from the initial position of the first write end pointer further includes:

[0030] If the initial position of the second write start pointer is not the same as the initial position of the first write start pointer, then it is determined that there is a message update.

[0031] Optionally, the data structure of the message body includes: a message header and a payload portion, wherein the message header includes: payload length information; the step of reading the message body from the initial position of the second write end pointer until the reading ends at the initial position of the first write end pointer further includes:

[0032] The difference between the initial position of the first write start pointer and the initial position of the second write start pointer is determined to be greater than or equal to the length of the message header of the message body.

[0033] Optional, also includes:

[0034] The difference between the initial position of the first write start pointer and the initial position of the second write start pointer is determined to be less than or equal to the size of the message storage area.

[0035] Optionally, the step of reading the message body from the initial position of the second write end pointer until the reading ends at the initial position of the first write end pointer includes:

[0036] Starting from the initial position of the second end-of-write pointer, parse the message header of the message body to obtain the length information of the payload in the message header;

[0037] The payload is read based on its length information until the reading ends at the initial position of the first write end pointer.

[0038] Optionally, the data structure of the message body further includes: a topic identifier portion; the message header further includes: length information of the topic identifier; before reading or writing the message body from the message storage area based on the pointer information, the process further includes:

[0039] Parse the message header of the message body to obtain the length information of the topic identifier in the message header;

[0040] Based on the length information of the topic identifier, the topic corresponding to the message body is obtained;

[0041] Determine if the topic matches the subscription list.

[0042] Optionally, determining that the topic matches the subscription list includes:

[0043] Based on the matching weights, the matching is performed sequentially in the order of full matching, parameter matching, and wildcard matching until a match is successful.

[0044] Optionally, before parsing the message header of the message body and obtaining the length information of the topic identifier in the message header, the method further includes:

[0045] Confirm that the subscribers are recorded in the subscription list.

[0046] Optionally, before determining that there is a value in the subscription list, the method further includes:

[0047] The message header has been confirmed to be correct.

[0048] Optionally, the step of reading the message body from the initial position of the second write end pointer until the reading from the initial position of the first write end pointer further includes:

[0049] The cancellation token is valid.

[0050] Optionally, before parsing the message queue head and obtaining the pointer information, the process further includes:

[0051] Request a shared memory space, and establish a message queue in the shared memory space. The message queue includes a queue head and a storage area.

[0052] Secondly, embodiments of this application provide a communication device, including:

[0053] The parsing module is used to parse the queue head of the message queue and obtain pointer information. The message queue is established in a shared memory space and includes a queue head and a message storage area. The queue head includes the pointer information, and the message storage area is used to store the message body.

[0054] The processing module is used to read or write the message body from the message storage area based on the pointer information.

[0055] Optionally, the pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer;

[0056] The processing module is specifically used to modify the initial position of the first write end pointer to the end position according to the size of the message to be written, wherein the difference between the end position and the initial position is equal to the size of the message to be written; to start writing the message to be written from the initial position of the first write start pointer until the message to be written is completed, and then update the initial position of the first write start pointer to the end position of the message to be written.

[0057] Optionally, the processing module is further configured to acquire a mutex lock and release the mutex lock.

[0058] Optionally, the processing module is further configured to determine that the initial position of the first write start pointer is the same as the initial position of the first write end pointer.

[0059] Optionally, the processing module is further configured to set the initial position of the first write start pointer and the initial position of the first write end pointer to be the same if the initial position of the first write start pointer and the initial position of the first write end pointer are not the same.

[0060] Optionally, the processing module is specifically used to update the initial position of the first write start pointer to the initial position of the first write end pointer, or to update the initial position of the first write end pointer to the initial position of the first write start pointer.

[0061] Optionally, the processing module is further configured to determine that the size of the message to be written is less than or equal to the size of the message storage area.

[0062] Optionally, the pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer;

[0063] The processing module is specifically used to read the message body from the initial position of the second write end pointer until the reading ends at the initial position of the first write end pointer. The initial position of the second write end pointer is the initial position of the first write end pointer in the previous reading.

[0064] Optionally, the processing module is further configured to obtain the initial position of the first write end pointer from the queue head, and determine that the initial position of the first write end pointer does not exceed the boundary of the read message; and / or, if the initial position of the first write end pointer is obtained from the queue head and it is determined that the initial position of the first write end pointer exceeds the boundary of the read message, then the read message is discarded.

[0065] Optionally, the processing module is further configured to determine that if the initial position of the second write start pointer is inconsistent with the initial position of the first write start pointer, then a message update is determined.

[0066] Optionally, the data structure of the message body includes a message header and a payload portion, wherein the message header includes the length information of the payload; the processing module is further configured to determine that the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is greater than or equal to the length of the message header of the message body.

[0067] Optionally, the processing module is further configured to determine that the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is less than or equal to the size of the message storage area.

[0068] Optionally, the processing module is specifically used to parse the message header of the message body from the initial position of the second write end pointer, obtain the length information of the payload in the message header, and read the payload based on the length information of the payload until the reading ends at the initial position of the first write end pointer.

[0069] Optionally, the data structure of the message body further includes: a topic identifier portion; the message header further includes: the length information of the topic identifier; the processing module is further configured to parse the message header of the message body, obtain the length information of the topic identifier in the message header; obtain the topic corresponding to the message body based on the length information of the topic identifier; and determine that the topic matches the subscription list.

[0070] Optionally, the processing module is specifically used to perform matching based on the matching weight in the order of full matching, parameter matching, and wildcard matching until a match is successful.

[0071] Optionally, the processing module is specifically used to determine if there are subscribers recorded in the subscription list.

[0072] Optionally, the processing module is also used to determine that the message header is correct.

[0073] Optionally, the processing module is also used to determine whether the cancellation token is valid.

[0074] Optionally, the processing module is further configured to request shared memory space and establish a message queue in the shared memory space, the message queue including a queue head and a storage area.

[0075] Thirdly, embodiments of this application provide an edge computing device, including a processor and a memory, wherein the memory stores a program or instructions that can run on the processor, and the program or instructions, when executed by the processor, implement the steps of the communication method as described in any of the first aspects.

[0076] Fourthly, embodiments of this application provide a communication system including an edge computing device as described in the third aspect, wherein the edge computing device is configured with message queues and / or topics for publishers and subscribers to communicate based on the message queues and / or topics.

[0077] Fifthly, embodiments of this application provide a computer-readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the communication method as described in any of the first aspects.

[0078] In a sixth aspect, embodiments of this application provide a computer program product that, when executed by a processor, implements the steps of the communication method as described in any of the first aspects.

[0079] The communication method, apparatus, system, edge computing device, and storage medium provided in this application establish a message queue in a shared memory space and define the data structure of the message queue. As a result, processes can obtain pointer information by parsing the queue head of the message queue, and read or write the message body from the message storage area based on the pointer information. This combines the high efficiency of shared memory access with the high scalability and decoupling of message queues, thereby improving the efficiency of inter-process communication. Furthermore, the asynchronous nature of message queues improves the concurrency of inter-process communication. Attached Figure Description

[0080] Figure 1 This is a schematic diagram of a message queue data structure provided in an embodiment of this application;

[0081] Figure 2 This is a schematic diagram of a data structure for a message body provided in an embodiment of this application;

[0082] Figure 3 This is a schematic diagram of another message body data structure provided in an embodiment of this application;

[0083] Figure 4 A flowchart illustrating an inter-process communication method provided in an embodiment of this application;

[0084] Figure 5 A schematic diagram illustrating a message writing process provided in an embodiment of this application;

[0085] Figure 6A schematic diagram illustrating another message writing process provided in an embodiment of this application;

[0086] Figure 7 A schematic diagram illustrating another message writing process provided in an embodiment of this application;

[0087] Figure 8 A schematic diagram illustrating yet another message writing process provided in an embodiment of this application;

[0088] Figure 9 A schematic diagram illustrating a message reading process provided in an embodiment of this application;

[0089] Figure 10 A schematic diagram illustrating another message reading process provided in an embodiment of this application;

[0090] Figure 11 A schematic diagram illustrating another message reading process provided in an embodiment of this application;

[0091] Figure 12 A schematic diagram illustrating yet another message reading process provided in an embodiment of this application;

[0092] Figure 13 A schematic diagram illustrating yet another message reading process provided in an embodiment of this application;

[0093] Figure 14 A schematic diagram illustrating a message reading process provided in an embodiment of this application;

[0094] Figure 15 A schematic diagram illustrating a message reading process provided in an embodiment of this application;

[0095] Figure 16 This application provides a schematic diagram of the structure of a communication device according to an embodiment of the present application;

[0096] Figure 17 This is a schematic diagram of the structure of an edge computing device according to an embodiment of this application. Detailed Implementation

[0097] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0098] The terms "first," "second," etc., used in this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same class, without limiting the number of objects; for example, the first object can be one or more. Furthermore, "or" in this application indicates at least one of the connected objects. For example, "A or B" covers three scenarios: Scenario 1: including A but not B; Scenario 2: including B but not A; Scenario 3: including both A and B. The character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0099] The term "instruction" in this application can be either a direct instruction (or explicit instruction) or an indirect instruction (or implicit instruction). A direct instruction can be understood as one in which the sender explicitly informs the receiver of specific information, the operation to be performed, or the requested result, etc., in the instruction sent. An indirect instruction can be understood as one in which the receiver determines the corresponding information based on the instruction sent by the sender, or makes a judgment and determines the operation to be performed or the requested result, etc., based on the judgment result.

[0100] This application embodiment improves message access efficiency by establishing a message queue in shared memory for inter-process communication.

[0101] In this embodiment, a shared memory space is first allocated, and a message queue is established in the shared memory space. The message queue includes a queue head and a message storage area.

[0102] The implementation methods for establishing a message queue in shared memory in this application embodiment include, but are not limited to, the following possible implementation methods:

[0103] like Figure 1 As shown, Figure 1 This is a schematic diagram of a message queue data structure provided in an embodiment of this application. A queue head 11 is defined in shared memory, wherein the queue head 11 is used to store pointer information, specifically a write start pointer (also called a head pointer) and a write end pointer (also called a tail pointer); a message storage area 12 is defined, which is used to store the message body, thereby realizing the establishment of a message queue in shared memory.

[0104] This application embodiment also defines a data structure for the message body, which includes, but is not limited to, the following possible implementations:

[0105] One possible implementation is as follows: Figure 2 As shown, Figure 2This is a schematic diagram of a message body data structure provided in an embodiment of this application. The message body includes a message header 21 and a payload portion 22. The message header includes the length information of the payload, and the payload portion is used to carry the message content. This message body data structure can be applied to general inter-process communication, such as IoT device communication, real-time monitoring systems, and traffic simulation systems.

[0106] Another possible implementation is as follows Figure 3 As shown, Figure 3 This is a schematic diagram of another message body data structure provided in an embodiment of this application. Figure 3 Is Figure 2 Based on the data structure of the message body shown, a topic identifier section 23 is added. This topic identifier section carries topic identifier information, and the message header also includes the length information of the topic identifier. This message body data structure can be applied to some scenarios of inter-process communication based on topics. Inter-process communication based on topics can improve system flexibility, scalability, and decoupling. For example, it can be applied to message subscription and publishing libraries, where message subscribers and publishers write and read messages based on topics, such as in a traffic simulation system.

[0107] Based on the embodiments provided in this application, the above... Figures 1-3 The data structures for the message queue and message body are shown, and the methods for inter-process communication are as follows: Figure 4 As shown, Figure 4 This is a flowchart illustrating an inter-process communication method provided in an embodiment of this application. The method of this embodiment includes:

[0108] S41: Parse the message queue head and obtain pointer information.

[0109] The message queue is established in a shared memory space, and its data structure is as follows: Figure 1 As shown, when a process needs to read or write a message, it first parses the message queue head to obtain pointer information.

[0110] S43: Read or write the message body from the message storage area based on pointer information.

[0111] Based on pointer information, it can be determined whether there are any message updates in the message queue; or, based on pointer information, the end position of the updated message in the message queue can be determined; or, based on pointer information, the start position of the written message in the message queue can be determined, and so on. Therefore, when a process needs to read or write the message body, it reads or writes the message body from the message storage area based on the pointer information.

[0112] In this embodiment, by establishing the message queue in the shared memory space and defining the data structure of the message queue, processes can obtain pointer information by parsing the queue head, and read or write the message body from the message storage area based on the pointer information. This combines the efficient access characteristics of shared memory with the high scalability and decoupling advantages of message queues, thereby improving the efficiency of inter-process communication. Furthermore, by utilizing the asynchronous characteristics of message queues, the concurrency of inter-process communication is improved.

[0113] Inter-process communication typically involves message writing and reading processes. The following describes the writing and reading processes of a message queue built on shared memory.

[0114] During the writing and reading processes, it may be necessary to obtain the write start pointer and / or write end pointer from the queue head. The process itself will also record the write start pointer and / or write end pointer locally. For ease of description, in the following embodiments of this application, the write start pointer stored in the queue head is described as the first write start pointer, and the write end pointer is described as the first write end pointer; the write start pointer recorded locally by the process is described as the second write start pointer, and the write end pointer is described as the second write end pointer.

[0115] During the write process, the positions indicated by the first write start pointer and the first write end pointer are updated. For ease of description, the position indicated by the first write start pointer before the write process begins is described as the initial position of the first write start pointer, and the position indicated by the first write end pointer is described as the initial position of the first write end pointer. During the write process, the end position of the write is determined based on the size of the message to be written. The initial positions of the first write end pointer and the first write start pointer are updated based on the end position of the write.

[0116] under Figures 5 to 8 The present application describes different embodiments of the message writing process provided in the embodiments.

[0117] Figure 5 This is a schematic diagram illustrating a message writing process provided in an embodiment of this application. Figure 5 Is Figure 4 Based on the example shown, the following describes one possible implementation of S43, such as... Figure 5 As shown, the process of this embodiment is as follows:

[0118] S431: Based on the size of the message to be written, modify the initial position of the first write end pointer to the end position.

[0119] The difference between the end position and the initial position is equal to the size of the message to be written.

[0120] When a process needs to write a message, it determines the amount of memory space required based on the size of the message to be written. Then, based on the required amount of memory space, it determines the end position of the write and modifies the initial position of the first write end pointer to the end position.

[0121] For example, if the initial position of the first write end pointer is 0x1000 and the size of the message to be written is 200 bytes, based on the initial position of the first write pointer and the size of the message to be written, the end position can be determined to be 0x1000 plus 200 bytes, i.e., 0x1140. Then, the initial position of the first write end pointer is shifted 200 bytes backward, i.e., updated from 0x1000 to 0x1140.

[0122] S433: Start writing the message to be written from the initial position of the first write start pointer until the message to be written is completed, then update the initial position of the first write start pointer to the end position of the message to be written.

[0123] Based on the previous example, assuming the initial position of the first write start pointer is 0x1000 and the size of the message to be written is 200 bytes, then the process will start writing the message from the shared memory address 0x1000 until all 200 bytes of data in the message to be written are written. The end position of the message to be written is 0x1140. The initial position of the first write start pointer is then updated to the end position of the message to be written, which is 0x1140. In other words, the initial position of the first write start pointer is updated from 0x1000 to 0x1140.

[0124] In this embodiment, the initial position of the first write end pointer is modified to the end position according to the size of the message to be written. The message to be written starts from the initial position of the first write pointer and continues until the message to be written is completed. Then, the initial position of the first write start pointer is updated to the end position of the message to be written. In this way, the message writing process based on the shared memory message queue is completed, and the efficiency of message writing is improved.

[0125] In this application embodiment, inter-process communication based on shared memory message queues suffers from concurrency issues. To ensure the validity of data written and read, this application embodiment can implement concurrency control through, but is not limited to, the following possible implementation methods: for example, using read-write locks, sequence locks, spin locks, or mutexes to ensure the validity of written and read data. The following description uses the use of mutexes for concurrency control during the write process as an example to illustrate the technical solution of this application embodiment. Figure 6 As shown, Figure 6 Is Figure 5 Based on the illustrated embodiment, further, before S41, it may include: S410, and after S433, it may also include: S44.

[0126] S410: Acquire the mutex lock.

[0127] When a process wants to write a message, it first acquires a mutex lock. Once a process acquires the mutex lock, no other process can perform a write operation until that process releases the mutex lock, thus ensuring data consistency during the write process. After a process acquires the mutex lock, other processes attempting to acquire the same mutex lock will be blocked or suspended until the acquiring process completes its write operation and releases the mutex lock.

[0128] After the process successfully acquires the mutex lock, it begins writing the data to be written. After the data writing is completed, S44 is executed.

[0129] S44: Release the mutex.

[0130] Once the process finishes writing data, it releases the mutex lock, meaning that other processes waiting to acquire the mutex lock, or those subsequently requesting to acquire it, will have the opportunity to acquire the mutex lock and begin writing operations.

[0131] In this embodiment, the process acquires a mutex lock before starting to write data and releases the mutex lock after writing data, thereby ensuring data consistency during the writing process.

[0132] In some cases, write exceptions may occur, potentially causing the initial positions of the first write start pointer and the first write end pointer to be inconsistent. A write exception indicates that the previously written data is invalid, and it's necessary to ignore or overwrite it. Therefore, it's crucial to ensure that the initial positions of the first write start pointer and the first write end pointer are the same before starting the write process. Figure 7 As shown, Figure 7 Is Figure 6 Based on the illustrated embodiment, further, prior to S431, it also includes:

[0133] S4301: Determine whether the initial position of the first write start pointer and the initial position of the first write end pointer are the same. If it is determined that the initial position of the first write start pointer and the initial position of the first write end pointer are the same, execute S431. If it is determined that the initial position of the first write start pointer and the initial position of the first write end pointer are not the same, execute S4302.

[0134] S4302: Set the initial position of the first write start pointer and the initial position of the first write end pointer to be the same.

[0135] Optionally, one implementation is to update the initial position of the first write start pointer to the initial position of the first write end pointer.

[0136] For example, if the initial position of the first write start pointer is 0x1000 and the initial position of the first write end pointer is 0x1100, then the initial position of the first write start pointer will be updated from 0x1000 to 0x1100.

[0137] Another implementation is to update the initial position of the first end-of-write pointer to the initial position of the first start-of-write pointer.

[0138] Combining the previous example, update the initial position of the first end-of-write pointer from 0x1100 to 0x1000.

[0139] In this embodiment, by setting the initial position of the first write start pointer and the initial position of the first write end pointer to be the same before writing begins, the write data anomaly caused by the previous write data anomaly is avoided.

[0140] In some cases, the size of messages to be written by certain processes may be too large, exceeding the size of the message storage area. This can lead to incomplete message writing, where the first message written is overwritten by later messages. To avoid this, in this embodiment, S4303 is executed before writing the message. Figure 8 As shown:

[0141] S4303: Determine whether the size of the message to be written is less than or equal to the size of the message storage area.

[0142] If it is determined that the size of the message to be written is less than or equal to the size of the message storage area, then execute S431; if it is determined that the size of the message to be written is greater than the size of the storage area, then execute S4304.

[0143] S4304: Outputs error information.

[0144] In this embodiment, by determining whether the size of the message to be written is less than or equal to the size of the message storage area before writing the message, the write operation is determined, thereby avoiding the situation where the message is not fully written due to the message being too large, and thus ensuring the validity of the message writing.

[0145] under Figures 9 to 15 The present application describes different embodiments of the message reading process provided in the embodiments.

[0146] Figure 9 This is a schematic diagram illustrating a message reading process provided in an embodiment of this application. Figure 9 Is Figure 4 Based on the example shown, another possible implementation of S43 is described, as follows: Figure 9 As shown, the process of this embodiment is as follows:

[0147] S531: Start reading the message body from the initial position of the second end-of-write pointer until the reading ends at the initial position of the first end-of-write pointer.

[0148] The initial position of the second write end pointer is the same as the initial position of the first write end pointer from the previous read.

[0149] After each message read, the process locally records the initial position of the first write end pointer and the initial position of the first write start pointer. Starting from the initial position of the second write end pointer, the message header of the message body is parsed to obtain the length information of the payload in the message header; the payload is then read based on the length information of the payload until the reading ends at the initial position of the first write end pointer.

[0150] For example, suppose a process recorded the initial position of the first write end pointer as memory address 0x1000 in a previous read operation, and this is the end position of the last message read. In the next message read, the process will use this address as the initial position of the second write end pointer. The process begins parsing the message body from address 0x1000, first reading the message header to obtain the payload length information. Once the payload length is obtained, the process starts reading data from the current position according to the payload length, until it reaches the initial position of the first write end pointer in this read operation, let's say memory address 0x1500. In this way, the process completes reading the entire message body from the end position of the previous message to the end position of the current message.

[0151] In this embodiment, the message body is read from the initial position of the second write end pointer and the initial position of the first write end pointer, and the reading continues until the initial position of the first write end pointer is reached, thereby realizing the message queue read operation based on shared memory.

[0152] The technical solution provided in this application supports parallel read and write operations. Therefore, it's possible that during the read process, other processes are performing write operations, which could potentially overwrite the data being read. Therefore, to ensure the validity of read messages, this application embodiment... Figure 9 Based on the illustrated embodiment, further, after the reading is completed, the method further includes: executing S533, as shown in the example. Figure 10 As shown:

[0153] S533: Obtain the initial position of the first write end pointer from the head of the queue, and determine whether the initial position of the first write end pointer exceeds the boundary of the read messages. If it is determined that the initial position of the first write end pointer exceeds the boundary of the read messages, then execute S535; if it is determined that the initial position of the first write end pointer does not exceed the boundary of the read messages, then the process ends.

[0154] For example, suppose the message storage area is 4,000 bytes in size. At a certain moment, the process records the initial position of the second write start pointer as memory address 0x3000. Later, due to frequent write operations, the initial position of the first write start pointer is updated to 0x5000. At this point, the difference between the two pointers is 2,000 bytes, which is less than the size of the message storage area. Therefore, the process can safely read messages from the initial position of the second write start pointer (0x3000) until the current position of the first write start pointer (0x5000).

[0155] However, if additional write operations occur during this process, causing the initial position of the first write start pointer to be further updated to 0x8000, the difference between the two pointers becomes 5,000 bytes, exceeding the size of the message storage area. In this case, since the message storage area is designed as a circular buffer, some of the earliest messages may have already been overwritten by newly written messages. Therefore, message data starting from the initial position of the second write start pointer (0x3000) will no longer be valid. Consequently, the initial position of the first write end pointer retrieved from the queue head will be 0x8000, exceeding the boundary of read messages, meaning the read messages have become invalid data.

[0156] S535: Discard read data.

[0157] If it is determined that the initial position of the first end-of-write pointer exceeds the boundary of the read message, the data content read by the current read operation may have been overwritten by the write operation. Therefore, the read data content is invalid.

[0158] In this embodiment, the validity of the read message is ensured by obtaining the initial position of the first write end pointer from the head of the queue and determining that the position of the first write end pointer does not exceed the boundary of the read message.

[0159] Figure 11 This is a schematic diagram illustrating another message reading process provided in an embodiment of this application. Figure 11 Is Figure 10 Based on the illustrated embodiment, further, before reading the message, it also includes: determining whether there are message updates in the message queue, wherein one possible implementation is as follows: Figure 11 As shown, before executing S531, the process also includes executing S530:

[0160] S530: If the initial position of the second write start pointer is determined to be inconsistent with the initial position of the first write start pointer, then it is determined that there is a message update.

[0161] Since each write operation updates the initial position of the first write start pointer, it is possible to determine whether there is a message update based on whether the initial positions of the first and second write start pointers are the same.

[0162] For example, in a specific implementation scenario, the process first checks the initial position of the current second write start pointer, which is recorded by the process after the last read operation. If this position is different from the initial position of the current first write start pointer, it means that new messages have been written to the message queue since the last read. This approach allows the process to quickly determine whether new messages have arrived between two read operations without additional polling or waiting. If the two pointer positions are the same, it can be assumed that no new messages have arrived since the last check, and the process can choose not to perform a read operation, thereby saving resources and improving efficiency.

[0163] For example, at a certain point in time, after a process completes a read operation, it records the initial position of the second write start pointer as memory address 0x2000. Before the next read operation, the process checks the initial position of the first write start pointer and finds that it has moved to a new memory address 0x2500. This change indicates that new messages have been written between these two addresses. Therefore, the process will start reading from the initial position of the second write start pointer 0x2000 to the new position 0x2500, retrieving all messages that arrived during this period.

[0164] In this embodiment, by determining that the initial position of the second write start pointer is inconsistent with the initial position of the first write start pointer, it is determined that there is a message update. This ensures the efficiency and timeliness of the message reading operation, enabling the process to be prepared to know that a new message has arrived and process it in a timely manner.

[0165] Since each message includes a message header, and the message header size is fixed, for example, 12 bytes, if the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is less than the length of the message header in the message body, then the written message is invalid. To avoid reading such invalid data, after executing S530, S5301 is further executed, such as... Figure 12 As shown:

[0166] S5301: Determine that the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is greater than or equal to the length of the message header of the message body.

[0167] If the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is greater than or equal to the length of the message header of the message body, then execute S531; if the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is equal to the length of the message header of the message body, it indicates that there is no valid message update in the message queue, then return to S530.

[0168] In this embodiment, the validity of the updated data is determined by whether the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is greater than or equal to the length of the message header of the message body, so as to avoid unnecessary reading processes and resource waste.

[0169] In some cases, the difference between the initial position of the first write start pointer and the initial position of the second write start pointer may be greater than the size of the message storage area. This situation may occur when messages are not read in a timely manner. For example, after the last read, two or more write operations have occurred, and the total size of the written data has exceeded the size of the message storage area. Therefore, before reading the data, the process further includes: S5302:

[0170] S5302: Determine that the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is less than or equal to the size of the message storage area.

[0171] If the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is less than or equal to the size of the message storage area, then data can be read. If the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is not less than or equal to the size of the message storage area, it means that the total size of the written data has exceeded the size of the message storage area, therefore, the message is invalid.

[0172] For example, suppose the message storage area is 4,000 bytes in size. At some point, the process records the initial position of the second write start pointer as memory address 0x3000. Subsequently, due to frequent write operations, the initial position of the first write start pointer is updated to 0x5000. At this point, the difference between the two pointers is 2,000 bytes, less than the size of the message storage area. However, before the message reading process can perform its current read, additional write operations occur, causing the initial position of the first write start pointer to be further updated to 0x8000. Now, the difference between the two pointers becomes 5,000 bytes, exceeding the size of the message storage area. In this situation, because the message storage area is designed as a circular buffer, some of the earliest messages may have already been overwritten by newly written messages. Therefore, message data starting from the initial position of the second write start pointer (0x3000) will no longer be valid.

[0173] This embodiment determines whether data can be read from the position of the second write start pointer by comparing the difference between the first write start pointer and the second write start pointer with the size of the message storage area. If the difference is within the allowable range, it means that the message between that position and the position of the first write start pointer is complete and valid. If the difference exceeds the size of the message storage area, it means that data overwriting has occurred and the data is invalid.

[0174] Optionally, to ensure the validity of the read message, the correctness of the message header is also determined based on the checksum in the message header before reading the message.

[0175] The inter-process communication mechanism based on shared memory message queues in this application embodiment can be applied to a publish-subscribe pattern, which includes publishers and subscribers, wherein publishers are responsible for sending messages, and subscribers subscribe to message topics of interest.

[0176] In the publish-subscribe pattern, messages are not sent directly to specific recipients, but are published to a topic. A topic is an identifier or label used to categorize messages.

[0177] Publishers are the entities that send messages. They publish messages to specific topics without knowing which subscribers will receive them. Publishers focus solely on generating and publishing messages. Subscribers are the entities that receive messages. They express interest in messages on one or more topics by subscribing to them. When messages are published to these topics, subscribers are notified and process them as needed. When a subscriber receives a message that matches a topic, it executes the associated delegate. The delegate is a callback function defined by the subscriber to handle the received message. When a subscriber subscribes to a topic, it sets a corresponding delegate based on the subscribed topic. When a topic match is successful, the corresponding delegate is executed to notify the subscriber.

[0178] In the message queue established based on shared memory in this application embodiment, each topic corresponds to a message queue. The publisher writes the message to the queue of the corresponding topic, and the subscriber reads the message from the corresponding queue.

[0179] The following describes the message reading process applied in the publish-subscribe pattern using a specific example:

[0180] Figure 13 This application provides another flowchart illustrating message reading, as shown in the embodiment. Figure 13 As shown, Figure 13 Is Figure 12 As shown, based on a reasonable premise, prior to S531, it also includes:

[0181] S5303: Parse the message header of the message body to obtain the length information of the topic identifier in the message header.

[0182] The message header of this application includes the length information of the topic identifier. Therefore, after parsing the message header of the message body, the length information of the topic identifier can be obtained at the corresponding position.

[0183] S5304: Based on the length information of the topic identifier, obtain the topic identifier corresponding to the message body.

[0184] Based on the length information of the topic identifier, determine the specific byte range of the topic identifier in the message body, and obtain the identifier of the topic corresponding to the message body.

[0185] S5305: Determine that the topic identifier matches the subscription list.

[0186] If the topic identifier matches the subscription list, it means that a corresponding subscriber has subscribed to the topic, so the message reading step continues. If the topic identifier does not match the subscription list, it means that no corresponding subscriber has subscribed to the topic, so there is no need to continue the message reading step.

[0187] In this embodiment, the length information of the topic identifier in the message header is obtained by parsing the message body. Based on the length information of the topic identifier, the topic identifier corresponding to the message body is obtained. If the topic identifier matches the subscription list, the message reading step continues. If the topic identifier does not match the subscription list, it means that no corresponding subscriber has subscribed to the topic, and there is no need to continue the reading step. Thus, the inter-process communication method provided in this embodiment can be applied to the publish-subscribe model.

[0188] Figure 14 This is a schematic diagram illustrating another message reading process provided in an embodiment of this application. Figure 14 Is Figure 13 Based on the illustrated embodiment, further, before S5303, it also includes:

[0189] S53030: Confirm that there are subscribers recorded in the subscription list.

[0190] The subscription list contains registered subscribers and the topics they are interested in. If there is a value in the subscription list, it means there are subscribers. If there is no value in the subscription list, it means there are no subscribers interested in the topic, and there is no need to continue reading messages.

[0191] In this embodiment, by determining whether there are subscribers in the subscription list, it is possible to determine early whether it is necessary to read messages in the message queue, thereby avoiding resource waste.

[0192] Figure 15 This is a schematic diagram illustrating another message reading process provided in an embodiment of this application. Figure 15 Is Figure 14 Based on the illustrated embodiment, further, before S41, S50 is included:

[0193] S50: Confirm that the cancellation token is valid.

[0194] A cancellation token is a mechanism used to control whether a message read operation should continue. A valid cancellation token means that the current message read operation is still authorized and should continue. An invalid cancellation token means that external conditions or the user have instructed the operation to stop or cancel.

[0195] In this embodiment, by checking the status of the cancellation token at the beginning of the message reading process, the message processing flow can be flexibly controlled. If the cancellation token is valid, the system will continue to execute subsequent message reading steps; if the cancellation token is invalid, the system will stop further message reading and processing.

[0196] The communication method provided in this application embodiment can support asynchronous communication. After the sender sends a message, it does not need to wait for the receiver's response and can continue to perform other operations. That is, the sender does not need to be blocked because of waiting for the receiver's message confirmation. Asynchronous communication can improve the system's concurrency and response speed.

[0197] In this embodiment, asynchronous communication is achieved by establishing a message queue in shared memory. The sender writes messages to the message queue in shared memory, and the receiver asynchronously reads messages from the message queue when ready, thereby improving transmission efficiency. Furthermore, using an asynchronous communication mechanism avoids blocking the main thread, thus improving the smoothness of system operation.

[0198] The communication method provided in this application embodiment is applicable to scenarios with high concurrency and high transmission efficiency, such as IoT device communication, real-time monitoring systems, and traffic simulation systems.

[0199] This application also provides a communication system comprising an edge computing device configured with message queues and / or topics for publishers and subscribers to communicate based on message queues and / or topics. Specifically, the communication system includes a sender and a receiver. After acquiring data, the sender serializes the data using a serialization component. The serialization component can serialize the data using a serialization method agreed upon with the receiver. Serialization methods include, but are not limited to, JSON (JavaScript Object Notation), MemoryPack, MessagePack, and BufferOwner. Then, a corresponding message channel is selected for the serialized message. The message channel type includes: a shared memory-based message queue channel. The selection of a shared memory-based message queue channel uses the aforementioned... Figures 1-15 The communication method shown is as follows: The receiving end determines the channel type for receiving data, parses the data in the channel, obtains the topic identifier, and performs subscription matching for the topic identifier through the subscription manager. The subscription manager maintains a subscription list containing registered subscribers and their topics of interest. The data is deserialized through a serialization component in a manner agreed upon with the sending end. Then, the corresponding delegate is executed, that is, the callback function or processing logic provided by the subscriber matched in the subscription manager when registering the subscription is executed.

[0200] Figure 16 This application provides a schematic diagram of the structure of a communication device, as shown in the embodiment. Figure 16As shown, the apparatus of this embodiment includes: a parsing module 1601, used to parse the queue head of the message queue and obtain pointer information, wherein the message queue is established in a shared memory space, the message queue includes: a queue head and a message storage area, the queue head includes: the pointer information, and the message storage area is used to store the message body;

[0201] The processing module 1602 is used to read or write the message body from the message storage area based on the pointer information.

[0202] Optionally, the pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer;

[0203] The processing module 1602 is specifically used to modify the initial position of the first write end pointer to the end position according to the size of the message to be written, wherein the difference between the end position and the initial position is equal to the size of the message to be written; to start writing the message to be written from the initial position of the first write start pointer until the message to be written is completed, and then update the initial position of the first write start pointer to the end position of the message to be written.

[0204] Optionally, the processing module 1602 is further configured to acquire a mutex lock and release the mutex lock.

[0205] Optionally, the processing module 1602 is further configured to determine that the initial position of the first write start pointer is the same as the initial position of the first write end pointer.

[0206] Optionally, the processing module 1602 is further configured to set the initial position of the first write start pointer and the initial position of the first write end pointer to be the same if the initial position of the first write start pointer and the initial position of the first write end pointer are not the same.

[0207] Optionally, the processing module 1602 is specifically used to update the initial position of the first write start pointer to the initial position of the first write end pointer, or to update the initial position of the first write end pointer to the initial position of the first write start pointer.

[0208] Optionally, the processing module 1602 is further configured to determine that the size of the message to be written is less than or equal to the size of the message storage area.

[0209] Optionally, the pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer;

[0210] The processing module 1602 is specifically used to read the message body from the initial position of the second write end pointer until the reading ends at the initial position of the first write end pointer. The initial position of the second write end pointer is the initial position of the first write end pointer in the previous reading.

[0211] Optionally, the processing module 1602 is further configured to obtain the initial position of the first write end pointer from the queue head, and determine that the initial position of the first write end pointer does not exceed the boundary of the read message; and / or, if the initial position of the first write end pointer is obtained from the queue head and it is determined that the initial position of the first write end pointer exceeds the boundary of the read message, then the read message is discarded.

[0212] Optionally, the processing module 1602 is further configured to determine that if the initial position of the second write start pointer is inconsistent with the initial position of the first write start pointer, then a message update is determined.

[0213] Optionally, the data structure of the message body includes a message header and a payload portion, wherein the message header includes the length information of the payload; the processing module 1602 is further configured to determine that the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is greater than or equal to the length of the message header of the message body.

[0214] Optionally, the processing module 1602 is further configured to determine that the difference between the initial position of the first write start pointer and the initial position of the second write start pointer is less than or equal to the size of the message storage area.

[0215] Optionally, the processing module 1602 is specifically used to parse the message header of the message body from the initial position of the second write end pointer, obtain the length information of the payload in the message header, and read the payload based on the length information of the payload until the reading ends at the initial position of the first write end pointer.

[0216] Optionally, the data structure of the message body further includes: a topic identifier part; the message header further includes: the length information of the topic identifier; the processing module 1602 is further used to parse the message header of the message body, obtain the length information of the topic identifier in the message header; obtain the topic corresponding to the message body based on the length information of the topic identifier; and determine that the topic matches the subscription list.

[0217] Optionally, the processing module 1602 is specifically used to perform matching based on the matching weight in the order of full matching, parameter matching and wildcard matching until a match is successful.

[0218] Optionally, the processing module 1602 is specifically used to determine that there are subscribers recorded in the subscription list.

[0219] Optionally, the processing module 1602 is further configured to determine that the message header is correct.

[0220] Optionally, the processing module 1602 is also used to determine that the cancellation token is valid.

[0221] Optionally, the processing module 1602 is further configured to request a shared memory space and establish a message queue in the shared memory space, the message queue including a queue head and a storage area.

[0222] The device in this embodiment corresponds to the technical solutions that can be used to execute the above-described method embodiments. Its implementation principle and technical effects are similar, and will not be repeated here.

[0223] This application embodiment also provides an edge computing device, including a processor and a memory, wherein the memory stores programs or instructions that can run on the processor, and the programs or instructions, when executed by the processor, implement the above-described functionality. Figures 1-15 The steps of the communication method described in the illustrated embodiment.

[0224] This application also provides a communication system including the edge computing device described above, wherein the edge computing device is configured with message queues and / or topics for publishers and subscribers to communicate based on the message queues and / or topics.

[0225] This application embodiment also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a program or instructions, which, when executed by a processor, implement the above-described functionality. Figures 1-15 The steps of the communication method described in the illustrated embodiment.

[0226] This application also provides a computer program product, which, when executed by a processor, implements the above-described functionality. Figures 1-15 The steps of the communication method described in the illustrated embodiment.

[0227] The following is a detailed reference. Figure 17 The diagram illustrates a suitable structural schematic for implementing the edge computing device 700 in the embodiments of this application. The edge computing device 700 in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. The illustrated edge computing device is merely an example and should not impose any limitations on the functionality or scope of the embodiments of this application.

[0228] like Figure X As shown, the edge computing device 700 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the edge computing device 700. The processing unit 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0229] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 708 including, for example, magnetic tapes, hard disks, etc.; and communication devices 709. Communication device 709 allows edge computing device 700 to communicate wirelessly or wiredly with other devices to exchange data. Although an edge computing device 700 with various devices is shown, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0230] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 709, or installed from storage device 708, or installed from ROM 702. When the computer program is executed by processing device 701, it performs the functions defined in the MES management method of embodiments of this application.

[0231] It should be noted that the computer-readable medium described above in this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0232] In some implementations, the user and management terminals can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0233] The aforementioned computer-readable medium may be included in the aforementioned edge computing device; or it may exist independently and not assembled into the edge computing device.

[0234] The aforementioned computer-readable medium carries one or more programs that, when executed by the edge computing device, cause the edge computing device to:

[0235] Parse the queue head of the message queue to obtain pointer information. The message queue is established in a shared memory space and includes a queue head and a message storage area. The queue head includes the pointer information, and the message storage area is used to store the message body.

[0236] Based on the pointer information, the message body is read from or written to the message storage area.

[0237] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof. These programming languages ​​include, but are not limited to, object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0238] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0239] The units described in the embodiments of this application can be implemented in software or hardware. The names of the units are not, in some cases, limiting the scope of the unit itself.

[0240] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0241] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0242] According to one or more embodiments of this application, this application provides a computer-readable storage medium storing a computer program for performing any of the MES management methods described in the embodiments of this application.

[0243] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.

[0244] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. Multitasking and parallel processing may be advantageous in certain environments. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this application. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0245] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A communication method, characterized in that, include: Parse the queue head of the message queue to obtain pointer information. The message queue is established in a shared memory space and includes a queue head and a message storage area. The queue head includes the pointer information, and the message storage area is used to store the message body. Based on the pointer information, the message body is read from or written to the message storage area.

2. The method according to claim 1, wherein the pointer information includes: The initial position of the first write start pointer and the initial position of the first write end pointer; The step of reading or writing the message body from the message storage area based on the pointer information includes: Based on the size of the message to be written, the initial position of the first write end pointer is modified to the end position, and the difference between the end position and the initial position is equal to the size of the message to be written; The message to be written begins to be written from the initial position of the first write start pointer until the message to be written is completed, at which point the initial position of the first write start pointer is updated to the end position of the message to be written.

3. The method according to claim 2, characterized in that, Before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes: Acquire the mutex lock; After writing the message to be written from the initial position of the first write start pointer until the message to be written is completed, and updating the initial position of the first write start pointer to the end position of the message to be written, the method further includes: Release the mutex.

4. The method according to claim 3, characterized in that, Before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes: The initial position of the first write start pointer is determined to be the same as the initial position of the first write end pointer.

5. The method according to claim 3, characterized in that, Before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes: If the initial position of the first write start pointer is not the same as the initial position of the first write end pointer, then the initial position of the first write start pointer and the initial position of the first write end pointer are set to be the same.

6. The method according to claim 5, characterized in that, Setting the initial position of the first write start pointer and the initial position of the first write end pointer to be the same includes: Update the initial position of the first write start pointer to the initial position of the first write end pointer, or update the initial position of the first write end pointer to the initial position of the first write start pointer.

7. The method according to any one of claims 2-6, characterized in that, Before modifying the initial position of the first write end pointer to the end position according to the size of the message to be written, the method further includes: The size of the message to be written is determined to be less than or equal to the size of the message storage area.

8. The method according to claim 2, characterized in that, The pointer information includes: the initial position of the first write start pointer and the initial position of the first write end pointer; The step of reading or writing the message body from the message storage area based on the pointer information includes: The message body is read from the initial position of the second end-of-write pointer until the reading ends at the initial position of the first end-of-write pointer. The initial position of the second end-of-write pointer is the same as the initial position of the first end-of-write pointer in the previous reading.

9. The method according to claim 8, characterized in that, The process of reading until the initial position of the first end-of-write pointer is reached also includes: Obtain the initial position of the first write end pointer from the head of the queue, and determine that the initial position of the first write end pointer does not exceed the boundary of the read messages; and / or, obtain the initial position of the first write end pointer from the head of the queue, and determine that the initial position of the first write end pointer exceeds the boundary of the read messages, then discard the read messages.

10. The method according to claim 8, characterized in that, The step of reading the message body from the initial position of the second write end pointer until the reading from the initial position of the first write end pointer also includes: If the initial position of the second write start pointer is not the same as the initial position of the first write start pointer, then it is determined that there is a message update.

11. The method according to claim 10, characterized in that, The data structure of the message body includes a message header and a payload portion, wherein the message header includes the length information of the payload; the process of reading the message body from the initial position of the second write end pointer until the reading ends at the initial position of the first write end pointer also includes: The difference between the initial position of the first write start pointer and the initial position of the second write start pointer is determined to be greater than or equal to the length of the message header of the message body.

12. The method according to claim 11, characterized in that, Also includes: The difference between the initial position of the first write start pointer and the initial position of the second write start pointer is determined to be less than or equal to the size of the message storage area.

13. The method according to any one of claims 8-12, characterized in that, The step of reading the message body from the initial position of the second write end pointer until the reading ends at the initial position of the first write end pointer includes: Starting from the initial position of the second end-of-write pointer, parse the message header of the message body to obtain the length information of the payload in the message header; The payload is read based on its length information until the reading ends at the initial position of the first write end pointer.

14. The method according to claim 1, characterized in that, The data structure of the message body also includes: a topic identifier portion; the message header also includes: the length information of the topic identifier; before reading or writing the message body from the message storage area based on the pointer information, the process further includes: Parse the message header of the message body to obtain the length information of the topic identifier in the message header; Based on the length information of the topic identifier, the topic corresponding to the message body is obtained; Determine if the topic matches the subscription list.

15. The method according to claim 14, characterized in that, Determining that the topic matches the subscription list includes: Based on the matching weights, the matching is performed sequentially in the order of full matching, parameter matching, and wildcard matching until a match is successful.

16. The method according to claim 15, characterized in that, Before parsing the message header of the message body and obtaining the length information of the topic identifier in the message header, the method further includes: Confirm that the subscribers are recorded in the subscription list.

17. A communication device, characterized in that, include: The parsing module is used to parse the queue head of the message queue and obtain pointer information. The message queue is established in a shared memory space and includes a queue head and a message storage area. The queue head includes the pointer information, and the message storage area is used to store the message body. The processing module is used to read or write the message body from the message storage area based on the pointer information.

18. An edge computing device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the communication method as described in any one of claims 1 to 17.

19. A communication system, characterized in that, Includes the edge computing device as described in claim 18, wherein the edge computing device is configured with message queues and / or topics for publishers and subscribers to communicate based on the message queues and / or topics.

20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the communication method as described in any one of claims 1 to 17.