Movatterモバイル変換


[0]ホーム

URL:


CN120371570A - Inter-process communication method and device - Google Patents

Inter-process communication method and device

Info

Publication number
CN120371570A
CN120371570ACN202510866914.4ACN202510866914ACN120371570ACN 120371570 ACN120371570 ACN 120371570ACN 202510866914 ACN202510866914 ACN 202510866914ACN 120371570 ACN120371570 ACN 120371570A
Authority
CN
China
Prior art keywords
message
target
message structure
structure body
message queue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510866914.4A
Other languages
Chinese (zh)
Inventor
田伟昊
李彦
苏夕庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huahuan Electronics Co Ltd
Original Assignee
Beijing Huahuan Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Huahuan Electronics Co LtdfiledCriticalBeijing Huahuan Electronics Co Ltd
Priority to CN202510866914.4ApriorityCriticalpatent/CN120371570A/en
Publication of CN120371570ApublicationCriticalpatent/CN120371570A/en
Pendinglegal-statusCriticalCurrent

Links

Landscapes

Abstract

Translated fromChinese

本说明书实施例公开了一种进程间通信方法及装置,包括:对任一进程,在该进程建立进程列表;其中,进程列表是根据目标设备的进程信息生成的;创建与该进程对应的接收消息队列,并将接收消息队列扩展到该进程的所述进程列表中;该进程需要与目标进程通信时,根据需要目标进程执行的任务生成消息结构体,将所述消息结构体发送到目标进程对应的接收消息队列,以使所述目标进程根据所述接收消息队列执行所述任务;其中,所述目标进程根据所述接收消息队列执行所述任务包括:根据所述接收消息队列确定需要处理的消息结构体,根据所述需要处理的消息结构体确定需要执行的目标操作以及从共享内存中确定需要操作的数据,并对所述数据执行所述目标操作。

The embodiments of the present specification disclose an inter-process communication method and device, including: for any process, establishing a process list in the process; wherein the process list is generated according to the process information of the target device; creating a receive message queue corresponding to the process, and extending the receive message queue to the process list of the process; when the process needs to communicate with the target process, generating a message structure according to the task that the target process needs to perform, and sending the message structure to the receive message queue corresponding to the target process, so that the target process performs the task according to the receive message queue; wherein the target process performs the task according to the receive message queue, including: determining a message structure to be processed according to the receive message queue, determining a target operation to be performed according to the message structure to be processed, and determining data to be operated from a shared memory, and performing the target operation on the data.

Description

Inter-process communication method and device
Technical Field
The present application relates to the field of process communication technologies, and in particular, to an inter-process communication method and apparatus.
Background
In embedded related systems, there are scenarios of inter-process communication. The IPC communication modes include modes of signals, pipelines, semaphores, shared memory, (inter-process) queues, SOCKET and the like, and the communication modes have respective defects in the process of realizing inter-process communication. For example, the shared memory mode has high speed, but does not have a synchronous and asynchronous mechanism, can not ensure the correctness of data when a plurality of processes are used, the message queue mode has no problem of reading sequence, but consumes additional CPU resources when the processes are more, influences efficiency, has low transmission efficiency when the data volume is large, and occupies additional memory, and in the prior art, netconf southbound control processes need to acquire a large amount of data from other processes and perform inter-process communication at high frequency, so that a large amount of resources are required to be consumed.
Disclosure of Invention
The embodiment of the specification provides an inter-process communication method and device, which are used for solving the technical problem of how to improve the inter-process communication effect and efficiency.
In order to solve the technical problems, the embodiment of the specification provides the following technical scheme:
the embodiment of the specification provides an inter-process communication method, which comprises the following steps:
For any process, establishing a process list in the process, wherein the process list is generated according to the process information of the target equipment;
Creating a received message queue corresponding to the process, and expanding the received message queue into the process list of the process;
When the process needs to communicate with a target process, generating a message structure body according to a task executed by the target process, and sending the message structure body to a receiving message queue corresponding to the target process so that the target process executes the task according to the receiving message queue;
wherein the target process executing the task according to the received message queue comprises:
And determining a message structure body to be processed according to the received message queue, determining a target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
Optionally, before generating the message structure according to the task executed by the target process, the method further includes:
the process is linked to a shared memory common to all processes.
Optionally, before sending the message structure body to a received message queue corresponding to the target process, the method further includes:
And placing the data which needs to be processed by the target process into a shared memory, wherein the message structure body comprises positioning information of the data in the shared memory.
Optionally, the method further comprises:
Determining a sending interface of the message structure body according to whether the target process is required to return a response message;
And/or the number of the groups of groups,
Determining whether the message structure body reaches a received message queue corresponding to the target process in a stipulated time;
If not, the message structure body is sent to the message receiving queue corresponding to the target process again.
The embodiment of the specification provides another inter-process communication method, which comprises the following steps:
For any process, establishing a process list in the process, wherein the process list is generated according to the process information of the target equipment;
creating a received message queue corresponding to the process, and expanding the received message queue into the process list of the process, wherein the received message queue is used for queuing message structures sent by other processes;
And determining a message structure body to be processed according to the received message queue, determining a target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
Optionally, the method further comprises:
after receiving the message structure, the maximum sequence identifier of the message structure which is not processed at present is checked, and then the next sequence identifier is given to the newly received message structure.
Optionally, determining a message structure body to be processed according to the received message queue includes:
Taking a message structure body corresponding to a first sequence identifier in a current received message queue as a message structure body to be processed;
And updating the received message queue after processing one message structure body, and continuing to use the message structure body corresponding to the first sequence identifier in the updated received message queue as the message structure body to be processed.
Optionally, the method further comprises:
and starting a receiving message thread corresponding to the process, wherein the receiving message thread is used for receiving message structures sent by other processes and storing the message structures into a receiving message queue of the process.
An embodiment of the present specification provides an inter-process communication apparatus, the apparatus including:
The system comprises a first communication preparation module, a first communication preparation module and a second communication preparation module, wherein the first communication preparation module is used for establishing a process list for any process, creating a received message queue corresponding to the process, and expanding the received message queue into the process list of the process;
The first communication execution module is used for generating a message structure body according to a task executed by the target process when the process needs to communicate with the target process, and sending the message structure body to a receiving message queue corresponding to the target process so that the target process executes the task according to the receiving message queue;
wherein the target process executing the task according to the received message queue comprises:
And determining a message structure body to be processed according to the received message queue, determining a target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
Another inter-process communication apparatus is provided in an embodiment of the present specification, the apparatus comprising:
The system comprises a first communication preparation module, a second communication preparation module, a receiving message queue, a message structure body, a first communication preparation module and a second communication preparation module, wherein the first communication preparation module is used for establishing a process list for any process, the process list is established for the process, the receiving message queue corresponding to the process is established and is expanded into the process list of the process, and the receiving message queue is used for arranging message structure bodies sent by other processes;
And the second communication execution module is used for determining a message structure body to be processed according to the received message queue, determining a target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
The above-mentioned at least one technical scheme that this description embodiment adopted can reach following beneficial effect:
According to the embodiment of the specification, the data structure in the kernel is abandoned, the shared memory in the user mode is used, frequent data reading and writing between the user mode and the kernel mode are not needed, the consumption of CPU resources is reduced, and the inter-process communication efficiency is further improved. In addition, the mode of controlling the shared memory by using the received message queue in the embodiment of the specification enables the operation on the shared memory to be an atomic operation, ensures that only one process can read and write the data of the shared memory at the same time, and ensures the accuracy of the data.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings used in the description of the embodiments of the present specification or the prior art will be briefly described below. It will be apparent to those skilled in the art that the drawings, which are only illustrative of the manner in which some of the embodiments of the present application may be utilized, are readily apparent and other drawings may be made from these drawings without the benefit of the inventive faculty.
Fig. 1 is a flow chart of an inter-process communication method according to a first embodiment of the present disclosure.
Fig. 2 is a schematic diagram of an inter-process communication flow in the first embodiment of the present specification.
Fig. 3 is a schematic diagram of a message structure in the first embodiment of the present specification.
Fig. 4 is a flow chart of an inter-process communication method according to a second embodiment of the present disclosure.
Fig. 5 is a schematic structural diagram of an inter-process communication apparatus according to a third embodiment of the present disclosure.
Fig. 6 is a schematic structural diagram of an inter-process communication apparatus according to a fourth embodiment of the present disclosure.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the accompanying drawings. It will be apparent that the embodiments referred to in this detailed description are only some, but not all, embodiments of the application. All other examples, which are obtained based on the examples in the detailed description without any inventive effort, should be considered as falling within the scope of the present application by a person of ordinary skill in the art.
The first embodiment (hereinafter referred to as "embodiment one") of the present disclosure provides an inter-process communication method, where the execution subject of the embodiment one includes, but is not limited to, a terminal or a server or an operating system or an application program, i.e., the execution subject may be various, and may be set, used, or changed according to the needs. In addition, a third party application may also be provided to assist the executing entity in executing embodiment one. The data processing method in the first embodiment may be executed by a server, for example, and a corresponding application may be installed on a terminal (the terminal may be held by a user), and data transmission may be performed between the terminal or the application and the server, thereby assisting the server in executing the data processing method in the first embodiment.
Referring to fig. 1 and 2, an inter-process communication method provided in a first embodiment includes:
s101, for any process, establishing a process list in the process, wherein the process list is generated according to process information of target equipment;
after the target device (including but not limited to an embedded communication device) is started, the various processes begin running. The following description is made from a single process perspective:
For any process, a process list may be established in the process. The process list is generated according to the process information of the target device.
Specifically, the process information of the target device may be obtained, which includes global resource information including a process table of all processes, a process ID of each process, and the like. And (3) storing a table formed by the process IDs of the processes according to the process table, wherein the table formed by the process IDs is a process list. The specific form of the process list is not limited, and the main information included in the process list is each process and a process ID of each process.
The process list is copied in each process, so that the process list is built in any process. The content may be executed by a first process initiated by the target device.
S103, creating a received message queue corresponding to the process, and expanding the received message queue into the process list of the process;
In a first embodiment, for any process, a received message queue corresponding to the process is created, and the received message queue is extended to a process list of the process. The received message queue may have a plurality of locations or spaces that form a queued structure. Of course, the specific structure of the received message queue is not limited.
The received message queue corresponding to the process is bound to the process ID of the process. For the process, a process list is already established in the process, and the received message queue corresponding to the process is bound with the process ID of the process, so that the received message queue of the process is expanded (by the process ID of the process) into the process list of the process.
After the received message queue is extended, the process list of the process exists independently, is maintained by the process itself, and is visible to each process.
In addition, the received message queue of the process may be given a queue identifier, and the identifiers of the received message queues of different processes are different. Some preprocessing operations may be performed on the received message queue, such as initializing the received message queue, etc., before the received message queue is actually used to receive each type of message. These preprocessing operations may be performed as desired, as the embodiment is not limited.
In the first embodiment, for any process, a thread corresponding to the process may be started, where the thread is configured to receive various types of messages sent by other processes, and store the received various types of messages in a received message queue of the process. The thread will be referred to as a receive message thread hereinafter.
For any process, the process may be linked to a shared memory common to all processes, the shared memory being visible to all processes. Specifically, after the target device is started, a certain process (for example, the first process started by the target device) may acquire internal resources such as a stack area space and a register of the target device, and then determine a shared memory shared by all the processes, where each process may be respectively linked to the shared memory after being started.
The above-mentioned contents, including the expansion of the received message queue and the process list, the preprocessing operation of the received message queue, the starting of the received message thread, the process link shared memory, etc., can be regarded as the preparation work of the inter-process communication. In a practical scenario, these preparations may be applied as needed to perform inter-process communication tasks.
And S105, when the process needs to communicate with the target process, generating a message structure body according to a task executed by the target process, and sending the message structure body to a receiving message queue corresponding to the target process so as to enable the target process to execute the task according to the receiving message queue, wherein the target process executes the task according to the receiving message queue, and comprises the steps of determining the message structure body to be processed according to the receiving message queue, determining target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
For any process, the process needs to communicate with a target process (i.e., the process to which the process is to communicate or send messages), and when sending messages to other processes, the process can generate a message structure according to tasks executed by the target process. Wherein, the task that needs to be executed by the target process is used to refer to what data needs to be executed by the target process (hereinafter referred to as a target operation).
Before generating the message structure body, the sending process may prepare data to be processed by the target process, apply for the shared memory, and put the data to be processed by the target process into the shared memory.
The message structure may include a message header and a message body. The content of the message header includes, but is not limited to:
(1) Receiving an id corresponding to a process (i.e., a target process);
(2) The id corresponding to the sending process (i.e., the process that sent the message structure, i.e., any of the processes described above);
(3) The length of the IPC message;
(4) The number of IPC messages;
(5) IPC message type;
(6) IPC message subtype;
(7) IPC message opcode (representing a target operation to be performed on data by the receiving process);
(8) Priority.
The contents of the message body include, but are not limited to, location information in the shared memory of data that needs to be processed by the target process in order for the target process to locate such data from the shared memory based on the message body. For example, the data to be processed by the target process is copied to the shared memory, and an offset data address offset value is obtained by parsing, where the offset data address offset value is included in the message body, and the data in the shared memory can be located by the offset data address offset value.
The specific content of the header and body of the message is referred to in fig. 3. Fig. 3 is merely an example, and the content or form of the message header or message body may be set or changed as needed in actual circumstances.
In a first embodiment, a sending process assembles a message header and a message body into a message structure body, and sends the message structure body to a receiving message queue corresponding to a target process, so that the target process executes a task which needs to be executed by the target process according to the receiving message queue.
In addition, in actual situations, the sending interface of the message structure body and the receiving interface of the message structure body of the target process can be determined according to different requirements. For example, the sending process may determine the sending interface of the message structure and the receiving interface of the message structure according to whether the target process is required to return the response message, and implement the corresponding function according to the difference of the called sending interface, receiving interface and input parameters.
For example, in order to implement the synchronous function (i.e. synchronization between the sending process and the receiving process), the sending process invokes the reply method, and the sending process needs to wait for the receiving process to return a response, then the corresponding sending interface and the corresponding receiving interface may be selected, or in order to implement the asynchronous function, the sending process invokes the non-reply method, and the sending process considers sending a notification to the receiving process, and does not need the receiving process to return a response, then the corresponding sending interface and the corresponding receiving interface may be selected, or after each sending of the message structure, it may be determined whether the message structure reaches the receiving message queue corresponding to the target process in the agreed time, and if not, the sending process resends the message structure to the receiving message queue corresponding to the target process again, and resends the message structure may be repeated multiple times until the message structure is sent to the receiving message queue of the receiving process in the agreed time. Specifically, the contracted time can be represented by a timeout parameter of the sending process. Therefore, a timeout retransmission mechanism is realized by using the timeout parameter, and the influence of accidental factors (such as equipment blocking) on a communication result is reduced.
The following describes from the target thread perspective how to receive a message structure and perform the tasks according to the message from the received message queue:
as previously described, a receive message queue may receive various types of messages, including message structures, for queuing message structures sent by other processes.
The message structure body sent by the sending process is received by the receiving message thread of the target process, and the corresponding sequence identification is given to the message structure body. The sequence identifier may be a sequence number or other form for indicating the sequence or sequence number of the message structure.
On the one hand, after the message structure is newly received, the maximum sequence identifier of the message structure which is not processed by the current target process is checked, and then the next sequence identifier is given to the newly received message structure. For example, if the maximum sequence identifier of the message structure that has not been processed by the current target process is p, the sequence identifier of the newly received message structure is p+1, and on the other hand, the target process determines the message structure that needs to be processed according to the corresponding received message queue. Specifically, when the target process processes the message structure, the current first sequence identifier of the message queue corresponds to the message structure as the message structure to be processed. Assuming that the message structure a is a message structure to be processed, after the message structure a is processed, the sequence identifier corresponding to the message structure a on the received message queue is released, and the message structure corresponding to the next sequence identifier is advanced and updated to the sequence identifier just released.
In summary, the message structure processed by the target process is actually the message structure corresponding to the first sequence identifier on the received message queue corresponding to the target process. This is because, after the target device is started, the first message structure received by the target process is given a first sequence identifier (assuming that the sequence identifier is in digital form, the first sequence identifier is 1) of the received message queue corresponding to the target process, and the target process processes the message structure with the sequence identifier of 1. When the next message structure is received, the following is classified as:
In the first case, if the message structure body on the sequence identifier 1 is processed, the sequence identifier 1 is released, and the received next message structure body is still endowed with the sequence identifier 1 and is processed by the target process;
In the second case, if the message structure on the sequence identifier 1 is not processed, the sequence identifier of the next received message structure is 2. When the message structure body with the sequence identifier 1 is processed, the sequence identifier 1 is released, and the ranking of the message structure body with the original sequence identifier 2 advances one bit, namely, the sequence identifier of the message structure body with the original sequence identifier 2 is updated to be 1, and is processed by the target process.
And so on, the target process takes the message structure corresponding to the first sequence identification in the current received message queue as the message structure to be processed. After receiving the new message structure, checking the maximum sequence identifier of the message structure which is not processed by the current target process, and then giving the next sequence identifier to the newly received message structure. And each time the target thread finishes processing one message structure body, updating the received message queue, traversing the updated received message queue, and continuing to use the message structure body corresponding to the first sequence identification in the updated received message queue as the message structure body to be processed. The sequence identification of the message structure to be processed is updated currently (i.e. the sequence identification of the message structure to be processed currently advances by one bit) each time the target thread finishes processing one message structure, the received message queue is updated.
In this way, the target process determines the message structure body to be processed according to the received message queue, and ensures that the message structure body corresponding to the first sequence identifier sequenced on the received message queue is processed by the target process all the time.
Next, how the target thread processes the message structure and performs tasks is described:
The target thread determines target operations to be executed according to the message structure body to be processed, and determines data to be operated from the shared memory. Specifically, the target process parses the message structure to obtain a message header and a message body. The target process can determine the target operation to be executed according to the message header (see the description of the message header and fig. 3 above), and the target process can locate the data to be executed from the shared memory according to the message body, so as to execute the target operation on the located data, that is, execute the task to be executed by the target process.
In the first embodiment, the target process determines whether to return the response message to the process that transmits the message structure according to the transmission interface used by the process that transmits the message structure.
If the response message needs to be returned, the target process generates a message structure body according to the response message which needs to be returned, and sends the message structure body to the corresponding process, and the process receiving the message structure body processes the message structure body. The foregoing details have been set forth herein and are not repeated here.
If the target process only sends the response message to the other process, the target process generally does not need to store data in the shared memory, but only needs to generate a message structure body according to the response message returned as needed, send the message structure body to the corresponding process, and process the message structure body by the process receiving the message structure body.
In the first embodiment, the shared memory only allows a single process to read and write data. When a certain process processes the message structure body and reads and writes the data of the shared memory, other processes needing to read and write the data of the shared memory can wait. After the current process finishes reading and writing data, the next process reads and writes the data of the shared memory. Specifically, each transmitting process and each receiving process may have an order, and the order of each transmitting process and each receiving process may be determined according to the time when data is applied to be written into the shared memory (transmitting process) and the time when data is applied to be read into the shared memory (receiving process).
Embodiment one will be further described by way of specific examples:
Assuming that the sending process is an alarm process, the target process is a terminal process. The alert process performs the following:
Preparing data, namely preparing data which needs to be processed by the terminal process by the alarm process, and assembling the data which needs to be processed by the terminal process into a structure body.
And (3) applying for the shared memory, filling data into the shared memory, namely applying for a block of space from the linked shared memory by the alarm process, copying the data which need to be processed by the terminal process into the space, and analyzing an offset data address offset value.
And assembling a message structure body, namely generating the message structure body according to tasks executed by the terminal process, wherein the message structure body comprises a message header and a message body. The message header indicates that the receiving process is a terminal process, the sending process is an alarm process, the data length, the number type and the subtype are determined by the data which are put into the shared memory, the operation code is selected according to the requirement (for example, EVENT notification identification can be used in the example), and the corresponding priority is selected according to the importance degree of the EVENT. A offsett data address offset value is recorded in the message body.
And selecting an API according to the requirement, namely determining a sending interface of a message structure body and a receiving interface of the terminal process according to whether the terminal process is required to return a response message.
And sending the message structure body to a receiving message queue of the terminal process, and waiting for the terminal process to process the message structure body.
The terminal process performs the following:
Waiting for receiving a message;
discovering and receiving a message structure body, and giving a sequence identifier;
And circularly traversing the corresponding received message queues, and processing and sequencing the first message structure body.
As described above, the message structure sent by the alarm process is given a sequence identifier after being received, but it may not be the first message structure currently ordered, so it is necessary to wait for the receiving process to process. The message structure sent by the alarm process becomes the first message structure in order after updating the received message queue for a certain time, and is processed by the terminal process.
The specific processing process comprises the steps that a terminal process analyzes a message structure body to obtain the message header and various contents contained in the message body, and the information including the sending process id, the length, the number, the type, the subtype, the operation code, the priority and the like in the message header and the address offset information in the message body. Wherein, the sending process id determines that the message structure body is the message structure body sent by the alarm process, and the operation code can determine that the EVENT operation (namely the target operation) needs to be performed on the data.
The pointer in the message body points to the shared memory and is mapped to a designated area in the memory by the offset in the message body. Correspondingly, the terminal process can reflect and shoot out a section of data in the shared memory through offsett data address offset value and shared memory address in the message body, namely the alarm process packages and puts the section of data to be processed by the terminal process in the shared memory.
The receiving process executes target operation on the data reflected from the shared memory, releases the shared memory, and decides whether to return a response message to the sending process according to the sending API used by the alarm process.
The first embodiment can obtain the following beneficial effects:
In the message queue mode used in the prior process communication, the queue used is essentially a data structure formed by a linked list provided by a kernel. Writing data to the message queue, in effect inserting a new node into the data structure, and reading data from the message queue, in effect reading and deleting a node from the data structure. The sending process defines the message to be sent in the message buffer of the process at the time of communication, and then connects the message structure to a linked list in the kernel. The receiving process matches the corresponding node from the linked list (i.e. message queue) in the kernel, acquires the message and stores it in the message buffer of the receiving process, and deletes the node. In the process, the user mode and the kernel mode perform frequent data copying, and the frequent read-write operation of the kernel mode consumes additional cpu resources.
In the first embodiment, the data structure in the kernel is abandoned, the shared memory in the user mode is used, frequent data reading and writing between the user mode and the kernel mode are not needed, the consumption of CPU resources is reduced, and the inter-process communication efficiency is improved.
In the existing process communication method realized through the shared memory, a synchronization and mutual exclusion mechanism does not exist in the shared memory, so that when a plurality of processes operate the shared memory simultaneously, before a first process finishes reading and writing the shared memory, no mechanism is used for preventing another process from reading and writing the shared memory.
In the first embodiment, the operation on the shared memory is changed into the atomic operation by using the manner of controlling the shared memory by using the received message queue, so that only one process can read and write the data of the shared memory, the accuracy of the data is ensured, and the inter-process communication effect is improved.
Through the first embodiment, the synchronization of the shared memory can be ensured by the characteristics of the received message queue during data interaction, the correctness of the data is ensured, the kernel mode operation is not involved in the shared memory mode, the consumption of resources such as a CPU (Central processing Unit), a memory and the like is reduced, and the inter-process communication efficiency in the embedded system is improved.
The first embodiment can stably and efficiently realize the inter-process communication requirement, is easy to maintain and is not easy to make mistakes.
According to the embodiment, the synchronous and asynchronous functions are used as required in the communication process, a timeout retransmission mechanism in the communication process is increased, and efficiency and accuracy in inter-process communication are improved.
The second embodiment (hereinafter referred to as "embodiment two") of the present disclosure provides an inter-process communication method, where the execution subject of the embodiment two includes, but is not limited to, a terminal or a server or an operating system or an application program, i.e., the execution subject may be various, and may be set, used, or changed according to the needs. In addition, a third party application may also assist the execution body in executing the second embodiment. The data processing method in the second embodiment may be executed by a server, for example, and a corresponding application may be installed on a terminal (the terminal may be held by a user), and data transmission may be performed between the terminal or the application and the server, thereby assisting the server in executing the data processing method in the second embodiment.
Referring to fig. 4, the inter-process communication method provided in the second embodiment includes:
s202, for any process, a process list is established in the process, wherein the process list is generated according to the process information of target equipment;
See in particular embodiment one.
S204, creating a received message queue corresponding to the process, and expanding the received message queue into the process list of the process, wherein the received message queue is used for queuing message structures sent by other processes;
See in particular embodiment one.
S206, determining a message structure body to be processed according to the received message queue, determining a target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
See in particular embodiment one.
In the second embodiment, after receiving the message structure, the maximum sequence identifier of the message structure that has not been processed at present is checked, and then the next sequence identifier is given to the newly received message structure. See in particular embodiment one.
In a second embodiment, determining a message structure body to be processed according to the received message queue may include:
Taking a message structure body corresponding to a first sequence identifier in a current received message queue as a message structure body to be processed;
And updating the received message queue after processing one message structure body, and continuing to use the message structure body corresponding to the first sequence identifier in the updated received message queue as the message structure body to be processed.
See in particular embodiment one.
In a second embodiment, for any process, a receiving message thread corresponding to the process is started, where the receiving message thread is used to receive a message structure body sent by another process, and store the message structure body in a receiving message queue of the process. See in particular embodiment one.
The second embodiment is not described in detail with reference to the first embodiment.
Since a single process may be either a transmitting process or a receiving process, the execution subject of the first or second embodiment may be either a single process or a target device.
A third embodiment of the present specification provides an inter-process communication apparatus corresponding to the inter-process communication method of the first embodiment. Referring to fig. 5, the inter-process communication apparatus includes:
The first communication preparation module 301 is configured to establish a process list for any process, create a received message queue corresponding to the process, and extend the received message queue to the process list of the process, where the process list is generated according to process information of a target device;
The first communication executing module 303 is configured to generate a message structure according to a task executed by a target process when the process needs to communicate with the target process, and send the message structure to a receiving message queue corresponding to the target process, so that the target process executes the task according to the receiving message queue;
wherein the target process executing the task according to the received message queue comprises:
And determining a message structure body to be processed according to the received message queue, determining a target operation to be executed according to the message structure body to be processed, determining data to be operated from a shared memory, and executing the target operation on the data.
Optionally, the first communication preparation module 301 is further configured to link the process to a shared memory shared by all the processes before generating a message structure according to a task executed by the target process.
Optionally, the first communication preparation module 301 is further configured to put, in a shared memory, data that needs to be processed by the target process before sending the message structure to a received message queue corresponding to the target process, where the message structure includes positioning information of the data in the shared memory.
Optionally, the first communication execution module 303 is further configured to:
Determining a sending interface of the message structure body according to whether the target process is required to return a response message;
And/or the number of the groups of groups,
Determining whether the message structure body reaches a received message queue corresponding to the target process in a stipulated time;
If not, the message structure body is sent to the message receiving queue corresponding to the target process again.
A fourth embodiment of the present specification provides an inter-process communication apparatus corresponding to the inter-process communication method described in the second embodiment. Referring to fig. 6, the inter-process communication apparatus includes:
The second communication preparation module 402 is configured to establish a process list for any process, create a received message queue corresponding to the process, and extend the received message queue to the process list of the process, where the received message queue is used for queuing message structures sent by other processes, and the process list is generated according to process information of a target device;
And the second communication execution module 404 is configured to determine a message structure body to be processed according to the received message queue, determine a target operation to be executed according to the message structure body to be processed, determine data to be operated from the shared memory, and execute the target operation on the data.
Optionally, the second communication execution module 404 is further configured to, after receiving the message structure, check a maximum sequence identifier of the message structure that is not yet processed, and then assign a next sequence identifier to the newly received message structure.
Optionally, determining a message structure body to be processed according to the received message queue includes:
Taking a message structure body corresponding to a first sequence identifier in a current received message queue as a message structure body to be processed;
And updating the received message queue after processing one message structure body, and continuing to use the message structure body corresponding to the first sequence identifier in the updated received message queue as the message structure body to be processed.
Optionally, the second communication executing module 404 is further configured to start a receiving message thread corresponding to the process, where the receiving message thread is configured to receive a message structure body sent by another process, and store the message structure body in a receiving message queue of the process.
The above embodiments may be used with reference to each other or in combination, and modules with the same names in different embodiments may be the same module or different modules.
The foregoing description is by way of example only and is not intended as limiting the application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the application are to be included in the scope of the claims of the present application.

Claims (10)

CN202510866914.4A2025-06-262025-06-26Inter-process communication method and devicePendingCN120371570A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202510866914.4ACN120371570A (en)2025-06-262025-06-26Inter-process communication method and device

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202510866914.4ACN120371570A (en)2025-06-262025-06-26Inter-process communication method and device

Publications (1)

Publication NumberPublication Date
CN120371570Atrue CN120371570A (en)2025-07-25

Family

ID=96437328

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202510866914.4APendingCN120371570A (en)2025-06-262025-06-26Inter-process communication method and device

Country Status (1)

CountryLink
CN (1)CN120371570A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN1859325A (en)*2006-02-142006-11-08华为技术有限公司News transfer method based on chained list process
CN101448018A (en)*2008-12-262009-06-03中兴通讯股份有限公司Interprocess communication method and device thereof
CN104346229A (en)*2014-11-142015-02-11国家电网公司Processing method for optimization of inter-process communication of embedded operating system
CN109413432A (en)*2018-07-032019-03-01北京中科睿芯智能计算产业研究院有限公司Multi-process coding method, system and device based on event and shared drive mechanism
CN112559207A (en)*2020-12-102021-03-26南京丹迪克科技开发有限公司Method for realizing data interaction between processes based on message queue and shared memory mode
WO2021088419A1 (en)*2019-11-072021-05-14浪潮(北京)电子信息产业有限公司Method for invoking fpga device by using multiple service request processes and related apparatus
CN115408172A (en)*2022-08-292022-11-29苏州浪潮智能科技有限公司Inter-process communication method, device, equipment and medium
WO2024125280A1 (en)*2022-12-152024-06-20华为技术有限公司Message transmission method and apparatus, and device and storage medium
CN118606069A (en)*2024-05-242024-09-06东方证券股份有限公司 Inter-process communication method based on shared memory

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN1859325A (en)*2006-02-142006-11-08华为技术有限公司News transfer method based on chained list process
CN101448018A (en)*2008-12-262009-06-03中兴通讯股份有限公司Interprocess communication method and device thereof
CN104346229A (en)*2014-11-142015-02-11国家电网公司Processing method for optimization of inter-process communication of embedded operating system
CN109413432A (en)*2018-07-032019-03-01北京中科睿芯智能计算产业研究院有限公司Multi-process coding method, system and device based on event and shared drive mechanism
WO2021088419A1 (en)*2019-11-072021-05-14浪潮(北京)电子信息产业有限公司Method for invoking fpga device by using multiple service request processes and related apparatus
CN112559207A (en)*2020-12-102021-03-26南京丹迪克科技开发有限公司Method for realizing data interaction between processes based on message queue and shared memory mode
CN115408172A (en)*2022-08-292022-11-29苏州浪潮智能科技有限公司Inter-process communication method, device, equipment and medium
WO2024125280A1 (en)*2022-12-152024-06-20华为技术有限公司Message transmission method and apparatus, and device and storage medium
CN118606069A (en)*2024-05-242024-09-06东方证券股份有限公司 Inter-process communication method based on shared memory

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JULIAN SHUN: "Ligra: a lightweight graph processing framework for shared memory", PPOPP \'13: PROCEEDINGS OF THE 18TH ACM SIGPLAN SYMPOSIUM ON PRINCIPLES AND PRACTICE OF PARALLEL PROGRAMMING, 23 February 2013 (2013-02-23), pages 135, XP093290463*
林学峰;徐世新;: "消息队列通信机制在卫星计费系统中的应用", 计算机应用, no. 1, 28 August 2006 (2006-08-28), pages 214 - 215*

Similar Documents

PublicationPublication DateTitle
CN113504985B (en) A task processing method and network device
CN108647104B (en)Request processing method, server and computer readable storage medium
Neira‐Ayuso et al.Communicating between the kernel and user‐space in Linux using Netlink sockets
WO2019042312A1 (en)Distributed computing system, data transmission method and device in distributed computing system
CN110069346B (en)Method and device for sharing resources among multiple processes and electronic equipment
US20090292810A1 (en)Message binding processing technique
US9946582B2 (en)Distributed processing device and distributed processing system
KR100436471B1 (en)Apparatus and method for communicating between computer systems using a sliding send window for ordered messages in a clustered computing environment
US10740159B2 (en)Synchronization object prioritization systems and methods
CN115964176B (en) Cloud computing cluster scheduling method, electronic device and storage medium
CN114730314B (en) Transaction submission system, method and related equipment
CN105389120A (en)Supporting RMA API over active message
CN105930545B (en) Method and device for file migration
CN116643854A (en) A service orchestration method, device, process controller and task processor
CN108055296B (en) A transaction processing method and device based on microservice architecture
CN120371570A (en)Inter-process communication method and device
JP2013186765A (en)Batch processing system, progress confirmation device, progress confirmation method and program
CN103399949B (en)A kind of database storage block state control method and device
CN114416405A (en) A semantic method and device based on message middleware
CN113687962A (en) A request processing method, apparatus, device and storage medium
US10761883B2 (en)Program executing apparatus and program execution method
JP4667299B2 (en) Interprocess communication method
CN108038007B (en)Method and system for orderly processing messages based on Ignite
CN110879747B (en)Resource management method and device
CN117931485B (en) A data transmission system and method, electronic device and storage medium

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp