CN111400055A - Method, device, equipment and storage medium for communication among multiple processes - Google Patents
Method, device, equipment and storage medium for communication among multiple processes Download PDFInfo
- Publication number
- CN111400055A CN111400055A CN201910004763.6A CN201910004763A CN111400055A CN 111400055 A CN111400055 A CN 111400055A CN 201910004763 A CN201910004763 A CN 201910004763A CN 111400055 A CN111400055 A CN 111400055A
- Authority
- CN
- China
- Prior art keywords
- interface
- communication
- definition information
- called
- calling
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 319
- 230000008569 process Effects 0.000 title claims abstract description 215
- 230000006854 communication Effects 0.000 title claims abstract description 132
- 238000004891 communication Methods 0.000 title claims abstract description 131
- 230000004044 response Effects 0.000 claims description 13
- 238000010586 diagram Methods 0.000 description 7
- 238000012423 maintenance Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000007792 addition Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
本发明提供了一种多进程间通信的方法、装置、设备及存储介质,涉及通信技术领域。该多进程间通信的方法,包括:接收来自呼叫进程的通信指令,通信指令包括操作系统中被呼叫进程的接口标识;基于被呼叫进程的接口标识,在操作系统的共享内存中调用与被呼叫进程的接口标识匹配的接口定义信息,接口定义信息用于定义进程的接口;根据与被呼叫进程的接口标识匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。利用本发明的技术方案能够提高多进程间通信的效率。
The present invention provides a method, device, device and storage medium for multi-process communication, and relates to the technical field of communication. The method for multi-process communication includes: receiving a communication instruction from a calling process, where the communication instruction includes an interface identifier of the called process in the operating system; based on the interface identifier of the called process, calling and calling in the shared memory of the operating system and the called process Interface definition information matched with the interface identifier of the process, the interface definition information is used to define the interface of the process; according to the interface definition information matched with the interface identifier of the called process, the communication between the calling process and the called process is performed. By using the technical scheme of the present invention, the efficiency of multi-process communication can be improved.
Description
技术领域technical field
本发明涉及通信技术领域,尤其涉及一种多进程间通信的方法、装置、设备及存储介质。The present invention relates to the field of communication technologies, and in particular, to a method, apparatus, device and storage medium for multi-process communication.
背景技术Background technique
在对操作系统的应用层开发过程中,会需要使用不同进程间的通信。比如,需要进行进程A与进程B之间的通信,则需要开发人员手动定义进程A的相关信息,再手动查找进程B的相关信息。利用进程A的相关信息和进程B的相关信息,定义进程A与进程B之间的通信方法,从而发起进程A与进程B的通信。During the development of the application layer of the operating system, communication between different processes will be required. For example, if the communication between process A and process B needs to be performed, the developer needs to manually define the relevant information of the process A, and then manually search for the relevant information of the process B. Using the relevant information of the process A and the relevant information of the process B, a communication method between the process A and the process B is defined, so as to initiate the communication between the process A and the process B.
随着应用数量的增多,想要实现进程间的通信,需要开发人员大量的手动操作维护,花费时间长,降低了多进程间通信的效率。As the number of applications increases, to achieve inter-process communication requires a lot of manual operation and maintenance by developers, which takes a long time and reduces the efficiency of multi-process communication.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供了一种多进程间通信的方法、装置、设备及存储介质,能够提高多进程间通信的效率。Embodiments of the present invention provide a method, apparatus, device and storage medium for multi-process communication, which can improve the efficiency of multi-process communication.
第一方面,本发明实施例提供了一种多进程间通信的方法,包括:接收来自呼叫进程的通信指令,通信指令包括操作系统中被呼叫进程的接口标识;基于被呼叫进程的接口标识,在操作系统的共享内存中调用与被呼叫进程的接口标识匹配的接口定义信息,接口定义信息用于定义进程的接口;根据与被呼叫进程的接口标识匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。In a first aspect, an embodiment of the present invention provides a method for multi-process communication, including: receiving a communication instruction from a calling process, where the communication instruction includes an interface identifier of the called process in the operating system; based on the interface identifier of the called process, Call the interface definition information matching the interface identifier of the called process in the shared memory of the operating system, and the interface definition information is used to define the interface of the process; Communication between calling processes.
在一些可能的实施例中,上述多进程间通信的方法还包括:将所有进程的接口定义信息写入操作系统的共享内存中。In some possible embodiments, the above method for multi-process communication further includes: writing interface definition information of all processes into the shared memory of the operating system.
在一些可能的实施例中,根据与被呼叫进程的接口标识匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信,包括:根据与被呼叫进程的接口标识匹配的接口定义信息,调用与接口定义信息对应的接口指针,以访问被呼叫进程的执行地址;接收来自被呼叫进程的响应信息,并将响应信息返回给呼叫进程。In some possible embodiments, performing the communication between the calling process and the called process according to the interface definition information matched with the interface identifier of the called process includes: according to the interface definition information matched with the interface identifier of the called process, The interface pointer corresponding to the interface definition information is called to access the execution address of the called process; the response information from the called process is received, and the response information is returned to the calling process.
在一些可能的实施例中,共享内存中存储有可执行文件,上述多进程间通信的方法还包括:将被呼叫进程的接口定义信息编译入可执行文件中的接口定义段,以使可执行文件被执行时实现对接口定义信息对应的接口指针的调用。In some possible embodiments, an executable file is stored in the shared memory, and the above method for multi-process communication further includes: compiling the interface definition information of the called process into an interface definition section in the executable file, so that the executable When the file is executed, the interface pointer corresponding to the interface definition information is called.
在一些可能的实施例中,上述多进程间通信的方法还包括:更新操作系统的共享内存中的进程的接口定义信息。In some possible embodiments, the above method for multi-process communication further includes: updating interface definition information of the process in the shared memory of the operating system.
在一些可能的实施例中,接口定义信息包括接口标识、接口标识对应的接口所属的进程和接口标识对应的接口所属的进程的信道信息。In some possible embodiments, the interface definition information includes an interface identifier, a process to which the interface corresponding to the interface identifier belongs, and channel information of a process to which the interface corresponding to the interface identifier belongs.
第二方面,本发明实施例提供了一种多进程间通信的装置,包括:接收模块,用于接收来自呼叫进程的通信指令,通信指令包括操作系统中被呼叫进程的接口标识;调用模块,用于基于被呼叫进程的接口标识,在操作系统的共享内存中调用与被呼叫进程的接口标识匹配的接口定义信息,接口定义信息用于定义进程的接口;执行模块,用于根据与被呼叫进程的接口标识匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。In a second aspect, an embodiment of the present invention provides an apparatus for multi-process communication, including: a receiving module for receiving a communication instruction from a calling process, where the communication instruction includes an interface identifier of the called process in an operating system; a calling module, It is used to call the interface definition information matching the interface identifier of the called process in the shared memory of the operating system based on the interface identifier of the called process, and the interface definition information is used to define the interface of the process; the execution module is used to The interface identification information of the process matches the interface definition information, and the communication between the calling process and the called process is performed.
在一些可能的实施例中,上述多进程间通信的装置还包括:定义模块,用于将所有进程的接口定义信息写入操作系统的共享内存中。In some possible embodiments, the apparatus for multi-process communication further includes: a definition module, configured to write the interface definition information of all processes into the shared memory of the operating system.
在一些可能的实施例中,定义模块还用于更新操作系统的共享内存中的进程的接口定义信息。In some possible embodiments, the definition module is further configured to update the interface definition information of the process in the shared memory of the operating system.
在一些可能的实施例中,执行模块具体用于:根据与被呼叫进程的接口标识匹配的接口定义信息,调用与接口定义信息对应的接口指针,以访问被呼叫进程的执行地址;接收来自被呼叫进程的响应信息,并将响应信息返回给呼叫进程。In some possible embodiments, the execution module is specifically configured to: call the interface pointer corresponding to the interface definition information according to the interface definition information matching the interface identifier of the called process to access the execution address of the called process; The response information of the calling process, and the response information is returned to the calling process.
在一些可能的实施例中,共享内存中存储有可执行文件,上述多进程间通信的装置还包括:编译模块,用于将被呼叫进程的接口定义信息编译入可执行文件中的接口定义段,以使可执行文件被执行时实现对接口定义信息对应的接口指针的调用。In some possible embodiments, an executable file is stored in the shared memory, and the apparatus for multi-process communication further includes: a compilation module for compiling the interface definition information of the called process into an interface definition segment in the executable file , so that when the executable file is executed, the interface pointer corresponding to the interface definition information is called.
在一些可能的实施例中,接口定义信息包括接口标识、接口标识对应的接口所属的进程和接口标识对应的接口所属的进程的信道信息。In some possible embodiments, the interface definition information includes an interface identifier, a process to which the interface corresponding to the interface identifier belongs, and channel information of a process to which the interface corresponding to the interface identifier belongs.
第三方面,本发明实施例提供了一种多进程间通信的设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的程序,处理器执行程序时实现上述技术方案中的多进程间通信的方法。In a third aspect, an embodiment of the present invention provides a device for multi-process communication, including a memory, a processor, and a program stored in the memory and running on the processor. When the processor executes the program, the above technical solutions are implemented. A method for multi-process communication.
第四方面,本发明实施例提供了一种存储介质,其上存储有程序,程序被处理器执行时实现上述技术方案中的多进程间通信的方法。In a fourth aspect, an embodiment of the present invention provides a storage medium on which a program is stored, and when the program is executed by a processor, the method for implementing the multi-process communication in the foregoing technical solution is implemented.
本发明实施例提供了一种多进程间通信的方法、装置、设备及存储介质,在接收到来自呼叫进程的通信指令,可基于该通信指令中的被呼叫进程的接口标识,在共享内容中调用与被呼叫进程的接口标识匹配的接口定义信息。利用匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。也就是说,承载多进程间通信的方法的设备接收通信指令后,即可自动完成进程之间的通信。不需要开发人员或维护人员手动查找信息并建立通信,从而减少了多进程间通信所花费的时间,提高了多进程间通信的效率。Embodiments of the present invention provide a method, device, device, and storage medium for multi-process communication. After receiving a communication instruction from a calling process, based on the interface identifier of the called process in the communication instruction, in the shared content Call the interface definition information that matches the interface ID of the called process. Using the matched interface definition information, the communication between the calling process and the called process is performed. That is to say, after the device carrying the method for multi-process communication receives the communication instruction, it can automatically complete the communication between the processes. There is no need for developers or maintenance personnel to manually search for information and establish communication, thereby reducing the time spent in multi-process communication and improving the efficiency of multi-process communication.
附图说明Description of drawings
从下面结合附图对本发明的具体实施方式的描述中可以更好地理解本发明其中,相同或相似的附图标记表示相同或相似的特征。The present invention can be better understood from the following description of specific embodiments of the present invention in conjunction with the accompanying drawings, wherein the same or similar reference numerals denote the same or similar features.
图1为本发明实施例中一种多进程间通信的方法的流程图;1 is a flowchart of a method for multi-process communication in an embodiment of the present invention;
图2为本发明另一实施例中一种多进程间通信的方法的流程图;2 is a flowchart of a method for multi-process communication in another embodiment of the present invention;
图3为本发明一实施例中一种多进程间通信的装置的结构示意图;3 is a schematic structural diagram of an apparatus for multi-process communication according to an embodiment of the present invention;
图4为本发明另一实施例中一种多进程间通信的装置的结构示意图;4 is a schematic structural diagram of an apparatus for multi-process communication in another embodiment of the present invention;
图5为本发明实施例中一种多进程间通信的设备的结构示意图。FIG. 5 is a schematic structural diagram of a device for multi-process communication according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将详细描述本发明的各个方面的特征和示例性实施例。在下面的详细描述中,提出了许多具体细节,以便提供对本发明的全面理解。但是,对于本领域技术人员来说很明显的是,本发明可以在不需要这些具体细节中的一些细节的情况下实施。下面对实施例的描述仅仅是为了通过示出本发明的示例来提供对本发明的更好的理解。本发明决不限于下面所提出的任何具体配置和算法,而是在不脱离本发明的精神的前提下覆盖了元素、部件和算法的任何修改、替换和改进。在附图和下面的描述中,没有示出公知的结构和技术,以便避免对本发明造成不必要的模糊。Features and exemplary embodiments of various aspects of the invention are described in detail below. In the following detailed description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is only intended to provide a better understanding of the present invention by illustrating examples of the invention. The present invention is in no way limited to any specific configurations and algorithms set forth below, but covers any modification, substitution and improvement of elements, components and algorithms without departing from the spirit of the invention. In the drawings and the following description, well-known structures and techniques have not been shown in order to avoid unnecessarily obscuring the present invention.
本发明实施例提供了一种多进程间通信的方法、装置、设备及存储介质,可应用于多个进程之间需要通信的场景中。每个进程均具有自身一部分独立的资源,各个进程自身独立的资源时相互隔离的。为了能使得不同的进程之间互相访问资源并进行协调工作,需要进程之间进行通信。比如,开发人员对操作系统进行开发,需要多个进程相互通信。或者,维护人员在维护多个应用程序的过程中,需要各个应用程序的进程之间相互通信。Embodiments of the present invention provide a method, apparatus, device, and storage medium for multi-process communication, which can be applied to scenarios where communication between multiple processes is required. Each process has a part of its own independent resources, and the independent resources of each process are isolated from each other. In order to enable different processes to access resources and coordinate work, communication between processes is required. For example, developers developing operating systems require multiple processes to communicate with each other. Or, in the process of maintaining multiple applications, the maintainer needs to communicate with each other between the processes of each application.
在本发明实施例中,不需要开发人员或维护人员手动查找进程的相关信息,并手动建立进程之间的通信。可自动进行呼叫进程和被呼叫进程之间的通信,从而减少了多进程间通信所花费的时间,提高了多进程间通信的效率。In this embodiment of the present invention, it is not necessary for developers or maintenance personnel to manually search for process-related information and manually establish communication between processes. Communication between the calling process and the called process can be performed automatically, thereby reducing the time spent in multi-process communication and improving the efficiency of multi-process communication.
图1为本发明实施例中一种多进程间通信的方法的流程图。如图1所示,该多进程间通信的方法可包括步骤S101至步骤S103。FIG. 1 is a flowchart of a method for multi-process communication in an embodiment of the present invention. As shown in FIG. 1 , the method for multi-process communication may include steps S101 to S103.
在步骤S101中,接收来自呼叫进程的通信指令。In step S101, a communication instruction from the calling process is received.
在本发明中以呼叫进程与被呼叫进程为例进行说明。呼叫进程为发起呼叫的进程。被呼叫进程为被呼叫进程呼叫的进程。通信指令用于指示呼叫进程欲与被呼叫进程进行通信。比如,通信指令具体可为IPC-CALL指令。通信指令包括操作系统中被呼叫进程的接口标识。接口标识用于标识接口,不同的接口的接口标识不同。在一些示例中,操作系统具体可包括但不限于Linux系统。In the present invention, the calling process and the called process are used as examples for description. The calling process is the process that initiates the call. The called process is the process called by the called process. The communication instruction is used to instruct the calling process to communicate with the called process. For example, the communication instruction may specifically be an IPC-CALL instruction. The communication instruction includes the interface identification of the called process in the operating system. The interface identifier is used to identify the interface, and the interface identifiers of different interfaces are different. In some examples, the operating system may specifically include, but is not limited to, a Linux system.
在步骤S102中,基于被呼叫进程的接口标识,在操作系统的共享内存中调用与被呼叫进程的接口标识匹配的接口定义信息。In step S102, based on the interface identifier of the called process, the interface definition information matching the interface identifier of the called process is called in the shared memory of the operating system.
其中,操作系统中可设置有共享内容。该共享内容被所有进程共享,共享内存中可存储有所有进程的接口定义信息。接口定义信息用于定义进程的接口。进程利用接口来实现通信。利用接口定义信息,则可完成与该接口定义信息指向的接口所述的进程之间的通信。这里的“匹配”是指,匹配的被呼叫进程的接口标识和接口定义信息指向的是相同的进程。The shared content may be set in the operating system. The shared content is shared by all processes, and interface definition information of all processes can be stored in the shared memory. The interface definition information is used to define the interface of the process. Processes use interfaces to communicate. Using the interface definition information, the communication with the process described by the interface pointed to by the interface definition information can be completed. The "matching" here means that the interface identifier and interface definition information of the matched called process point to the same process.
在一些示例中,接口定义信息可包括接口标识、所述接口标识对应的接口所属的进程和所述接口标识对应的接口所属的进程的信道信息。若在共享内容中存储有与被呼叫进程的接口标识相同的接口标识,则确定与被呼叫进程的接口标识相同的接口标识所属的接口定义信息,为与所述被呼叫进程的接口标识匹配的接口定义信息。In some examples, the interface definition information may include an interface identifier, a process to which the interface corresponding to the interface identifier belongs, and channel information of a process to which the interface corresponding to the interface identifier belongs. If an interface identifier identical to the interface identifier of the called process is stored in the shared content, it is determined that the interface definition information to which the interface identifier identical to the interface identifier of the called process belongs is the one that matches the interface identifier of the called process. Interface definition information.
在步骤S103中,根据与被呼叫进程的接口标识匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。In step S103, the communication between the calling process and the called process is performed according to the interface definition information matching the interface identifier of the called process.
获取得到被呼叫进程的接口标识匹配的接口定义信息,即获得了被呼叫进程的接口定义信息。根据被呼叫进程的接口定义,可建立呼叫进程与被呼叫进程之间的通信通道,并执行呼叫进程与被呼叫进程之间的通信。The interface definition information matching the interface identifier of the called process is obtained, that is, the interface definition information of the called process is obtained. According to the interface definition of the called process, a communication channel between the calling process and the called process can be established, and the communication between the calling process and the called process can be performed.
比如,接口定义信息可包括接口标识、所述接口标识对应的接口所属的进程和所述接口标识对应的接口所属的进程的信道信息。则可根据接口标识得到对应的接口、对应的接口所属的进程,以及该进程的信道信息,根据接口、进程和信道信息,则可执行通信功能。For example, the interface definition information may include an interface identifier, a process to which the interface corresponding to the interface identifier belongs, and channel information of a process to which the interface corresponding to the interface identifier belongs. Then, the corresponding interface, the process to which the corresponding interface belongs, and the channel information of the process can be obtained according to the interface identifier, and the communication function can be executed according to the interface, process and channel information.
需要说明的是,上述多进程间通信的方法不只应用于呼叫进程呼叫被呼叫进程的过程中,也可应用在被呼叫进程回应呼叫进程的过程中,在此并不限定。It should be noted that the above multi-process communication method is not only applied to the process of calling the called process, but also to the process of the called process responding to the calling process, which is not limited herein.
在本发明实施例中,在接收到来自呼叫进程的通信指令,可基于该通信指令中的被呼叫进程的接口标识,在共享内容中调用与被呼叫进程的接口标识匹配的接口定义信息。利用匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。也就是说,承载多进程间通信的方法的设备接收通信指令后,即可自动完成进程之间的通信。不需要开发人员或维护人员手动查找信息并建立通信,从而减少了多进程间通信所花费的时间,提高了多进程间通信的效率。还可避免多进程通信时可能产生的拥塞。In this embodiment of the present invention, upon receiving a communication instruction from a calling process, based on the interface identifier of the called process in the communication instruction, the interface definition information matching the interface identifier of the called process can be called in the shared content. Using the matched interface definition information, the communication between the calling process and the called process is performed. That is to say, after the device carrying the method for multi-process communication receives the communication instruction, it can automatically complete the communication between the processes. There is no need for developers or maintenance personnel to manually search for information and establish communication, thereby reducing the time spent in multi-process communication and improving the efficiency of multi-process communication. It also avoids possible congestion when multi-process communication occurs.
而且,由于接口定义信息可在操作系统的共享内存中调用,则可实时更新操作系统的共享内存中的接口定义信息。具体可为增添、删除、更改操作系统的共享内存中进程的接口定义信息。便于多进程间通信的进程的扩展加载,也增强了多进程间通信的适用性。Moreover, since the interface definition information can be called in the shared memory of the operating system, the interface definition information in the shared memory of the operating system can be updated in real time. Specifically, the interface definition information of the process in the shared memory of the operating system can be added, deleted, or changed. The extended loading of processes that facilitate multi-process communication also enhances the applicability of multi-process communication.
图2为本发明另一实施例中一种多进程间通信的方法的流程图。图2与图1的不同之处在于,图1中的步骤S103可细化为步骤S1031和步骤S1032。图2所示的多进程间通信的方法还可包括步骤S104和步骤S105。FIG. 2 is a flowchart of a method for multi-process communication in another embodiment of the present invention. The difference between FIG. 2 and FIG. 1 is that step S103 in FIG. 1 can be subdivided into steps S1031 and S1032. The method for multi-process communication shown in FIG. 2 may further include step S104 and step S105.
在步骤S104中,将所有进程的接口定义信息写入操作系统的共享内存中。In step S104, the interface definition information of all processes is written into the shared memory of the operating system.
在一些示例中,可在共享内存中设置多个内存块。可为每个进程的接口定义信息分配一个内存块,将该进程的接口定义信息存入对应的内存块中。在执行步骤S102的过程中,可调用对应的内存块中与被呼叫进程的接口标识匹配的接口定义信息。In some examples, multiple memory blocks may be set up in shared memory. A memory block can be allocated for the interface definition information of each process, and the interface definition information of the process is stored in the corresponding memory block. In the process of executing step S102, the interface definition information in the corresponding memory block that matches the interface identifier of the called process can be called.
由于存储在内存块中的均为二进制数据,因此可将每个进程的接口定义信息进行编译,得到编译为二进制数据的接口定义信息。将编译为二进制数据的接口定义信息写入对应的内存块中,以完成调用所需的接口定义信息的调用。Since all the data stored in the memory block are binary data, the interface definition information of each process can be compiled to obtain the interface definition information compiled into binary data. Write the interface definition information compiled into binary data into the corresponding memory block, so as to complete the calling of the interface definition information required for the calling.
在步骤S105中,将被呼叫进程的接口定义信息编译入可执行文件中的接口定义段,以使可执行文件被执行时实现对接口定义信息对应的接口指针的调用。In step S105, the interface definition information of the called process is compiled into the interface definition section in the executable file, so that when the executable file is executed, the interface pointer corresponding to the interface definition information is called.
其中,共享内存中存储有可执行文件。执行可执行文件,则可实现对接口定义信息对应的接口指针的调用。在一些示例中,可执行文件可包括程序执行段和程序退出段。程序执行段用于实现多进程间通信过程中的各个调用。程序退出段用于实现进程的退出。Among them, executable files are stored in the shared memory. By executing the executable file, the interface pointer corresponding to the interface definition information can be called. In some examples, an executable file may include a program execution segment and a program exit segment. The program execution segment is used to implement each call in the multi-process communication process. The program exit segment is used to realize the exit of the process.
可在可执行文件的程序执行段前加入接口定义段。在进行多进程间通信的过程中,可将被呼叫进程的接口定义信息编译至接口定义段中。可执行文件被执行时,可从接口定义段得知被呼叫程序的接口定义信息,从而调用与被呼叫程序的接口定义信息对应的接口指针。The interface definition section can be added before the program execution section of the executable file. In the process of multi-process communication, the interface definition information of the called process can be compiled into the interface definition section. When the executable file is executed, the interface definition information of the called program can be obtained from the interface definition section, so as to call the interface pointer corresponding to the interface definition information of the called program.
可在可执行文件的程序退出段之前加入接口注销段,在进程退出操作系统的过程中,可将需要退出操作系统的进程的接口定义信息编译至接口注销段中。可执行文件被执行时,可从接口注销段得知需要退出操作系统的进程,从而退出操作系统。The interface logout section can be added before the program exit section of the executable file. During the process of exiting the operating system, the interface definition information of the process that needs to exit the operating system can be compiled into the interface logout section. When the executable file is executed, the process that needs to exit the operating system can be known from the logout segment of the interface, thereby exiting the operating system.
在一些示例中,接口定义消息可为通过自定义进程间通信接口(Define Inter-Process Communication,DEF-IPC)定义接口得到的。In some examples, the interface definition message may be obtained by defining an interface through a Define Inter-Process Communication (Define Inter-Process Communication, DEF-IPC).
在步骤S1031中,根据与被呼叫进程的接口标识匹配的接口定义信息,调用与接口定义信息对应的接口指针,以访问被呼叫进程的执行地址。In step S1031, according to the interface definition information matching the interface identifier of the called process, the interface pointer corresponding to the interface definition information is called to access the execution address of the called process.
接口指针指向接口。调用接口指针,即可访问被呼叫进程的执行地址,以完成呼叫进程与被呼叫进程之间的通信。An interface pointer points to an interface. By calling the interface pointer, the execution address of the called process can be accessed to complete the communication between the calling process and the called process.
需要说明的是,步骤S1032中的接口定义信息指的是与被呼叫进程的接口标识匹配的接口定义信息。It should be noted that the interface definition information in step S1032 refers to the interface definition information matching the interface identifier of the called process.
在步骤S1032中,接收来自被呼叫进程的响应信息,并将响应信息返回给呼叫进程。In step S1032, the response information from the called process is received, and the response information is returned to the calling process.
由于呼叫进程与被呼叫进程之间已经建立通信,因此可将来自被呼叫进程的响应信息通过被呼叫进程的接口和被呼叫进程的信道,返回给呼叫进程。完成一次呼叫进程与被呼叫进程间的通信。Since communication has been established between the calling process and the called process, the response information from the called process can be returned to the calling process through the interface of the called process and the channel of the called process. Complete a communication between the calling process and the called process.
图3为本发明一实施例中一种多进程间通信的装置的结构示意图。如图3所示,该多进程间通信的装置200可包括接收模块201、调用模块202和执行模块203。FIG. 3 is a schematic structural diagram of an apparatus for multi-process communication according to an embodiment of the present invention. As shown in FIG. 3 , the
接收模块201,用于接收来自呼叫进程的通信指令,通信指令包括操作系统中被呼叫进程的接口标识。The receiving module 201 is configured to receive a communication instruction from a calling process, where the communication instruction includes an interface identifier of the called process in the operating system.
调用模块202,用于基于被呼叫进程的接口标识,在操作系统的共享内存中调用与被呼叫进程的接口标识匹配的接口定义信息,接口定义信息用于定义进程的接口。The calling module 202 is configured to call interface definition information matching the interface identifier of the called process in the shared memory of the operating system based on the interface identifier of the called process, where the interface definition information is used to define the interface of the process.
执行模块203,用于根据与被呼叫进程的接口标识匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。The executing module 203 is configured to execute the communication between the calling process and the called process according to the interface definition information matched with the interface identifier of the called process.
在一些示例中,上述执行模块203可具体用于:根据与被呼叫进程的接口标识匹配的接口定义信息,调用与接口定义信息对应的接口指针,以访问被呼叫进程的执行地址;接收来自被呼叫进程的响应信息,并将响应信息返回给呼叫进程。In some examples, the above-mentioned execution module 203 may be specifically configured to: call the interface pointer corresponding to the interface definition information according to the interface definition information matching the interface identifier of the called process to access the execution address of the called process; The response information of the calling process, and the response information is returned to the calling process.
在本发明实施例中,在接收到来自呼叫进程的通信指令,可基于该通信指令中的被呼叫进程的接口标识,在共享内容中调用与被呼叫进程的接口标识匹配的接口定义信息。利用匹配的接口定义信息,执行呼叫进程与被呼叫进程之间的通信。也就是说,承载多进程间通信的方法的设备接收通信指令后,即可自动完成进程之间的通信。不需要开发人员或维护人员手动查找信息并建立通信,从而减少了多进程间通信所花费的时间,提高了多进程间通信的效率。In this embodiment of the present invention, upon receiving a communication instruction from a calling process, based on the interface identifier of the called process in the communication instruction, the interface definition information matching the interface identifier of the called process can be called in the shared content. Using the matched interface definition information, the communication between the calling process and the called process is performed. That is to say, after the device carrying the method for multi-process communication receives the communication instruction, it can automatically complete the communication between the processes. There is no need for developers or maintenance personnel to manually search for information and establish communication, thereby reducing the time spent in multi-process communication and improving the efficiency of multi-process communication.
图4为本发明另一实施例中一种多进程间通信的装置的结构示意图。图4与图3的不同之处在于,图4所示的多进程间通信的装置200还可包括定义模块204和编译模块205。FIG. 4 is a schematic structural diagram of an apparatus for multi-process communication according to another embodiment of the present invention. The difference between FIG. 4 and FIG. 3 is that the
定义模块204,用于将所有进程的接口定义信息写入操作系统的共享内存中。The definition module 204 is used for writing the interface definition information of all processes into the shared memory of the operating system.
编译模块205,用于将被呼叫进程的接口定义信息编译入可执行文件中的接口定义段,以使可执行文件被执行时实现对接口定义信息对应的接口指针的调用。The compiling module 205 is used for compiling the interface definition information of the called process into the interface definition section in the executable file, so that when the executable file is executed, the interface pointer corresponding to the interface definition information is called.
其中,共享内存中存储有可执行文件。Among them, executable files are stored in the shared memory.
在一些示例中,上述接口定义信息可包括接口标识、接口标识对应的接口所属的进程和接口标识对应的接口所属的进程的信道信息。In some examples, the above-mentioned interface definition information may include the interface identifier, the process to which the interface corresponding to the interface identifier belongs, and the channel information of the process to which the interface corresponding to the interface identifier belongs.
在一些示例中,定义模块204还可用于更新操作系统的共享内存中的进程的接口定义信息。In some examples, the definition module 204 may also be used to update interface definition information for processes in shared memory of the operating system.
图5为本发明实施例中一种多进程间通信的设备的结构示意图。如图5所示,多进程间通信的设备300包括存储器301、处理器302及存储在存储器301上并可在处理器302上运行的程序。FIG. 5 is a schematic structural diagram of a device for multi-process communication according to an embodiment of the present invention. As shown in FIG. 5 , the
在一个示例中,上述处理器302可以包括中央处理器(CPU),或者特定集成电路(ASIC),或者可以被配置成实施本申请实施例的一个或多个集成电路。In one example, the above-mentioned processor 302 may include a central processing unit (CPU), or a specific integrated circuit (ASIC), or may be configured as one or more integrated circuits implementing embodiments of the present application.
存储器301可以包括用于数据或指令的大容量存储器。举例来说而非限制,存储器301可包括HDD、软盘驱动器、闪存、光盘、磁光盘、磁带或通用串行总线(USB)驱动器或者两个或更多个以上这些的组合。在合适的情况下,存储器301可包括可移除或不可移除(或固定)的介质。在合适的情况下,存储器301可在多进程间通信的设备300的内部或外部。在特定实施例中,存储器301是非易失性固态存储器。在特定实施例中,存储器301包括只读存储器(ROM)。在合适的情况下,该ROM可以是掩模编程的ROM、可编程ROM(PROM)、可擦除PROM(EPROM)、电可擦除PROM(EEPROM)、电可改写ROM(EAROM)或闪存或者两个或更多个以上这些的组合。Memory 301 may include mass storage for data or instructions. By way of example and not limitation, memory 301 may include an HDD, floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or universal serial bus (USB) drive, or a combination of two or more of the above. Memory 301 may include removable or non-removable (or fixed) media, where appropriate. Memory 301 may be internal or external to
处理器302通过读取存储器301中存储的可执行程序代码来运行与可执行程序代码对应的程序,以用于控制上述实施例中多进程间通信的方法。The processor 302 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 301, so as to control the method for multi-process communication in the above-mentioned embodiment.
在一个示例中,多进程间通信的设备300还可包括通信接口303和总线304。其中,如图5所示,存储器301、处理器302、通信接口303通过总线304连接并完成相互间的通信。In one example, the
通信接口303,主要用于实现本申请实施例中各模块、装置、单元和/或设备之间的通信。也可通过通信接口303接入输入设备和/或输出设备。The communication interface 303 is mainly used to implement communication between modules, apparatuses, units, and/or devices in the embodiments of the present application. Input devices and/or output devices may also be accessed through the communication interface 303 .
总线304包括硬件、软件或两者,将多进程间通信的设备300的部件彼此耦接在一起。举例来说而非限制,总线304可包括加速图形端口(AGP)或其他图形总线、增强工业标准架构(EISA)总线、前端总线(FSB)、超传输(HT)互连、工业标准架构(ISA)总线、无限带宽互连、低引脚数(LPC)总线、存储器总线、微信道架构(MCA)总线、外围组件互连(PCI)总线、PCI-Express(PCI-X)总线、串行高级技术附件(SATA)总线、视频电子标准协会局部(VLB)总线或其他合适的总线或者两个或更多个以上这些的组合。在合适的情况下,总线304可包括一个或多个总线。尽管本申请实施例描述和示出了特定的总线,但本申请考虑任何合适的总线或互连。The bus 304 includes hardware, software, or both, coupling the components of the
本申请一实施例还提供一种存储介质,该存储介质上存储有程序,该程序被处理器执行时可控制上述实施例中的多进程间通信的方法。An embodiment of the present application further provides a storage medium, where a program is stored on the storage medium, and when the program is executed by a processor, the method for multi-process communication in the foregoing embodiment can be controlled.
需要明确的是,本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同或相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。对于装置实施例、设备实施例和存储介质实施例而言,相关之处可以参见方法实施例的说明部分。本发明并不局限于上文所描述并在图中示出的特定步骤和结构。本领域的技术人员可以在领会本发明的精神之后,作出各种改变、修改和添加,或者改变步骤之间的顺序。并且,为了简明起见,这里省略对已知方法技术的详细描述。It should be clear that each embodiment in this specification is described in a progressive manner, and the same or similar parts of each embodiment may be referred to each other, and each embodiment focuses on the differences from other embodiments. place. For the apparatus embodiment, the device embodiment, and the storage medium embodiment, reference may be made to the description part of the method embodiment for related parts. The invention is not limited to the specific steps and structures described above and shown in the drawings. Those skilled in the art may make various changes, modifications and additions, or change the order between steps, after appreciating the spirit of the present invention. Also, for the sake of brevity, detailed descriptions of known methods and techniques are omitted here.
以上的结构框图中所示的功能块可以实现为硬件、软件、固件或者它们的组合。当以硬件方式实现时,其可以例如是电子电路、专用集成电路(ASIC)、适当的固件、插件、功能卡等等。当以软件方式实现时,本发明的元素是被用于执行所需任务的程序或者代码段。程序或者代码段可以存储在机器可读介质中,或者通过载波中携带的数据信号在传输介质或者通信链路上传送。“机器可读介质”可以包括能够存储或传输信息的任何介质。机器可读介质的例子包括电子电路、半导体存储器设备、ROM、闪存、可擦除ROM(EROM)、软盘、CD-ROM、光盘、硬盘、光纤介质、射频(RF)链路,等等。代码段可以经由诸如因特网、内联网等的计算机网络被下载。The functional blocks shown in the above structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, elements of the invention are programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted over a transmission medium or communication link by a data signal carried in a carrier wave. A "machine-readable medium" may include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, and the like. The code segments may be downloaded via a computer network such as the Internet, an intranet, or the like.
Claims (13)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910004763.6A CN111400055A (en) | 2019-01-03 | 2019-01-03 | Method, device, equipment and storage medium for communication among multiple processes |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910004763.6A CN111400055A (en) | 2019-01-03 | 2019-01-03 | Method, device, equipment and storage medium for communication among multiple processes |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111400055A true CN111400055A (en) | 2020-07-10 |
Family
ID=71430196
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910004763.6A Pending CN111400055A (en) | 2019-01-03 | 2019-01-03 | Method, device, equipment and storage medium for communication among multiple processes |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111400055A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1595363A (en) * | 2003-05-09 | 2005-03-16 | 太阳微系统公司 | Interprocess communication in operating system partition |
US20080127206A1 (en) * | 2006-08-02 | 2008-05-29 | Microsoft Corporation Microsoft Patent Group | Conducting client-server inter-process communication |
CN101739300A (en) * | 2008-11-18 | 2010-06-16 | 中兴通讯股份有限公司 | Method and system for inter-process communication of multimedia terminal |
CN107133109A (en) * | 2017-04-24 | 2017-09-05 | 京信通信系统(广州)有限公司 | A kind of method of intermodule communication, device and computing device |
CN107688502A (en) * | 2017-08-18 | 2018-02-13 | 苏州科达特种视讯有限公司 | Inter-process communication methods and device |
-
2019
- 2019-01-03 CN CN201910004763.6A patent/CN111400055A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1595363A (en) * | 2003-05-09 | 2005-03-16 | 太阳微系统公司 | Interprocess communication in operating system partition |
US20080127206A1 (en) * | 2006-08-02 | 2008-05-29 | Microsoft Corporation Microsoft Patent Group | Conducting client-server inter-process communication |
CN101739300A (en) * | 2008-11-18 | 2010-06-16 | 中兴通讯股份有限公司 | Method and system for inter-process communication of multimedia terminal |
CN107133109A (en) * | 2017-04-24 | 2017-09-05 | 京信通信系统(广州)有限公司 | A kind of method of intermodule communication, device and computing device |
CN107688502A (en) * | 2017-08-18 | 2018-02-13 | 苏州科达特种视讯有限公司 | Inter-process communication methods and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10956167B2 (en) | Mechanism for instruction fusion using tags | |
CN108920135B (en) | User-defined service generation method and device, computer equipment and storage medium | |
CN110989926B (en) | Faulty disk slot location method, device and electronic equipment | |
CN110096424B (en) | Test processing method and device, electronic equipment and storage medium | |
CN108694052B (en) | Firmware upgrading method, firmware upgrading device and firmware upgrading system | |
CN110960855B (en) | Communication protocol code updating method and device, electronic equipment and storage medium | |
CN111506904B (en) | Method and device for online bug repair | |
CN108121686A (en) | Multiprocessor and multicomputer system | |
CN111208933A (en) | Data access method, device, equipment and storage medium | |
CN110659210A (en) | Information acquisition method and device, electronic equipment and storage medium | |
CN116455694A (en) | Baud rate setting method, baud rate setting device, baud rate setting equipment and storage medium | |
CN112162919A (en) | Debugging method and system for vehicle-mounted equipment and computer readable storage medium | |
CN114444423B (en) | Data processing method and system based on verification platform and electronic equipment | |
CN111400055A (en) | Method, device, equipment and storage medium for communication among multiple processes | |
WO2025025729A1 (en) | Application firewall implementation method for embedded device, storage medium, and apparatus | |
CN118820063A (en) | Code verification method, system, device and computer storage medium | |
CN117492802A (en) | Public updating device | |
CN110825461A (en) | Data processing method and device | |
US20190179630A1 (en) | Detecting software incompatibilities within a system stack | |
CN114666806B (en) | Wireless network virtualization method, device, equipment and storage medium | |
CN114675822A (en) | AUTOSAR software component development method, apparatus, equipment and storage medium | |
CN115113871A (en) | Method, device and device for viewing front-end code version information based on data center | |
CN115202632A (en) | Development Method of AUTOSAR Software Component Function Interface Based on Matlab/Simulink | |
US10922249B2 (en) | Input/output control code filter | |
CN111209056B (en) | Method and device for loading function, readable storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200710 |
|
RJ01 | Rejection of invention patent application after publication |