Cross-process communication method, cross-process communication system and vehicle-mounted terminal
By building an intermediate service cluster in the Android platform and dynamically managing load, the problems of high complexity and low performance in inter-process communication are solved, and the efficiency and user experience of inter-process communication are improved.
Patent Information
- Application Number
- CN202411281267.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-09-13
AI Technical Summary
AIDL in the existing Android platform has problems such as high complexity, difficulty in troubleshooting and low performance in inter-process communication, resulting in limited improvement in application experience on high-performance hardware.
By building an intermediate service cluster between the application process and the cluster process, dynamically manage intermediate service loads, transfer high-load to low-load intermediate services, and realize load balancing and communication efficiency improvement between processes.
It simplifies the development and maintenance of inter-process communication, improves communication efficiency and user experience, and reduces code maintenance costs.
Smart Images

Figure CN118796516B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to an inter-process communication method, an inter-process communication system and a vehicle-mounted terminal. Background Art
[0002] With the popularity of mobile devices and the continuous advancement of technology, IPC (Inter-Process Communication) has become increasingly important in the Android system. Currently, the Android platform mainly relies on AIDL (Android Interface Definition Language) to implement data exchange and method calls between processes. However, AIDL has a series of challenges and limitations in practical applications. These challenges not only increase the complexity of software development, but may also affect system stability and user experience.
[0003] At present, AIDL still has the following defects: high implementation complexity, strict consistency between the client and the server, any slight changes in the interface or new functions need to be updated synchronously to both ends, and the strong coupling greatly increases the difficulty of code maintenance; error troubleshooting is difficult. Since the fundamental principle of AIDL is addressing, if the client and server codes are not synchronized, there may be problems with inconsistent interface calls and responses. Error location and debugging are very difficult, which also increases maintenance costs; low performance. In today's context of rapidly improving hardware performance and continuously declining storage costs, the existing IPC mechanism has failed to fully utilize the strategy of exchanging space for time, resulting in limited improvement in application experience on high-performance hardware.
[0004] Therefore, the existing AIDL has obvious deficiencies in implementation complexity, error troubleshooting, and performance optimization, and has failed to achieve the goal of simplifying development and improving performance. There is an urgent need for an IPC solution that is easy to develop and maintain to adapt to the high performance requirements of modern mobile devices and improve the application experience. Summary of the invention
[0005] In view of the above-mentioned shortcomings of the prior art, the present invention discloses an inter-process communication method, an inter-process communication system and a vehicle-mounted terminal, which are used to solve the technical problem of low performance of the inter-process communication method in the prior art.
[0006] In a first aspect, the present invention provides a cross-process communication method, the method comprising: constructing an intermediate service cluster between an application process and a cluster process in advance, wherein the intermediate service cluster includes multiple intermediate services that communicate with each other, the application process is a service process that sends a service request, and the cluster process is a service process that responds to the service request; obtaining the actual load of each of the intermediate services in the communication link from the application process to the cluster process; if the actual load of any intermediate service is greater than a preset load threshold, determining the arbitrary intermediate service as a high-load intermediate service, otherwise, determining the arbitrary intermediate service as a low-load intermediate service; transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services, so as to realize one or more of the intermediate services collaboratively transmitting information between the application process and the cluster process.
[0007] In one embodiment of the present invention, the construction method of the intermediate service cluster includes: creating an interface class for cross-process communication, wherein the interface class includes a request interface and a response interface; configuring multiple intermediate services according to the cluster process, and according to a preset allocation principle, allocating each application process to each intermediate service for management, wherein the allocation principle is allocation according to the number of application processes; for each intermediate service, sending an intermediate service proxy object to each application process managed, and receiving an application process proxy object sent by each application process managed, establishing a connection between the application process and the cluster process based on the intermediate service, and forming the intermediate service cluster.
[0008] In one embodiment of the present invention, each of the intermediate services manages multiple application processes; transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services includes: obtaining the load occupancy of each of the application processes managed by the high-load intermediate service; determining at least one load receiving object from the low-load intermediate service based on the size of the actual load; comparing the load occupancy with a preset occupancy threshold; transferring one or more application processes whose load occupancy is less than or equal to the occupancy threshold to the load receiving object; or, collaboratively managing one or more application processes whose load occupancy is greater than the occupancy threshold through the high-load intermediate service and the load receiving object.
[0009] In one embodiment of the present invention, transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services includes: obtaining the request frequency of each of the application processes managed by the high-load intermediate service within a preset time period; determining at least one load receiving object from the low-load intermediate service based on the size of the actual load; and transferring part of the load in the high-load intermediate service to at least one of the load receiving objects based on the request frequency.
[0010] In one embodiment of the present invention, each of the intermediate services manages multiple application processes; transferring part of the load in the high-load intermediate service to at least one load-bearing object according to the request frequency includes: comparing the request frequency with a preset first frequency threshold; if the request frequency of any application process is less than or equal to the first frequency threshold, determining the any application process as a target application process to be transferred; and transferring all service requests of the target application process to at least one load-bearing object.
[0011] In one embodiment of the present invention, each of the intermediate services manages multiple application processes; transferring part of the load in the high-load intermediate service to at least one of the load-bearing objects according to the request frequency also includes: comparing the request frequency with a preset second frequency threshold; if the request frequency of any application process is greater than the second frequency threshold, determining the any application process as a target application process to be transferred; and transferring part of the service requests of the target application process to at least one of the load-bearing objects.
[0012] In one embodiment of the present invention, the actual load includes memory occupancy and processor occupancy; determining at least one load receiving object from the low-load intermediate service based on the size of the actual load includes: calculating the memory occupancy mean, memory occupancy standard deviation, processor occupancy mean and processor occupancy standard deviation corresponding to all low-load intermediate services based on the memory occupancy and the processor occupancy; for each of the low-load intermediate services, calculating the memory occupancy, the memory occupancy mean and the memory occupancy standard deviation to obtain a first standardized value of memory occupancy, and calculating the processor occupancy, the processor occupancy mean and the processor occupancy standard deviation to obtain a second standardized value of processor occupancy; calculating the first standardized value and the second standardized value based on a preset weight coefficient to obtain a performance index of each of the low-load intermediate services; comparing the performance index with a preset performance index threshold, and determining the low-load intermediate service whose performance index is less than or equal to the performance index threshold as the load receiving object.
[0013] In one embodiment of the present invention, after transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services, it also includes: for each of the application processes, determining the corresponding target intermediate service according to the intermediate service proxy object; sending the service request to the corresponding target intermediate service based on the request interface; the target intermediate service determines the target cluster process to be called by each of the application processes according to the service request, obtains subscription data from the target cluster process based on the response interface, and returns the subscription data to each of the application processes.
[0014] In a second aspect, the present invention provides a cross-process communication system, the system comprising: a construction module, used to pre-build an intermediate service cluster between an application process and a cluster process, wherein the intermediate service cluster includes multiple intermediate services that communicate with each other, the application process is a service process that sends a request service, and the cluster process is a service process that responds to the request service; an acquisition module, used to obtain the actual load of each of the intermediate services in the communication link from the application process to the cluster process; a determination module, used to determine any intermediate service as a high-load intermediate service if the actual load of any intermediate service is greater than a preset load threshold, otherwise, determine any intermediate service as a low-load intermediate service; a transfer module, used to transfer part of the load in the high-load intermediate service to at least one of the low-load intermediate services, so as to realize one or more intermediate services to collaboratively transmit information between the application process and the cluster process.
[0015] In a third aspect, the present invention provides a vehicle-mounted terminal, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the vehicle-mounted terminal implements the cross-process communication method described in the first aspect.
[0016] As described above, the cross-process communication method, cross-process communication system and vehicle-mounted terminal provided by the embodiments of the present invention have the following beneficial effects:
[0017] An intermediate service cluster is pre-built between the application process and the cluster process, and the intermediate service cluster includes multiple intermediate services that communicate with each other. The application process is the service process that sends service requests, and the cluster process is the service process that responds to service requests. By obtaining the actual load of each intermediate service in the communication link from the application process to the cluster process, if the actual load of any intermediate service is greater than a preset load threshold, any intermediate service is determined as a high-load intermediate service, otherwise, any intermediate service is determined as a low-load intermediate service, and part of the load in the high-load intermediate service is transferred to at least one low-load intermediate service, so that one or more intermediate services can collaboratively transmit information between the application process and the cluster process, unify the communication interface in the form of a communication cluster, and dynamically manage the distribution of application processes, so as to realize centralized management of processes and global communication between processes, and dynamically balance the load of each intermediate service, thereby improving the communication efficiency between processes, and also improving application performance and user experience.
[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present invention, and together with the specification, are used to explain the principles of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0020] Figure 1 is a schematic diagram of an implementation environment of an inter-process communication system shown in an exemplary embodiment of the present invention;
[0021] Figure 2 is a flow chart of an inter-process communication method shown in an exemplary embodiment of the present invention;
[0022] Figure 3 is a schematic diagram of an intermediate service cluster shown in an exemplary embodiment of the present invention;
[0023] Figure 4 is a schematic diagram of an intermediate service load transfer shown in an exemplary embodiment of the present invention;
[0024] Figure 5 is a flowchart of a specific inter-process communication method shown in an exemplary embodiment of the present invention;
[0025] Figure 6 is a block diagram of an inter-process communication system shown in an exemplary embodiment of the present invention;
[0026] Figure 7 It is a structural schematic diagram of a vehicle-mounted terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0027] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.
[0028] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present invention in a schematic manner, and thus the illustrations only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the form, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0029] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0030] Cross-process communication, also known as inter-process communication, refers to the process of exchanging data between two processes. At present, data exchange and method calls between processes are usually implemented based on AIDL. However, the inventors of the present invention have found that AIDL still has the following defects: high implementation complexity, strict consistency between the client and the server, any slight changes in the interface or new functions need to be updated synchronously to both ends, and the strong coupling greatly increases the difficulty of code maintenance; error troubleshooting is difficult, because the fundamental principle of AIDL is addressing, if the client and server codes are not synchronized, there may be problems with inconsistent interface calls and responses, error location and debugging are very difficult, and maintenance costs are increased; low performance, in today's context of rapidly improving hardware performance and continuously declining storage costs, the existing IPC mechanism has failed to fully utilize the strategy of exchanging space for time, resulting in limited improvement in application experience on high-performance hardware.
[0031] Therefore, see Figure 1 , Figure 1 FIG. 1 is a schematic diagram of an implementation environment of an inter-process communication system shown in an exemplary embodiment of the present invention. Figure 1As shown, the implementation environment includes a vehicle 110 and a cross-process communication system 120, wherein the cross-process communication system 120 is embedded in the vehicle 110 and is used to realize communication between processes in the vehicle 110. The cross-process communication 120 includes but is not limited to a vehicle-mounted system, a vehicle-mounted computer, etc., and unifies the communication interface in the form of a communication cluster, and dynamically manages the distribution of application processes, thereby realizing centralized management of processes and global communication between processes, and dynamically balancing the load of each intermediate service, thereby improving the communication efficiency between processes, and also improving application performance and user experience.
[0032] See also Figure 2 , Figure 2 is a flowchart of an inter-process communication method shown in an exemplary embodiment of the present invention. The method can be applied to Figure 1 The implementation environment shown, it should be understood that the method can also be applied to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable. In addition, in the embodiment of the present invention, the cross-process communication method can be applied to the Android system, that is, it can be applied to mobile devices of the Android system, such as mobile phones, car terminals, etc.
[0033] like Figure 2 As shown, in an exemplary embodiment, the inter-process communication method includes at least steps S210 to S240, which are described in detail as follows:
[0034] Step S210, pre-build an intermediate service cluster between the application process and the cluster process, wherein the intermediate service cluster includes a plurality of intermediate services that communicate with each other, the application process is a service process that sends a service request, and the cluster process is a service process that responds to the service request.
[0035] It should be noted that during inter-process communication, a process can both receive requests from other processes and request other processes, that is, the process can act as both a server and a client. In the intermediate service cluster, all processes can make requests and responses. In the embodiment of the present invention, the process that sends a service request is called an application process, and the process that responds to a service request is called a cluster process.
[0036] Specifically, the construction method of the intermediate service cluster includes: creating an interface class for cross-process communication, wherein the interface class includes a request interface and a response interface; configuring multiple intermediate services according to the cluster process, and according to a preset allocation principle, allocating each application process to each intermediate service for management, wherein the allocation principle is to allocate according to the number of application processes; for each intermediate service, sending the intermediate service proxy object to each application process managed, and receiving the application process proxy object sent by each application process managed, establishing a connection between the application process and the cluster process based on the intermediate service, and forming an intermediate service cluster.
[0037] First, create an AIDL interface class, which contains two interfaces, namely the request interface and the response interface. The request interface and the response interface are two interfaces of the intermediate service cluster. They are asynchronous request responses to each other. The application process can send a request based on the request interface and receive a response to the request based on the response interface. All inter-process communications are based on these two interfaces. In this way, the interface is unified and the cost of interface operation and maintenance is reduced.
[0038] Then, multiple intermediate services are configured according to the cluster process, that is, each intermediate service can be connected to each cluster process, wherein the number of intermediate services and the load of each intermediate service are set according to demand, and each application process is allocated to each intermediate service management according to the preset number, and the application process distribution is managed in a cluster manner. For example, if 3 intermediate services are configured and there are 30 application processes, 10 application processes are allocated to each intermediate service. This is the allocation when the intermediate service cluster is initialized, and the distribution of application processes will be adjusted later according to the load of each intermediate service.
[0039] In addition, for each intermediate service, after being divided into multiple application processes, the intermediate service proxy object will be sent to each application process managed, and the application process proxy object sent by each application process managed will be received and stored. In this way, the application process can find the intermediate service that manages it according to the intermediate service proxy object, send a request to it, and the corresponding intermediate service will find the requested cluster process, and establish a connection between the application process and the cluster process based on the intermediate service, thereby forming an intermediate service cluster. Inter-process communication is implemented based on the intermediate service cluster. For the outside, the cluster will not change, and only the dynamic adjustment of application process management is performed internally. In addition, the intermediate service is only responsible for transmitting requests and returning data, and does not need to know the specific operation of each request. That is, if the configuration content and destination of inter-process communication are different, the intermediate service cluster will realize the difference, and the processes are unknown to each other and do not establish communication. Among them, the management of the application process by the intermediate service is to hold the proxy object of the application process, and then the request of the application process can be distributed to the corresponding cluster process.
[0040] See also Figure 3 , Figure 3 FIG. 1 is a schematic diagram of an intermediate service cluster shown in an exemplary embodiment of the present invention. Figure 3 As shown in the figure, the intermediate service cluster includes three intermediate services, namely intermediate service 1, intermediate service 2 and intermediate service 3. Inter-process communication can send service requests to the corresponding intermediate service implementation based on the request interface of the intermediate service cluster. In the process, each is a request process and a response process. Everyone only holds an instance of the intermediate service cluster, that is, the intermediate service proxy object that accesses the cluster process. The intermediate service cluster finds the corresponding cluster process for the application process's request. From the beginning to the end, any application process only holds the proxy object of the intermediate service, while the intermediate service holds the proxy objects of all the application processes it manages, which greatly improves the convenience of development.
[0041] It should also be noted that in the process of inter-process communication, the problems faced include the process timing of startup, the selection of intermediate services, the retry mechanism for unresponsive requests, the rewriting of AIDL scripts so that the intermediate service clusters share the same kernel space, the internal distribution and strategy selection of the intermediate service clusters, and the registration of different interfaces in the same process. These problems are solved by performing redundant callback objects on the client and managing the callback object operations.
[0042] For example, for the registration problem of different interfaces in the same process, the intermediate service cluster can distribute a copy of the data, and the application process that receives the corresponding data must manage all interface registration callbacks and distribute them to each interface through callbacks. That is, the application process registers the data twice and distributes it to two interfaces.
[0043] Step S220, obtaining the actual load of each intermediate service in the communication link from the application process to the cluster process.
[0044] It should be noted that when the intermediate service cluster is constructed, each intermediate service is assigned the same load bearing capacity. However, as inter-process communication proceeds, each intermediate service manages different application processes, resulting in different actual loads of each intermediate service. In order to ensure the efficiency of inter-process communication, the intermediate service load will be balanced based on the actual load of each intermediate service. In this way, the performance of the intermediate service cluster can be guaranteed, so that each intermediate service can continue to provide services.
[0045] Step S230: If the actual load of any intermediate service is greater than a preset load threshold, any intermediate service is determined as a high-load intermediate service; otherwise, any intermediate service is determined as a low-load intermediate service.
[0046] In the embodiment of the present invention, before load balancing is performed, it is necessary to first determine the high-load intermediate service and the low-load intermediate service to balance the load of the high-load intermediate service to the low-load intermediate service. The number of the high-load intermediate service and the number of the low-load intermediate service are both at least one.
[0047] It should be noted that the preset load threshold is smaller than the load bearing capacity initially allocated to each intermediate service. This avoids load transfer when the load of the intermediate service reaches 100%, and does not cause any intermediate service to be fully loaded, resulting in low efficiency or failure of inter-process communication.
[0048] In addition, the actual load refers to the memory usage and processor usage of the current communication flow, which is affected by the communication requests between processes. That is, process management is performed in a way that dynamically abandons and dynamically obtains application processes based on the memory usage and CPU (Central Processing Unit) usage of the current communication flow.
[0049] Step S240: transferring part of the load in the high-load intermediate service to at least one low-load intermediate service, so as to enable one or more intermediate services to collaboratively transmit information between the application process and the cluster process.
[0050] In the embodiment of the present invention, each intermediate service can communicate with each other, and based on the process management algorithm, part of the load in the high-load intermediate service can be transferred to at least one low-load intermediate service. In addition, each intermediate service manages multiple application processes during initialization, and one or more intermediate services cooperate to transmit information between application processes and cluster processes, including one intermediate service responsible for transmitting information between one application process and all cluster processes, one intermediate service load transmitting information between multiple application processes and all cluster processes, and multiple intermediate services responsible for transmitting information between one application process and all cluster processes.
[0051] In one embodiment, part of the load in a high-load intermediate service is transferred to at least one low-load intermediate service, including: obtaining the load occupancy of each application process managed by the high-load intermediate service; determining at least one load receiving object from the low-load intermediate service based on the actual load size; comparing the load occupancy with a preset occupancy threshold; transferring one or more application processes whose load occupancy is less than or equal to the occupancy threshold to the load receiving object; or, collaboratively managing one or more application processes whose load occupancy is greater than the occupancy threshold through the high-load intermediate service and the load receiving object.
[0052] In this embodiment, one or more application processes with small load occupancy of the high-load intermediate service can be transferred to the load-bearing object for management. At this time, the high-load intermediate service will give the proxy object of the transferred application process to the load-bearing object, and the high-load intermediate service will no longer hold it; or the high-load intermediate service and the load-bearing object can jointly manage one or more application processes with large load occupancy. At this time, the high-load intermediate service and the load-bearing object jointly hold the proxy object of the one or more application processes. One or more intermediate services can be used to collaboratively transmit information between application processes and cluster processes.
[0053] In a possible embodiment, the occupancy threshold includes a first occupancy threshold and a second occupancy threshold, and the first occupancy threshold is less than or equal to the second occupancy threshold, then one or more application processes whose load occupancy is less than or equal to the first occupancy threshold are transferred to the load receiving object; or, one or more application processes whose load occupancy is greater than the second occupancy threshold are collaboratively managed through a high-load intermediate service and the load receiving object.
[0054] In one embodiment, part of the load in a high-load intermediate service is transferred to at least one low-load intermediate service, including: obtaining the request frequency of each application process managed by the high-load intermediate service within a preset time period; determining at least one load-bearing object from the low-load intermediate service based on the actual load size; and transferring part of the load in the high-load intermediate service to at least one load-bearing object based on the request frequency.
[0055] In this embodiment, considering that some application processes frequently communicate and cause the intermediate service load to be too high, as a possible embodiment, part of the load in the high-load intermediate service can be transferred to at least one load-bearing object according to the request frequency of the application process, that is, part of the requests of the application process with a high request frequency can be given to the load-bearing object for management, or all the requests of the application process with a low request frequency can be given to the load-bearing object for management. In this way, load balancing of each intermediate service in the intermediate service cluster is achieved.
[0056] Specifically, part of the load in the high-load intermediate service is transferred to at least one load receiving object according to the request frequency, including: comparing the request frequency with a preset first frequency threshold; if the request frequency of any application process is less than or equal to the first frequency threshold, then determining any application process as a target application process to be transferred; and transferring all service requests of the target application process to at least one load receiving object.
[0057] In this embodiment, all requests of the target application process with low request frequency are given to the load-bearing object for management, so as to achieve load balancing of the intermediate services in the intermediate service cluster and ensure the performance of frequent communication.
[0058] Specifically, transferring part of the load in the high-load intermediate service to at least one load receiving object according to the request frequency also includes: comparing the request frequency with a preset second frequency threshold; if the request frequency of any application process is greater than the second frequency threshold, determining any application process as a target application process to be transferred; and transferring part of the service requests of the target application process to at least one load receiving object.
[0059] The second frequency threshold is greater than or equal to the first frequency threshold. In this embodiment, some requests of the target application process with high request frequency are given to the load receiving object for management, so as to achieve load balancing of each intermediate service in the intermediate service cluster and ensure the performance of frequent communication.
[0060] See also Figure 4 , Figure 4 FIG. 1 is a schematic diagram showing an intermediate service load transfer according to an exemplary embodiment of the present invention. Figure 4 As shown, the intermediate service cluster includes intermediate service 1, intermediate service 2 and intermediate service 3. The intermediate services can communicate with each other and give up the management of some application processes to other intermediate services to achieve load balancing of the intermediate services in the intermediate service cluster.
[0061] It should also be noted that in the process of process load balancing, there may be multiple load-bearing objects. At this time, the high-load intermediate service distributes the transferred load to each load-bearing object according to the actual load situation of each load-bearing object. For example, the load can be divided evenly or proportionally, or after distributing the load, each load-bearing object can reach a load-balanced state.
[0062] In one embodiment, the actual load includes memory occupancy and processor occupancy; according to the size of the actual load, at least one load-bearing object is determined from the low-load intermediate service, including: according to the memory occupancy and the processor occupancy, the memory occupancy mean, the memory occupancy standard deviation, the processor occupancy mean and the processor occupancy standard deviation corresponding to all low-load intermediate services are calculated; for each low-load intermediate service, the memory occupancy, the memory occupancy mean and the memory occupancy standard deviation are calculated to obtain a first standardized value of the memory occupancy, and the processor occupancy, the processor occupancy mean and the processor occupancy standard deviation are calculated to obtain a second standardized value of the processor occupancy; according to a preset weight coefficient, the first standardized value and the second standardized value are calculated to obtain a performance index of each low-load intermediate service; the performance index is compared with a preset performance index threshold, and the low-load intermediate service whose performance index is less than or equal to the performance index threshold is determined as the load-bearing object.
[0063] In this embodiment, the standard deviation is calculated based on the memory occupancy and processor occupancy of the intermediate service, and a normal distribution is performed, and then a relatively idle intermediate service is selected to manage the communication of the transferred application process. This process is a real-time dynamic process. Compared with writing in a fixed intermediate service during testing and debugging, or artificially placing large communication processes in low-load intermediate services, this way, all application processes in the system can be easily configured, and a statistical distribution method can be used to ensure the communication performance of the intermediate service cluster and ensure that the communication efficiency between processes is not affected.
[0064] In one embodiment, after transferring part of the load in the high-load intermediate service to at least one low-load intermediate service, it also includes: for each application process, determining the corresponding target intermediate service according to the intermediate service proxy object; sending the service request to the corresponding target intermediate service based on the request interface; the target intermediate service determines the target cluster process called by each application process according to the service request, obtains subscription data from the target cluster process based on the response interface, and returns the subscription data to each application process.
[0065] It should be noted that for the request interface, the parameter is a String (i.e., a string data type) in the following format: service name / function name / subscription request / data; for the response interface, the parameter is a String in the following format: service name / function name / data.
[0066] In this embodiment, for each application process, the corresponding target intermediate service is determined according to the intermediate service proxy object. After the request is sent to the target intermediate service, the target intermediate service parses the request and obtains the corresponding service name. The intermediate service then establishes communication with the requested cluster process and sends the function name / request subscription / data part to the cluster process for response, which is then notified to the corresponding application process through the intermediate service.
[0067] In a possible embodiment, if the target intermediate service determines that it does not hold a proxy object of a certain application process after receiving the request, it traverses other intermediate services until an intermediate service that manages the application process is found. This usually occurs when the load is being transferred.
[0068] In a possible embodiment, the inter-process communication method is applied to an Android system, including: pre-building an intermediate service cluster between an application process and a cluster process of the Android system, the intermediate service cluster including multiple intermediate services that communicate with each other, the application process being a service process that sends a service request, and the cluster process being a service process that responds to the service request; obtaining the actual load of each intermediate service in the communication link from the application process to the cluster process in the Android system; if the actual load of any intermediate service is greater than a preset load threshold, determining any intermediate service as a high-load intermediate service, otherwise, determining any intermediate service as a low-load intermediate service; transferring part of the load in the high-load intermediate service to at least one low-load intermediate service, so as to realize one or more intermediate services collaboratively transmitting information between the application process and the cluster process in the Android system.
[0069] Taking car computer development as an example, there are many inter-process communication scenarios in the development. Now there are three processes: air-conditioning process, which includes functions such as air-conditioning start, temperature adjustment, and one-key chair comfort; system UI (User Interface) process, which can control seats, air-conditioning, etc.; hardware service process, which is responsible for the hardware that implements these operation signals to response signals.
[0070] Traditionally, if the air conditioning process wants to turn on the air conditioning, it needs to send a turn-on signal to the hardware service process. In this case, the air conditioning process and the hardware service process need to establish communication and formulate a response interface. In addition, both the air conditioning process and the hardware service process need to save an AIDL interface specification for communication. Now, the air conditioning process and the hardware service process no longer need to establish communication, and their interface instances are saved by the intermediate service cluster. Two interfaces are implemented between processes, and the specifications are unified. After booting, each process implements its own interface and obtains and holds the IBinder instance (i.e., proxy object) of the intermediate service.
[0071] The air conditioning process needs to turn on the air conditioner, so the air conditioning process sends a turn-on signal to the intermediate service cluster. The request interface parameters of calling the intermediate service indicate that the operation needs to be sent to the hardware service process to perform the specific operation. The request parameters are HardWareService (hardware service process) / HvacPower (air conditioning power function) / request (request subscription) / 2 (open). After receiving the request, the intermediate service knows through the request parameters that the data needs to be sent to the HardWareService hardware service process. At this time, the intermediate service will traverse and find the corresponding hardware service process through the request parameters, and append the identifier of the air conditioning process to the request parameters. The request parameters are HvacService (air conditioning process) / HvacPower / request / {param:2, response:true}. At this time, the hardware service process HardWareService receives the above request parameters and knows that it is the air conditioning process that makes the request. Then it parses the data and finds that it is the air conditioning power function that is parsing the parameter request. Then according to the 2 in the request parameters, it finds that the air conditioning function is to be turned on. So after executing the operation, it calls the response interface of the intermediate service cluster. The parameters are as follows: HvacService / HvacPower / OK and are given to the intermediate service cluster. After receiving the data through the response interface, the corresponding intermediate service in the intermediate service cluster knows that this is the execution result of turning on the air conditioning. Repeat the above steps to find the managed HvacService air conditioning process, and call the response interface of the air conditioning process to give the result to the air conditioning process. At this point, the air conditioning turn-on function is implemented when the air conditioning process and the hardware service process are completely unknown and no communication is established.
[0072] Then there is a scenario where the system UI process also wants to operate the air conditioner, but does not want to care about the results given by the air conditioner. There are two routes. The first is that the system UI process communicates directly with the hardware service process through the intermediate service cluster. The second is that the system UI process communicates with the air conditioner process through the intermediate service cluster, and then performs the air conditioner process function operation. No matter which one, the intermediate service cluster provides services.
[0073] See also Figure 5 , Figure 5 FIG. 1 is a flowchart of a specific cross-process communication method shown in an exemplary embodiment of the present invention. Figure 5 As shown, there are three intermediate services, which manage the air conditioning process, the system UI process and the hardware service process respectively. The system UI process communicates with the air conditioning process through the intermediate service of the management system UI process in the intermediate service cluster to request to turn on the air conditioner. After receiving the request, the air conditioning process requests the hardware service process through the intermediate service of the management air conditioning process. After receiving the request from the air conditioning process, the hardware service process executes the operation.
[0074] In addition, if the air conditioning process turns on one-touch comfort, because there is a speed condition for turning on one-touch comfort, for example, speed>100Km / h, if turning on one-touch comfort is a dangerous behavior, because the driver needs to stay focused at high speeds, then the air conditioning process will continuously obtain data uplink from the hardware service process. In order to ensure the real-time and efficiency of the speed, the speed change of 0-100 may require 100 inter-process communications. Without optimization, the intermediate service that manages the communication between the two processes is in a high-load situation. At this time, the currently managed intermediate service will determine the relatively idle ones among other intermediate services, and can give the application process part managed by itself to other intermediate services, focusing on the communication from the hardware service process to the air conditioning process. At this time, due to the consistent interface, the intermediate service Service1 that manages the hardware service process calls the request interface with the parameter Service2 / abandon / request / {process:UserClient}. After a low-load intermediate service Service2 gets it, it sends UserClient / receive / response / {process:Service2} to UserClient (application process). At this time, the low-load intermediate service Service2 manages UserClient.
[0075] The above-mentioned cross-process communication method pre-builds an intermediate service cluster between the application process and the cluster process, and the intermediate service cluster includes multiple intermediate services that communicate with each other. The application process is a service process that sends service requests, and the cluster process is a service process that responds to service requests. By obtaining the actual load of each intermediate service in the communication link from the application process to the cluster process, if the actual load of any intermediate service is greater than a preset load threshold, any intermediate service is determined as a high-load intermediate service. Otherwise, any intermediate service is determined as a low-load intermediate service, and part of the load in the high-load intermediate service is transferred to at least one low-load intermediate service, thereby realizing one or more intermediate services to collaboratively transmit information between the application process and the cluster process, unifying the communication interface in the form of a communication cluster, and dynamically managing the distribution of application processes, realizing centralized management of processes and global communication between processes, and dynamically balancing the load of each intermediate service, thereby improving the communication efficiency between processes, and also improving application performance and user experience.
[0076] See also Figure 6 , Figure 6 is a block diagram of an inter-process communication system shown in an exemplary embodiment of the present invention. The system can be applied to Figure 1The implementation environment shown is a schematic diagram. It should be understood that the system may also be applicable to other exemplary implementation environments, and this embodiment does not limit the implementation environment to which the system is applicable.
[0077] like Figure 6 As shown, in an exemplary embodiment, the inter-process communication system 600 includes at least a construction module 610, an acquisition module 620, a determination module 630 and a transfer module 640, which are described in detail as follows:
[0078] A construction module 610 is used to construct an intermediate service cluster between the application process and the cluster process in advance, wherein the intermediate service cluster includes a plurality of intermediate services that communicate with each other, the application process is a service process that sends a request service, and the cluster process is a service process that responds to the request service;
[0079] An acquisition module 620 is used to acquire the actual load of each intermediate service in the communication link from the application process to the cluster process;
[0080] A determination module 630, configured to determine any intermediate service as a high-load intermediate service if the actual load of any intermediate service is greater than a preset load threshold, otherwise, determine any intermediate service as a low-load intermediate service;
[0081] The transfer module 640 is used to transfer part of the load in the high-load intermediate service to at least one low-load intermediate service, so as to realize the coordinated transmission of information between the application process and the cluster process by one or more intermediate services.
[0082] It should be noted that the inter-process communication system provided in the above embodiment and the inter-process communication method provided in the above embodiment belong to the same concept, wherein the contents of the operations performed by each module have been described in detail in the method embodiment and will not be repeated here.
[0083] See also Figure 7 , Figure 7 It is a structural schematic diagram of a vehicle-mounted terminal provided by an embodiment of the present invention. Figure 7 The schematic diagram of the structure of the computer system of the vehicle terminal suitable for implementing the embodiment of the present invention is shown. It should be noted that: Figure 7 The computer system 700 of the vehicle-mounted terminal shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0084] like Figure 7As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 702 or the program loaded from the storage part 708 to the random access memory (RAM) 703, such as executing the method in the above embodiment. In the RAM 703, various programs and data required for system operation are also stored. The CPU 701, the ROM 702 and the RAM 703 are connected to each other through the bus 704. The input / output (I / O) interface 705 is also connected to the bus 704.
[0085] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read therefrom is installed into the storage section 708 as needed.
[0086] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 709, and / or installed from a removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, various functions defined in the system of the present invention are executed.
[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. Among them, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the above-mentioned module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0088] The units involved in the embodiments of the present invention may be implemented by software or hardware, wherein the names of these units do not constitute limitations on the units themselves in certain circumstances.
[0089] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present invention. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A cross-process communication method, characterized in that: The method comprises: Preliminarily building an intermediate service cluster between the application process and the cluster process, wherein the intermediate service cluster includes a plurality of intermediate services that communicate with each other, the application process is a service process that sends a service request, and the cluster process is a service process that responds to the service request; Obtaining the actual load of each of the intermediate services in the communication link from the application process to the cluster process; If the actual load of any intermediate service is greater than a preset load threshold, the any intermediate service is determined as a high-load intermediate service; otherwise, the any intermediate service is determined as a low-load intermediate service; Transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services, so that one or more of the intermediate services can collaboratively transmit information between the application process and the cluster process; The construction method of the intermediate service cluster includes: Creating an interface class for cross-process communication, wherein the interface class includes a request interface and a response interface; According to the cluster process, a plurality of the intermediate services are configured, and according to a preset allocation principle, each of the application processes is allocated to each of the intermediate services for management, wherein the allocation principle is allocation according to the number of application processes; For each of the intermediate services, the intermediate service proxy object is sent to each of the managed application processes, and the application process proxy object sent by each of the managed application processes is received. Based on the intermediate service, a connection between the application process and the cluster process is established to form the intermediate service cluster.
2. The inter-process communication method according to claim 1, characterized in that: Each of the intermediate services manages a plurality of the application processes; The transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services comprises: Obtaining the load occupancy of each of the application processes managed by the high-load intermediate service; Determining at least one load receiving object from the low-load intermediate service according to the size of the actual load; comparing the load occupancy with a preset occupancy threshold; Transfer one or more of the application processes whose load occupancy is less than or equal to the occupancy threshold to the load bearing object; or, collaboratively manage one or more of the application processes whose load occupancy is greater than the occupancy threshold through the high-load intermediate service and the load bearing object.
3. The inter-process communication method according to claim 1, characterized in that: The transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services comprises: Obtaining a request frequency of each of the application processes managed by the high-load intermediate service within a preset time period; Determining at least one load receiving object from the low-load intermediate service according to the size of the actual load; Part of the load in the high-load intermediate service is transferred to at least one of the load taking objects according to the request frequency.
4. The inter-process communication method according to claim 3, characterized in that: Each of the intermediate services manages a plurality of the application processes; The transferring part of the load in the high-load intermediate service to at least one of the load receiving objects according to the request frequency includes: Comparing the request frequency with a preset first frequency threshold; If the request frequency of any application process is less than or equal to the first frequency threshold, determining the any application process as a target application process to be transferred; All service requests of the target application process are transferred to at least one of the load-bearing objects.
5. The inter-process communication method according to claim 3, characterized in that: Each of the intermediate services manages a plurality of the application processes; The transferring part of the load in the high-load intermediate service to at least one of the load receiving objects according to the request frequency further includes: Comparing the request frequency with a preset second frequency threshold; If the request frequency of any application process is greater than the second frequency threshold, determining the any application process as a target application process to be transferred; Transferring part of the service requests of the target application process to at least one of the load bearing objects.
6. The inter-process communication method according to claim 2 or 3, characterized in that: The actual load includes memory usage and processor usage; The step of determining at least one load receiving object from the low-load intermediate service according to the actual load includes: Calculate the mean memory usage, the standard deviation of memory usage, the mean processor usage, and the standard deviation of processor usage corresponding to all low-load intermediate services according to the memory usage and the processor usage; For each of the low-load intermediate services, the memory occupancy, the mean value of the memory occupancy and the standard deviation of the memory occupancy are calculated to obtain a first standardized value of the memory occupancy, and the processor occupancy, the mean value of the processor occupancy and the standard deviation of the processor occupancy are calculated to obtain a second standardized value of the processor occupancy; Calculating the first normalized value and the second normalized value according to a preset weight coefficient to obtain a performance index of each of the low-load intermediate services; The performance index is compared with a preset performance index threshold, and the low-load intermediate service whose performance index is less than or equal to the performance index threshold is determined as the load undertaking object.
7. The inter-process communication method according to claim 1, characterized in that: After transferring part of the load in the high-load intermediate service to at least one of the low-load intermediate services, the method further includes: For each of the application processes, determining a corresponding target intermediate service according to the intermediate service proxy object; Sending the service request to the corresponding target intermediate service based on the request interface; The target intermediate service determines the target cluster process to be called by each of the application processes according to the service request, obtains subscription data from the target cluster process based on the response interface, and returns the subscription data to each of the application processes.
8. An inter-process communication system, characterized in that: The system comprises: A construction module, used to construct an intermediate service cluster between the application process and the cluster process in advance, wherein the intermediate service cluster includes a plurality of intermediate services that communicate with each other, the application process is a service process that sends a request for service, and the cluster process is a service process that responds to the request for service; An acquisition module, used for acquiring an actual load of each intermediate service in a communication link from the application process to the cluster process; A determination module, configured to determine any intermediate service as a high-load intermediate service if the actual load of the intermediate service is greater than a preset load threshold, and otherwise determine the any intermediate service as a low-load intermediate service; A transfer module, used to transfer part of the load in the high-load intermediate service to at least one of the low-load intermediate services, so as to realize the coordinated transmission of information between the application process and the cluster process by one or more of the intermediate services; The building blocks are specifically used for: Creating an interface class for cross-process communication, wherein the interface class includes a request interface and a response interface; According to the cluster process, a plurality of the intermediate services are configured, and according to a preset allocation principle, each of the application processes is allocated to each of the intermediate services for management, wherein the allocation principle is allocation according to the number of application processes; For each of the intermediate services, the intermediate service proxy object is sent to each of the managed application processes, and the application process proxy object sent by each of the managed application processes is received. Based on the intermediate service, a connection between the application process and the cluster process is established to form the intermediate service cluster.
9. A vehicle-mounted terminal, characterized in that: include: one or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, enables the vehicle terminal to implement the cross-process communication method described in any one of claims 1 to 7.
