Inter-process communication method and electronic device

By caching service information and data in kernel space, the problem of communication jams between client processes and service processes caused by the long processing time of service processes is solved, the operating speed and system performance of electronic devices are improved, and the user experience is enhanced.

CN116954936BActive Publication Date: 2025-09-05HUAWEI TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210390253.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-14
Publication Date
2025-09-05
Estimated Expiration
2042-04-14

AI Technical Summary

Technical Problem

In an operating system, when a client process communicates with a service process, the service process takes a long time to process, causing the client process to freeze, respond slowly, or even cause ANR problems, affecting system performance and user experience.

Method used

By caching service information and data in the memory of kernel space, unnecessary service calls are reduced, and high-speed cache memory is used to improve data access efficiency, the required data can be obtained directly from the memory, avoiding system jams caused by IPC operations.

Benefits of technology

It improves the operating speed and system performance of electronic devices, enhances user experience, reduces system resource usage, and reduces the waiting time of client processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116954936B_ABST
    Figure CN116954936B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides an inter-process communication method and electronic device, the method comprising: a processor obtaining a request message from a client process to initiate a communication request to a service process, and determining whether the service information is stored in a memory based on the service information in the request message, the memory being located in the kernel space; if the service information is stored in the memory, then obtaining data corresponding to the service information from the memory, and sending the data corresponding to the service information to the client process. Through the method or electronic device provided by the embodiment of the present application, the client process can obtain data corresponding to the service information from the memory located in the kernel space without accessing the service process located in the user space, which can reduce unnecessary calls to the service process, thereby improving the operating speed and system performance of the electronic device and enhancing the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of computer applications, and more specifically, to an inter-process communication method and electronic device. Background Art

[0002] In an operating system (for example, Android and Hongmeng), client processes communicate with service processes, generally through inter-process communication (IPC). For example, the client process can transmit information through the binder mechanism to obtain data from the service process.

[0003] When using the binder mechanism for communication, while the service process receives and processes information, the client process's request is suspended until the service process returns the processing result. Therefore, when the service process takes a long time to process, problems such as lag, slow response, and even application not responding (ANR) may occur, affecting the electronic device's system performance and reducing the user experience. Currently, there is no system optimization solution to address this problem. Summary of the Invention

[0004] The embodiments of the present application provide an inter-process communication method and an electronic device, which reduce the calling of unnecessary service processes, thereby improving the operating speed and system performance of the electronic device and enhancing the user experience.

[0005] In a first aspect, a method for inter-process communication is provided, which includes: a processor obtaining a request message from a client process to initiate a communication request to a service process; determining that the service information is stored in a memory based on the service information in the request message, and the memory is located in the kernel space; the processor obtaining data corresponding to the service information from the memory; and sending the data corresponding to the service information to the client process.

[0006] In an embodiment of the present application, the processor can determine that the service information is stored in the memory based on the service information in the request message, and can then directly retrieve the data corresponding to the service information from the memory and send the data to the client process. Because the memory is located in the kernel space, the client process can retrieve the data corresponding to the service information from the memory located in the kernel space without accessing the service process located in the user space. This can reduce unnecessary service calls, avoid system freezes caused by IPC operations, and effectively reduce system resource usage, improve the operating speed and system performance of the electronic device, and enhance the user experience.

[0007] In combination with the first aspect, in certain implementations of the first aspect, before determining that the service information is stored in the memory based on the service information in the request message, the method also includes: the processor sends the request message to the service process; receives data corresponding to the service information sent by the service process, and stores the service information and the data corresponding to the service information in the memory.

[0008] In an embodiment of the present application, the processor can send a request message to the service process, obtain the data corresponding to the service information returned by the service process, and save the service information and the data corresponding to the service information in the memory, that is, cache the results returned by the service process, so that the next time the client process calls the service, the processor can directly obtain the data corresponding to the service information from the memory and send the data to the client process, thereby reducing unnecessary service calls, avoiding system freezes and other problems caused by IPC operations, effectively reducing the occupation of system resources, improving the operating speed and system performance of electronic devices, and enhancing user experience.

[0009] In combination with the first aspect, in certain implementations of the first aspect, service information and data corresponding to the service information are stored in a memory, including: when a client process initiates a communication request to a service process, the processor records a first time point; when the service process responds to the communication request initiated by the client process, the processor records a second time point; the processor determines a service waiting time based on the first time point and the second time point; when the service waiting time is greater than a threshold, the processor stores the service information in the communication request and the data corresponding to the service information in the memory.

[0010] In an embodiment of the present application, the processor can detect the time consumption of IPC operations, and by setting a threshold for the service waiting time, detect the service that causes the client process to wait too long, and store the service information corresponding to the service and the data corresponding to the service information in the memory, so that when the client process calls the service again, the data corresponding to the service can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of the electronic device, and enhancing the user experience.

[0011] In combination with the first aspect, in certain implementations of the first aspect, service information and data corresponding to the service information are stored in a memory, including: when a client process initiates a communication request to a service process, the processor records the number of communication requests; when the number of communication requests is greater than a threshold, the processor stores the service information and data corresponding to the service information in the memory.

[0012] In an embodiment of the present application, the processor can detect the number of service requests, and by setting a threshold for the number of service requests, detect frequently called services, and store the service information corresponding to the service and the data corresponding to the service information in the memory, so that when the client process calls the service again, the data corresponding to the service can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of the electronic device, and enhancing the user experience.

[0013] Optionally, the processor can also simultaneously detect the service waiting time and the number of service requests. When the service waiting time is greater than a threshold and the number of communication requests initiated by the client process to the service process is greater than a threshold, the processor can save the service information and the data corresponding to the service information in the memory.

[0014] By setting a threshold for the service waiting time and a threshold for the number of service requests, services that cause the client process to wait for too long and initiate communication requests multiple times can be detected. The service information corresponding to these services and the data corresponding to the service information can be stored in the memory, so that when the client process calls these services again, the data corresponding to the service can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of electronic devices, and enhancing user experience.

[0015] Optionally, when the number of times the client process calls a service is far greater than the number of times the service process modifies the service, the processor may also save such services in the memory, so that when the client process calls these services again, the data corresponding to these services can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of the electronic device, and enhancing the user experience.

[0016] In combination with the first aspect, in some implementations of the first aspect, data corresponding to the service information is updated by a service process.

[0017] It should be understood that the memory stores service information and data corresponding to the service information. The data corresponding to the service information can be updated by the service process, that is, the data corresponding to the service information can change dynamically in real time. When the service process detects that the data corresponding to the service information has changed, it can update the data corresponding to the service information.

[0018] In an embodiment of the present application, the information stored in the memory can be updated in real time by the service process, so that when the user calls the corresponding service, the result corresponding to the service can be obtained accurately.

[0019] Optionally, if the processor detects that a service corresponding to a certain service information in the memory has not been called for a long time, the processor may actively delete the service information and the data corresponding to the service information, thereby saving storage space in the memory to facilitate the storage of other service information and the data corresponding to the service information.

[0020] Optionally, if the processor detects that a service takes a long time and / or is accessed too frequently, the processor may also add the service information of the service and the data corresponding to the service information to the memory, so that when the client process calls these services again, the data corresponding to these services can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of the electronic device, and enhancing the user experience.

[0021] In combination with the first aspect, in some implementations of the first aspect, the service information includes a service name and interface information corresponding to the service.

[0022] In an embodiment of the present application, the processor can accurately identify the service request made by the customer based on the service name in the service information and the interface information corresponding to the service, thereby determining whether the service is located in the memory and avoiding sending a request message directly to the service process.

[0023] In combination with the first aspect, in some implementations of the first aspect, the memory is a cache memory.

[0024] In an embodiment of the present application, by storing service information that meets preset conditions and the data corresponding to the service information in a cache memory cache, when the service is called again, it can be quickly called directly from the cache, avoiding repeated access and reducing the waiting time of the client process, thereby improving the operating speed and system performance of the electronic device and enhancing the user experience.

[0025] In a second aspect, an inter-process communication device is provided, which includes a storage unit, a processing unit and a transceiver unit. The storage unit is used to store service information and data corresponding to the service information; the processing unit is used to obtain a request message from a client process to initiate a communication request to a service process, determine that the service information is stored in the storage unit based on the service information in the request message, and obtain data corresponding to the service information from the storage unit; the transceiver unit is used to send the data corresponding to the service information to the client process.

[0026] In combination with the second aspect, in certain implementations of the second aspect, the transceiver unit is also used to send a request message to the service process and receive data corresponding to the service information sent by the service process; the processing unit is also used to save the service information and the data corresponding to the service information in the storage unit.

[0027] In combination with the second aspect, in certain implementations of the second aspect, the processing unit is further used to: record a first time point when the client process initiates a communication request to the service process; record a second time point when the service process responds to the communication request initiated by the client process; determine the service waiting time based on the first time point and the second time point; and when the service waiting time is greater than a threshold, save the service information in the communication request and the data corresponding to the service information in the storage unit.

[0028] In combination with the second aspect, in certain implementations of the second aspect, the processing unit is also used to: record the number of communication requests when the client process initiates a communication request to the service process; when the number of communication requests is greater than a threshold, save the service information and the data corresponding to the service information in the storage unit.

[0029] In combination with the second aspect, in some implementations of the second aspect, the processing unit is further used to: when the service waiting time is greater than a threshold and the number of communication requests is greater than a threshold, save the service information and the data corresponding to the service information in the storage unit.

[0030] In conjunction with the second aspect, in certain implementations of the second aspect, data corresponding to the service information is updated by a service process.

[0031] In combination with the second aspect, in some implementations of the second aspect, the service information includes a service name and interface information corresponding to the service.

[0032] In combination with the second aspect, in some implementations of the second aspect, the storage unit is a cache storage unit.

[0033] In a third aspect, a device is provided, which includes a processor, and the processor is used to execute the technical solution of the above-mentioned first aspect and any possible design of the first aspect.

[0034] In a fourth aspect, an electronic device is provided, comprising: one or more processors; one or more memories storing service information and data corresponding to the service information; the one or more memories storing one or more computer programs, the one or more computer programs comprising instructions, which, when executed by the one or more processors, enable the electronic device to execute the technical solution of the above-mentioned first aspect and any possible design of the first aspect thereof.

[0035] It should be understood that the electronic device can control the one or more processors to execute the technical solutions of the above-mentioned first aspect and any possible design of the first aspect.

[0036] In the fifth aspect, a chip is provided, which is coupled to a memory in an electronic device and is used to call a computer program stored in the memory and execute the technical solution of the first aspect of the embodiment of the present application and any possible design of the first aspect thereof; in the embodiment of the present application, "coupling" means that two components are directly or indirectly combined with each other.

[0037] In a sixth aspect, a computer-readable storage medium is provided, which includes a computer program. When the computer program runs on an electronic device, the electronic device executes the technical solution of the first aspect and any possible design of the first aspect.

[0038] In a seventh aspect, a computer program product is provided, which, when run on an electronic device, enables the computer to execute the technical solution of the above-mentioned first aspect and any possible design of the first aspect.

[0039] Among them, the beneficial effects of the second to seventh aspects can refer to the beneficial effects of the first aspect and will not be repeated. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 This is a structural diagram of an electronic device provided in an embodiment of the present application.

[0041] Figure 2 This is a schematic block diagram of a storage hierarchy provided in an embodiment of the present application.

[0042] Figure 3 This is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.

[0043] Figure 4 This is a schematic diagram of the binder communication mechanism.

[0044] Figure 5 It is a schematic flow chart of the binder communication mechanism.

[0045] Figure 6 This is a schematic flowchart of an inter-process communication method provided in an embodiment of the present application.

[0046] Figure 7 This is a schematic flowchart of another inter-process communication method provided in an embodiment of the present application.

[0047] Figure 8 This is a schematic flowchart of a method for detecting time consumption of inter-process communication provided in an embodiment of the present application.

[0048] Figure 9 This is a schematic flowchart of another inter-process communication method provided in an embodiment of the present application.

[0049] Figure 10 This is a schematic block diagram of an inter-process communication device provided in an embodiment of the present application.

[0050] Figure 11 This is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0052] The terms used in the following embodiments are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in the specification and appended claims of this application, the singular expressions "a", "an", and "the" are intended to include expressions such as "one or more", unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, "at least one", "one or more" refer to one, two, or more. "First", "second", and various numerical numbers are merely distinctions made for ease of description and are not intended to limit the scope of the embodiments of this application. The character " / " generally indicates that the objects associated with each other are in an "or" relationship. The size of the sequence numbers of the processes below does not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. For example, in the embodiments of this application, words such as "501", "601", and "701" are merely identifiers made for the convenience of description and do not limit the order of execution of the steps.

[0053] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. In this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described in this application as "exemplary" or "for example" should not be interpreted as being more preferred or more advantageous than other embodiments or design. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized. In the embodiments of the present application, descriptions such as "when...", "in the case of...", "if" and "if" all mean that the device will perform corresponding processing under certain objective circumstances, and do not limit the time, nor do they require the device to perform judgment actions when implemented, nor do they mean that there are other limitations.

[0054] The following describes electronic devices and embodiments for using such electronic devices. In some embodiments, the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and / or a music player, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch), etc. Exemplary embodiments of portable electronic devices include but are not limited to those equipped with A portable electronic device running Harmony OS or other operating systems. The portable electronic device may also be other portable electronic devices, such as a laptop computer. It should also be understood that in some other embodiments, the electronic device may not be a portable electronic device, but may be a desktop computer, smart TV, smart speaker, etc.

[0055] Figure 1 FIG. 1 shows a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 1 As shown, Figure 1: The figure shows a schematic structural diagram of an electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195. Among them, the sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0056] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0057] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal based on the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0058] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0059] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM card interface, and / or a USB interface. Among them, the USB interface 130 is an interface that complies with USB standards, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 101, and can also be used to transfer data between the electronic device 101 and peripheral devices. The USB interface 130 can also be used to connect headphones to play audio through the headphones.

[0060] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0061] The internal memory 121 can be used to store one or more computer programs, which include instructions. The processor 110 can execute the above instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system; the program storage area may also store one or more applications (such as a gallery, contacts, etc.). The data storage area may store data (such as photos, contacts, etc.) created during the use of the electronic device 101. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage components, a flash memory component, a universal flash storage (UFS), an embedded multimedia card (eMMC), etc. In some embodiments, the processor 110 may enable the electronic device 101 to execute the method provided in the embodiments of the present application, as well as other applications and data processing by executing instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor 110. The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0062] Figure 2 FIG1 shows a schematic block diagram of a storage hierarchy provided by an embodiment of the present application. Figure 2 As shown in the figure, the storage hierarchy is divided into four layers, namely register memory, cache memory, main memory, and auxiliary memory from top to bottom.

[0063] Among them, the storage hierarchy is the arrangement order of the storage system hierarchy. Each layer has higher read and write speeds, lower latency, and smaller capacity than the next layer.

[0064] Registers are storage areas used by processors to temporarily store data and results of operations. Registers can be located within the processor. Registers are typically located within the processor.

[0065] Cache memory is located between main memory and registers. It has a smaller capacity but faster read and write speeds than main memory. Cache memory can store some of the data in main memory. Therefore, when a processor reads data, it first accesses the cache memory. If the cache memory doesn't contain the required data, it then accesses the main memory. Because cache memory has faster read and write speeds than main memory, if the cache memory contains the data the processor needs, it can increase the operating speed of the electronic device.

[0066] Main memory is also called main memory, internal memory, internal memory (i.e. Figure 1 121 in the figure) is used to store instructions and data. When the processor needs to read data, it first reads it from cache memory. If the data is not in cache memory, the processor searches for it in main memory. If the processor finds the data in main memory, it caches it so that it can be read directly from cache memory next time. Main memory is slower than cache memory but faster than secondary memory.

[0067] Auxiliary memory is also called external memory (i.e. Figure 1 120) refers to the memory other than the main memory, cache memory, and register in the electronic device, such as a hard disk and an optical disk memory.

[0068] It should be noted that Figure 2 The storage hierarchy shown is merely an example, and the present application is not limited thereto. For example, in other embodiments of the present application, a cache may be provided between the main memory and the auxiliary memory. For another example, in other embodiments of the present application, the cache memory may be divided into multiple levels, such as L1 cache, L2 cache, and L3 cache.

[0069] Figure 3 A software structure block diagram of the electronic device 100 according to an embodiment of the present application is shown.

[0070] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other via software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer. The application layer can include a series of application packages.

[0071] like Figure 3As shown in the figure, the application layer may include applications such as gallery, calendar, map, navigation, call, camera, settings, video, music, and SMS. The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer may include some predefined functions. Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0072] The window manager is used to manage window programs. It can obtain the display screen size, determine whether there is a status bar, lock the screen, take screenshots, and so on. The content provider is used to store and retrieve data and make this data accessible to applications. This data may include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and phone books. The content provider is used to store and retrieve data and make this data accessible to applications. This data may include video, images, audio, incoming and outgoing calls, browsing history and bookmarks, and phone books. The view system includes visual controls, such as controls for displaying text and controls for displaying images. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon can include a view for displaying text and a view for displaying images. The call manager is used to provide communication functions for the electronic device 100. For example, it manages call status (including connected and ended calls). The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on. The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Another example is the display of text messages in the status bar, the sound of a notification, the vibration of electronic devices, or the flashing of indicator lights.

[0073] The Android runtime consists of a core library and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system. The core library consists of two parts: one for the Java language's callable functions and the other for the Android core library.

[0074] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0075] The system library can include multiple functional modules. For example: surface manager, media libraries, three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc. The surface manager is used to manage the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The three-dimensional graphics processing library is used to implement three-dimensional graphics drawing, image rendering, synthesis, and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing. In addition, the system library can also include state monitoring service modules, such as a physical state recognition module for analyzing and recognizing user gestures; a sensor service module for monitoring sensor data uploaded by various sensors at the hardware layer to determine the physical state of the electronic device 100.

[0076] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio drivers, sensor drivers, and binder drivers.

[0077] For ease of understanding, the following examples of this application will be described with Figures 1 to 3 Taking the electronic device with the structure shown as an example, the inter-process communication method provided in the embodiment of the present application is specifically explained in combination with the accompanying drawings and application scenarios.

[0078] Figure 4 A schematic diagram showing the principle of the binder communication mechanism.

[0079] In operating systems like Android and Hongmeng, user-mode IPC relies on binder. Binder is a crucial operating system feature, and its communication model is based on the client / server (C / S) communication model. Binder communication uses the C / S model. From a component perspective, binder communication involves the client, server, service manager, and binder driver.

[0080] Each Android process can only run in the virtual address space owned by its own process. For example, an Android process corresponds to a 4GB virtual address space, of which 3GB is user space and 1GB is kernel space. The size of the kernel space can be adjusted through parameter configuration. For user space, different processes cannot share each other, but kernel space can be shared. The client process (i.e., the process using the service / client process) communicates with the server process (i.e., the process providing the service / service process) and can use the kernel memory space that can be shared between processes to complete the underlying communication work. The client process and the server process can communicate by using a function in the device driver, such as ioctl, which manages the I / O channel of the device, to interact with the binder driver in the kernel space.

[0081] like Figure 4 As shown in the figure, the communication process based on the binder mechanism can be summarized as the following three processes: registering services, obtaining services, and using services. Registering services: The server process must first register the service with the service manager. Obtaining services: Before the client process uses a service, it must first obtain the corresponding service from the service manager. Using services: The client process establishes a communication channel with the server process where the service is located based on the service information obtained, and then can directly interact with the service. It is understandable that Figure 4 The interactions between the client process, server process, and service manager are represented by dashed lines. This is because they do not interact directly with each other but rather with the binder driver to implement IPC communication. The client process can also be called the client, and the server process can also be called the server.

[0082] The binder driver resides in kernel space (i.e., the kernel layer), while the client process, server process, and service manager reside in user space. The binder driver and service manager can be considered the operating system's infrastructure, while the client and server processes are the operating system's application layer. Users only need to customize the client and server processes, leveraging the operating system's basic platform architecture to directly perform IPC communication.

[0083] Figure 5 A schematic flow chart of the binder communication mechanism is shown.

[0084] From the above content, we can know that the client process and the server process interact through the binder driver. The following takes the service request for the phone number of "Zhang San" as an example to explain the specific process of the client process requesting the service. Figure 5 As shown, the process may specifically include S501 to S505.

[0085] S501, the server process registers the service with the service management.

[0086] Among them, the server process is the process that provides services in the C / S mode, that is, the service process.

[0087] In this step, since the server process cannot interact directly with the service management, the server process registers the service with the service management through the binder driver. The service management includes many services, for example, the service management includes a service for obtaining a phone number.

[0088] It should be understood that the server process first registers the service for obtaining the phone number with the binder driver, and then the binder driver sends the registered service for obtaining the phone number to the service management.

[0089] S502: The client process initiates a request to the service management to obtain the service.

[0090] Among them, the client process is the process that uses the service in the C / S mode, that is, the client process.

[0091] In this step, since the client process cannot interact directly with the service management, the client process initiates a service request to the service management through the binder driver, passing information such as the service name. The request can be a service request to obtain a phone number, and the service name can be obtain a phone service.

[0092] For example, the client process first sends a request to the binder driver for obtaining the service of the phone number, and then the binder driver sends the request to the service management, so that the service management knows that the client process needs to obtain the relevant service information of the phone number.

[0093] S503: The service management returns the service information to the client process.

[0094] Specifically, the service manager looks up the corresponding server service information based on the service name in the service request sent by the client process. It then returns the corresponding server service information to the client process through the binder driver and performs operations such as memory mapping to prepare for inter-process communication (IPC). The service information here can be understood as the service information corresponding to the telephone service.

[0095] S504: The client process sends data to the server process.

[0096] Specifically, after the client process receives the service information corresponding to the service returned by the binder driver, it can package the data to be obtained and send it to the service management and / or server process based on the memory mapping created by the binder driver for corresponding processing. In other words, the client process first sends the data to be obtained to the binder driver, and then the binder driver sends the data to be obtained to the service management and / or server process.

[0097] It should be understood that the data to be obtained is the data corresponding to the service information, that is, the data that the user wants to obtain, and the data may be, for example, the phone number of "Zhang San".

[0098] S505: The server process sends the return result to the client process through the binder driver.

[0099] Specifically, after receiving data, the server process extracts a thread from the thread pool to unpack the data and call the target method, ultimately returning the processed result to the client process. In other words, the server process and / or service management obtains the corresponding result based on the data sent by the client process and sends it to the binder driver, which then sends it to the client process. It should be understood that the returned result here could be, for example, the phone number of "Johnson."

[0100] In summary, the user's service request (e.g., obtaining the phone number of "Zhang San") can be completed through S501 to S505. The type of service the user needs to obtain (e.g., obtaining a phone service) can be determined through S501 to S503. The specific data corresponding to the service (e.g., the phone number of "Zhang San") can be obtained through S504 and S505. To obtain the returned service information in S503 and the returned result in S505, the client process needs to send information to the service management or server process through the binder driver. The service management or server process processes the received information and then returns the corresponding result through the binder driver.

[0101] Under the binder communication mechanism, when the server process receives and processes a request message, the client process's request thread is suspended until the server process returns the processing result. Therefore, if the server process takes a long time to process, the client process may experience lag, slow response, or even ANR errors. Currently, there is no system optimization solution to address this issue.

[0102] Therefore, the present application provides an inter-process communication (IPC) method, which caches the results returned by the service process by adding a cache mechanism in the binder driver, thereby reducing the number of service executions of the service process and the waiting time of the client process, thereby improving the operating speed of the electronic device and enhancing the user experience.

[0103] Figure 6 FIG1 shows a schematic flow chart of an inter-process communication method provided by an embodiment of the present application. Figure 6 As shown, the method 600 can be executed by a processor in an electronic device. The method 600 includes S601 to S604. The following takes the service of obtaining the phone number of "Zhang San" as an example to explain in detail the specific process of the client process obtaining the service.

[0104] S601: The processor obtains a request message from a client process to initiate a communication request to a service process.

[0105] It should be understood that when a user needs to obtain a certain service, a request message needs to be sent to the service process. The request message can be, for example, a service request sent by the client process to the service process in S502, and / or a data request sent by the client process to the service process in S504.

[0106] S602: The processor determines, based on the service information in the request message, that the service information is stored in a memory.

[0107] It should be understood that the processor can determine which services the client process requires based on the service information in the request message sent by the client process. For example, the request message sent by the client process to the server process is for obtaining the phone number of "Zhang San". The service information indicates that the request is for obtaining "Zhang San's phone number" and includes a service name and interface information corresponding to the service. The service name can be understood as the service name corresponding to the phone service, and the interface information corresponding to the service can be understood as the interface information required to obtain "Zhang San's phone number". The server process determines the information required by the client process based on the service information and then sends the required information to the client process.

[0108] It should also be understood that the memory is located in kernel space (i.e., kernel layer) and may be, for example, a cache memory. The memory stores service information and data corresponding to the service information. The service information includes a service name and interface information corresponding to the service. When the processor determines, based on the service information in the request message, that the service information is already stored in the memory, the processor may directly retrieve the data corresponding to the service information from the memory and return the data to the client process.

[0109] For example, when a user wants to obtain the phone number of "Zhang San" and the relevant service information corresponding to obtaining "Zhang San"'s phone number is stored in the memory, the client process can first obtain the data corresponding to the phone service from the memory, and then obtain "Zhang San"'s phone number from the memory. In other words, the service information can include the service information for obtaining the phone and the interface information corresponding to the service for obtaining the phone number, and the data corresponding to the service information can include the relevant data corresponding to obtaining the phone number; or, the service information can include the service information for obtaining "Zhang San"'s phone number and the interface information corresponding to the service for obtaining "Zhang San"'s phone number, and the data corresponding to the service information can include "Zhang San"'s phone number.

[0110] It should also be understood that before S602, the method may also perform the following steps: Figure 7 The method shown in FIG700 can save services that meet corresponding conditions in the memory, so that when the client process calls the service again, the service information and the data corresponding to the service information can be directly obtained from the memory.

[0111] S603: The processor obtains data corresponding to the service information from the memory.

[0112] It should be understood that the processor determines that the service information is stored in the memory (for example, cache) based on the service information in the request message sent by the client process. Therefore, there is no need to send a request message to the server process. The data corresponding to the service information can be directly obtained from the memory (for example, cache), thereby reducing a large number of unnecessary service calls and shortening the waiting time of the client process IPC.

[0113] For example, if the service information corresponding to the phone number of "Zhang San" is stored in the cache, the processor can directly obtain the phone number of "Zhang San" from the cache without sending the service information corresponding to the phone number of "Zhang San" to the server process and then obtaining the phone number of "Zhang San", thereby reducing unnecessary server process calls.

[0114] It should be noted that the data corresponding to the service information can be updated by the service process. In other words, the data corresponding to the service information can be dynamic and change in real time. When the server process detects that the data corresponding to the service information has changed, it can update the data corresponding to the service information, so that when the user calls the service, they can obtain the accurate results corresponding to the service.

[0115] Optionally, if the processor detects that a service corresponding to a certain service information in the memory has not been called for a long time, the processor may actively delete the service information and the data corresponding to the service information, thereby saving storage space in the memory to facilitate the storage of other service information and the data corresponding to the service information.

[0116] Alternatively, if the processor Figure 8 In the method described above, when it is detected that a service takes a long time and / or is accessed too frequently, the processor can also add the service information of the service and the data corresponding to the service information to the memory, so that when the client process calls these services again, the data corresponding to these services can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of the electronic device, and enhancing the user experience.

[0117] S604: The processor sends data corresponding to the service information to the client process.

[0118] Specifically, the processor can retrieve data corresponding to the service information from a memory (e.g., a cache) based on the service information and send the data to the client process, so that the processor can use the data corresponding to the service information for subsequent processing. For example, the data corresponding to the service information can be the phone number of "Zhang San".

[0119] According to the IPC method provided in an embodiment of the present application, the processor can determine that the service information in the request message is stored in the memory, thereby directly obtaining the data corresponding to the service information from the memory and sending the data to the client process. Because the memory is located in the kernel space, the client process can obtain the data corresponding to the service information from the memory located in the kernel space without accessing the service process located in the user space. This can reduce unnecessary service calls, avoid system freezes and other problems caused by IPC operations, effectively reduce system resource usage, improve the operating speed and system performance of electronic devices, and enhance user experience.

[0120] Figure 7 FIG2 shows a schematic flow chart of another inter-process communication method provided by an embodiment of the present application. Figure 7 As shown, the method 700 can be executed by a processor in an electronic device. The method 700 includes S701 to S704, which details the specific process of the client process obtaining the service.

[0121] It should be noted that method 700 can be executed before method 600, that is, the processor can obtain the service that needs to be stored in the memory by executing S701 to S704, and then when the client process calls the service, it can directly obtain the required data from the memory, thereby eliminating the need to send a request message to the service process to obtain the required data.

[0122] S701: The processor obtains a request message from a client process to initiate a communication request to a service process.

[0123] This step may refer to S601 and will not be described in detail here.

[0124] S702: The processor sends the request message to the service process.

[0125] It should be understood that the processor may, for example, Figure 5 The method flow described herein sends the request message to the service process through the binder driver to obtain data in the service process corresponding to the service information in the request message.

[0126] S703: The processor receives data corresponding to the service information sent by the service process, and saves the service information and the data corresponding to the service information in a memory.

[0127] Specifically, after the processor sends the request message sent by the client process to the server process through the binder driver, the server process extracts a thread from the thread pool, unpacks the data, calls the target method, and determines the data corresponding to the service information in the request message. The processor receives the data corresponding to the service information sent by the server process and saves the service information and the data corresponding to the service information in a memory (e.g., cache).

[0128] For example, after obtaining data related to Zhang San's phone number through the server process, the service information corresponding to Zhang San's phone number and the related data corresponding to Zhang San's phone number (for example, Zhang San's phone number) can be stored in the cache, so that the next time Zhang San's phone number is obtained, the data related to Zhang San's phone number can be directly obtained from the cache, without sending the service information corresponding to Zhang San's phone number to the server process, and then obtaining the related data corresponding to Zhang San's phone number, thereby reducing unnecessary server process calls.

[0129] Optionally, the service information and the data corresponding to the service information can be cached in a key-value pair format, with the service information serving as the key and the data corresponding to the service information serving as the value. Therefore, when querying the data stored in the cache, the data corresponding to the service information can be retrieved from the cache based on the service information in the request message.

[0130] It should be understood that when determining which services can be stored in a memory (eg, cache), the IPC operation duration and / or the difficulty of calling a service and / or the number of service requests may be considered.

[0131] In some embodiments, when a client process initiates a communication request to a server process, the processor records a first time point; when the server process responds to the communication request initiated by the client process, the processor records a second time point; the processor determines a service wait time based on the first and second time points; and when a preset condition is met, the processor stores the service information in the communication request and data corresponding to the service information in a memory. Optionally, the preset condition may be that the service wait time is greater than a threshold, which may be an empirical value, such as 6ms or 10ms, but is not limited in this application.

[0132] In some embodiments, when the client process initiates a communication request to the server process, the processor records the number of communication requests; when the number of communication requests is greater than a threshold, the processor may save the service information in the communication request and the data corresponding to the service information in the memory.

[0133] In some embodiments, the processor can also detect the service waiting time and the number of service requests at the same time. When the service waiting time is greater than a threshold and the number of communication requests initiated by the client process to the server process is greater than a threshold, the processor can also save the service information in the communication request and the data corresponding to the service information in the memory.

[0134] Generally speaking, for a service stored in memory, the number of times the client process calls the service should be much greater than the number of times the service process modifies the service. Figure 8 The contents are elaborated in detail and will not be repeated here.

[0135] S704: The processor sends data corresponding to the service information to the client process.

[0136] Specifically, after receiving the data corresponding to the service information returned by the service process, the processor can send the data to the client process, so that the processor can use the data corresponding to the service information for subsequent processing. For example, the data corresponding to the service information can be the phone number of "Zhang San".

[0137] According to the IPC method provided in the embodiment of the present application, the processor can send a request message to the service process, obtain the data corresponding to the service information returned by the service process, and save the service information and the data corresponding to the service information in the memory, that is, cache the results returned by the service process, so that the next time the client process calls the service, the processor can directly obtain the data corresponding to the service information from the memory and send the data to the client process, thereby reducing unnecessary service calls, avoiding system freezes and other problems caused by IPC operations, effectively reducing the occupation of system resources, improving the operating speed and system performance of electronic devices, and enhancing user experience.

[0138] Figure 8 FIG1 shows a schematic flow chart of a method for detecting time consumption of inter-process communication provided by an embodiment of the present application. Figure 8 As shown, the method 800 specifically includes S801 to S808, and these steps are respectively introduced in detail below.

[0139] S801, the program calls the IPC interface to request service.

[0140] It should be understood that different request messages / programs correspond to different IPC application program interfaces. For example, a request to open an address book and a request to open a camera application require access to different communication interfaces.

[0141] S802, enter the custom hook function (hook function).

[0142] It should be understood that in the embodiment of the present application, by using hook technology, a custom hook function is written. During the system operation, by replacing a native program app_process (i.e., the main entry point of the application process) of the operating system (for example, the Android system), the hook operation of the IPC processing interface of all application processes is realized.

[0143] Hooking is a technique used to alter the results of API execution, redirecting the execution of system API functions. The hook function can record the start and end times of IPCs, thereby determining the duration of the IPC.

[0144] S803, record start time.

[0145] S804: Call the system function to perform IPC operation.

[0146] S805: After receiving the IPC result, record the end time.

[0147] Through S803 to S805, the hook function is used to record the start time and the end time at the start position and the end position respectively, and the duration of each IPC operation (ie, the operation duration of each service) is determined.

[0148] It should be understood that the start time may correspond to the time when the client process initiates a communication request to the service process in S502, and the end time may correspond to the time when the service process responds to the communication request initiated by the client process in S503 or S505. In other words, the time detection can be the detection of the time between S502 and S503, that is, the time from obtaining the service to returning the service information; or the detection of the time between S502 and S505, that is, the time from obtaining the service to returning the specific data corresponding to the service.

[0149] S806: If the difference between the end time and the start time is greater than the set maximum duration, it is determined that an IPC timeout has occurred, and an exception log is printed.

[0150] The wait time for the current IPC operation is calculated by the difference between the end time and the start time. A maximum wait time is set as a threshold. When the difference is greater than the threshold (for example, 5ms or 10ms), a wait timeout is considered to have occurred. For IPC operations that cause wait timeouts, log information such as the wait time and stack trace is printed for further troubleshooting and optimization.

[0151] S807: Check the source code based on the exception log to determine the IPC operation type.

[0152] S808: If the IPC operation type is a query IPC operation, add the IPC information to the cache and set it as an operation that needs to be optimized.

[0153] It should be understood that the query type IPC operation can be understood as an operation that frequently uses interfaces, and the number of accesses to these interfaces is much greater than the number of modifications. For this type of IPC operation, its service information and the data corresponding to the service information can be added to the cache.

[0154] Among them, the cache can include two types of values. One type represents the target method identifier of the IPC operation, that is, the service information, which can be used to identify the service name and interface information called by the IPC operation; the other type corresponds to the result of the service information, that is, the data corresponding to the service information, which is the result returned by the server process.

[0155] It should be noted that, in determining which services need to be stored in the memory, in addition to considering the IPC operation duration, the difficulty of calling the service and / or the number of service requests may also be considered.

[0156] In some embodiments, the processor can determine whether to save the service in the memory based on the difficulty of calling the service. For example, the service of obtaining the phone number of "Zhang San" is relatively simple, while the service involved in dialing the phone number of "Zhang San" is relatively complex. In this case, the service corresponding to obtaining the phone number of "Zhang San" can be saved in the memory.

[0157] In some embodiments, when a client process initiates a communication request to a service process, the processor records the number of communication requests within a certain time range; when the number of communication requests is greater than a threshold, which may be an empirical value, the processor saves the service information and the data corresponding to the service information in a memory.

[0158] By setting a threshold for the number of service requests, frequently called services are detected, and the service information corresponding to the service and the data corresponding to the service information are stored in the memory. Therefore, when the client process calls the service again, the data corresponding to the service can be directly obtained from the memory, thereby reducing unnecessary service calls, improving the operating speed and system performance of electronic devices, and enhancing user experience.

[0159] In some embodiments, the processor can simultaneously detect the service waiting time and the number of service requests. When the service waiting time is greater than a threshold and the number of communication requests initiated by the client process to the service process is greater than a threshold, the processor can save the service information and the data corresponding to the service information in the memory.

[0160] By setting a threshold for the service waiting time and a threshold for the number of service requests, services that cause the client process to wait for too long and initiate communication requests multiple times can be detected. The service information corresponding to these services and the data corresponding to the service information can be stored in the memory, thereby further improving the operating speed and system performance of the electronic device and enhancing the user experience.

[0161] In some embodiments, the processor may also comprehensively consider the IPC operation duration, the difficulty of calling the service, and the number of service requests. By comprehensively considering these factors, the target interface that needs to be cached can be further found, so that the interface information and the service information that calls the interface can be stored in the cache, which can further improve the operating speed and system performance of the electronic device and enhance the user experience.

[0162] Through S801 to S808, the IPC time consumption can be detected, the server process that causes the client process to wait too long can be identified, and the service information and the data corresponding to the obtained service information can be stored in the memory (for example, cache). Therefore, when the client process calls the service again, the data corresponding to the service can be directly obtained from the memory (for example, cache), thereby reducing unnecessary service calls.

[0163] Furthermore, the IPC time-consuming detection method provided by the embodiment of the present application replaces app_process by writing a hook function during system startup, enabling hook operations on the IPC interfaces of all application processes without the upper-layer applications being aware of them. This allows the execution time of each IPC operation to be obtained, allowing the server process service that caused the client process's IPC operation to time out to be identified, facilitating subsequent location analysis. Furthermore, the IPC time-consuming detection method provided by the embodiment of the present application is not restricted by Android versions, is not restricted by root permissions, does not affect business functions, and has no significant impact on system performance.

[0164] Figure 9 FIG2 shows a schematic flow chart of another inter-process communication method provided by an embodiment of the present application. Figure 9 As shown, the method 600 may be executed by a processor in an electronic device, and the method 900 specifically includes S901 to S907.

[0165] S901, the program calls the IPC interface to request service.

[0166] S902: The binder driver receives a request message.

[0167] It should be understood that when the client process initiates communication with the server process, information interaction needs to be carried out through the binder driver. For details, please refer to S501 to S505, which will not be repeated here.

[0168] When the binder driver receives a request message, the binder driver can first determine whether the service information in the request message (i.e., the above-mentioned service name and the interface information corresponding to the service) is stored in the cache, where the request message can be, for example, a request to obtain the phone number of "Zhang San".

[0169] S903: Make a judgment based on the service information provided by the client process.

[0170] S904: Determine whether there is corresponding record information in the cache.

[0171] When the client process sends a request message to the server process, the processor first determines whether the service information in the request message is in the cache, that is, whether there is a corresponding record in the cache. If the service information is in the cache, that is, there is a corresponding record in the cache, the processor may execute S905. If the service information is not in the cache, that is, there is no corresponding record in the cache, the processor may execute S906 and S907.

[0172] Among them, the service information includes the service name and the interface information corresponding to the service. For example, the service name can be to obtain telephone service, and the interface information corresponding to the service can be understood as the interface information corresponding to the service for obtaining the telephone number of "Zhang San". The record item information can be understood as the above-mentioned service information and the data corresponding to the service information. The service information can be understood as the service information of the server process provided by the client process during the service request process, that is, what kind of system service is obtained (for example, obtaining telephone service) and the specific data under the system service that needs to be obtained (for example, the telephone number of "Zhang San").

[0173] It should be noted that when the server process determines that the information stored in the cache (i.e., the data corresponding to the service information) has changed, the server process can update it through the interface provided by the binder driver and store the updated information in the cache for the next call.

[0174] For example, a mobile phone application might frequently obtain the user's location information, but the user's location might not change for several hours or even a day. For such location services, the processor can also store this information in the cache. When the server process detects a change in the user's location, it can update the location details using the location-related APIs provided by the binder driver. This ensures that the cached information is accurate and convenient for the user to access next time.

[0175] S905: If there is corresponding record information in the cache, the result information is encapsulated and returned to the client process.

[0176] Specifically, the processor determines whether the service information is in the cache based on the service information in the request message sent by the client process. If the service information is not in the cache, the processor sends the request message to the server process. The server process determines the data corresponding to the service information based on the service information, such as the phone number of "Zhang San".

[0177] S906: If there is no corresponding record information in the cache, the corresponding service of the server process is called according to the normal process to process and wait for the return result.

[0178] Specifically, the processor determines whether the service information is in the cache based on the service information in the request message sent by the client process. If the service information is not in the cache, the processor sends the request message to the server process, and the server process determines the data corresponding to the service information based on the service information. For specific content, please refer to Figure 5 , I will not go into details here.

[0179] For example, if the service information corresponding to the phone number of "Zhang San" is not in the cache, the processor needs to send the service information corresponding to the phone number of "Zhang San" to the server process, and then obtain the data related to the phone number of "Zhang San".

[0180] S907: Based on the result returned by the server process, the result information is encapsulated and returned to the client process, and the processing result is inserted into the cache.

[0181] Specifically, after receiving the data corresponding to the service information returned by the service process, the processor can send the data to the client process, so that the processor can use the data corresponding to the service information for subsequent processing. For example, the data corresponding to the service information can be the phone number of "Zhang San".

[0182] For example, if there is no corresponding record information in the cache, the server process can be called to process the corresponding service first. When the processing is completed and the result is returned, <service information, data corresponding to the service information> can be used as<key,value> Yes, that is, insert the service information and the data corresponding to the service information into the cache in the form of key-value pairs.

[0183] It should be understood that when determining which services can be stored in the cache, the IPC operation duration and / or the difficulty of calling the service and / or the number of service requests may be considered.

[0184] In some embodiments, when the client process initiates a communication request to the server process, the processor records a first time point; when the server process responds to the communication request initiated by the client process, the processor records a second time point; the processor determines the service waiting time based on the first time point and the second time point; when the service waiting time is greater than a threshold, the processor saves the service information in the communication request and the data corresponding to the service information in the cache.

[0185] In some embodiments, when the client process initiates a communication request to the server process, the processor records the number of communication requests; when the number of communication requests is greater than a threshold, the processor saves the service information and the data corresponding to the service information in the cache.

[0186] In some embodiments, the processor can also simultaneously detect the service waiting time and the number of service requests. When the service waiting time is greater than a threshold and the number of communication requests initiated by the client process to the server process is greater than a threshold, the processor can save the service information and the data corresponding to the service information in the cache.

[0187] Generally speaking, for services stored in memory, the number of times the client process calls the service should be much greater than the number of times the server process modifies the service. Figure 8 , I will not go into details here.

[0188] According to the IPC method provided in the embodiment of the present application, by determining whether the service information in the request message of the client process is in the cache, if the service information is in the cache, the processor can directly obtain the data corresponding to the service information in the cache and send the data to the client process; if the service information is not in the cache, the processor can send the request message to the server process, obtain the data corresponding to the service information returned by the server process, save the service information and the data corresponding to the service information in the cache, that is, cache the result returned by the server process, so that the next time the client process calls the service information, the processor can directly obtain the data corresponding to the service information from the cache and send the data to the client process. The method provided in the embodiment of the present application can reduce unnecessary service calls, avoid system freezes and other problems caused by IPC operations, effectively reduce the occupation of system resources, improve the operating speed and system performance of electronic devices, and enhance user experience.

[0189] The above mainly introduces an inter-process communication method provided by an embodiment of the present application from the perspective of an electronic device. It is understandable that, in order to implement the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a hardware or computer software driven hardware manner depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0190] The embodiment of the present application can divide the functional modules of the processor in the electronic device according to the above method example. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0191] In the case of dividing each functional module into corresponding functional modules, Figure 10 FIG. 1 shows a schematic block diagram of an inter-process communication device provided in an embodiment of the present application. Figure 10 As shown, the IPC device 1000 may include: a storage unit 1010 , a processing unit 1020 and a transceiver unit 1030 .

[0192] The storage unit 1010 is used to store service information and data corresponding to the service information.

[0193] The processing unit 1020 is configured to obtain a request message from the client process to initiate a communication request to the service process, determine that the service information is stored in the storage unit based on the service information in the request message, and obtain data corresponding to the service information from the storage unit.

[0194] The transceiver unit 1030 is used to send data corresponding to the service information to the client process.

[0195] Optionally, the transceiver unit 1030 is further used to send a request message to the service process and receive data corresponding to the service information sent by the service process; the processing unit 1020 is further used to save the service information and the data corresponding to the service information in the storage unit.

[0196] Optionally, the processing unit 1020 is also used to: record a first time point when the client process initiates a communication request to the service process; record a second time point when the service process responds to the communication request initiated by the client process; determine the service waiting time based on the first time point and the second time point; when the service waiting time is greater than a threshold, save the service information in the communication request and the data corresponding to the service information in the storage unit 1010.

[0197] Optionally, the processing unit 1020 is further configured to: record the number of communication requests when the client process initiates a communication request to the service process; and save the service information and data corresponding to the service information in the storage unit when the number of communication requests is greater than a threshold.

[0198] Optionally, the processing unit 1020 is further configured to: when the service waiting time is greater than a threshold and the number of communication requests is greater than a threshold, store the service information and data corresponding to the service information in a storage unit.

[0199] Optionally, the data corresponding to the service information is updated by a service process.

[0200] Optionally, the service information includes a service name and interface information corresponding to the service.

[0201] Optionally, the storage unit 1010 is a cache storage unit.

[0202] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here. The inter-process communication device provided in the embodiment of the present application is used to execute the above inter-process communication method, so it can achieve the same effect as the above processing method.

[0203] Figure 11 : is a schematic structural diagram of an electronic device provided in an embodiment of the present application. Figure 11 As shown, the electronic device 1100 includes: one or more processors 1110; one or more memories 1120; the one or more memories 1120 store service information and data corresponding to the service information; the one or more memories 1120 also store one or more computer programs, each of which includes instructions. When the one or more processors 1110 execute the instructions, the electronic device 1100 executes the steps of the inter-process communication method in the above-mentioned embodiments.

[0204] For example, the one or more processors 1110 may be Figure 1 The processor 110 shown, the one or more memories 1120 may specifically be Figure 1 An internal memory 120 and / or an external memory connected to the electronic device is shown.

[0205] An embodiment of the present application provides a device, which includes a processor, and the processor is used to execute the inter-process communication method in the above-mentioned method embodiments.

[0206] An embodiment of the present application also provides a chip, which includes a processor and a communication interface. The communication interface is used to receive a signal and transmit the signal to the processor. The processor processes the signal so that the inter-process communication method in the above-mentioned method embodiments is executed.

[0207] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the inter-process communication method in the above-mentioned method embodiments.

[0208] An embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the inter-process communication method in each of the above method embodiments.

[0209] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory to enable the chip to execute the inter-process communication method in the above-mentioned method embodiments.

[0210] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0211] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0212] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0213] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0214] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0215] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0216] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. An inter-process communication method, characterized in that: include: The processor obtains a request message from the client process to initiate a communication request to the service process; The processor determines, based on the service information in the request message, that the service information is stored in a memory, the memory being located in a binder driver kernel module, the service information and data corresponding to the service information being stored in the memory, the service information including a service name and interface information corresponding to the service, the number of times the client process calls the service stored in the memory being greater than the number of times the service process modifies the service, and the storage content of the memory being dynamically updated based on a comparison result of the number of times the client process calls the service and the number of times the service process modifies the service; The processor obtains data corresponding to the service information from the memory; The processor sends the data to the client process.

2. The method according to claim 1, characterized in that Before the processor determines, based on the service information in the request message, that the service information is stored in the memory, the method further includes: The processor sends the request message to the service process; The processor receives data corresponding to the service information sent by the service process, and stores the service information and the data corresponding to the service information in the memory.

3. The method according to claim 2, characterized in that The storing the service information and the data corresponding to the service information in the memory includes: When the client process initiates a communication request to the service process, the processor records a first time point; When the service process responds to the communication request initiated by the client process, the processor records a second time point; The processor determines a service waiting time according to the first time point and the second time point; When the service waiting time is greater than a threshold, the processor saves the service information and data corresponding to the service information in the memory.

4. The method according to claim 2, characterized in that The storing the service information and the data corresponding to the service information in the memory includes: When the client process initiates a communication request to the service process, the processor records the number of the communication requests; When the number of communication requests is greater than a threshold, the processor stores the service information and data corresponding to the service information in the memory.

5. The method according to any one of claims 1 to 4, characterized in that The data corresponding to the service information is updated by the service process.

6. The method according to any one of claims 1 to 4, characterized in that The memory is a cache memory.

7. An electronic device, characterized in that: include: one or more processors; one or more memories; The one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the electronic device performs the following steps: Obtain the request message from the client process to initiate a communication request to the service process; Determining, based on the service information in the request message, that the service information is stored in the one or more memories, the one or more memories being located in a binder driver kernel module, the one or more memories storing the service information and data corresponding to the service information, the service information including a service name and interface information corresponding to the service, the number of times the client process calls a service stored in the one or more memories being greater than the number of times the service process modifies the service, and the storage contents of the one or more memories being dynamically updated based on a comparison result of the number of times the client process calls the service and the number of times the service process modifies the service; Retrieve data corresponding to the service information from the one or more memories; The data is sent to the client process.

8. The electronic device according to claim 7, wherein: When the instructions are executed by the one or more processors, the electronic device is caused to perform the following steps: Sending the request message to the service process; Receive data corresponding to the service information sent by the service process, and save the service information and the data corresponding to the service information in the one or more memories.

9. The electronic device according to claim 8, wherein: When the instructions are executed by the one or more processors, the electronic device is caused to perform the following steps: When the client process initiates a communication request to the service process, recording a first time point; When the service process responds to the communication request initiated by the client process, recording a second time point; determining a service waiting time according to the first time point and the second time point; When the service waiting time is greater than a threshold, the service information in the communication request and data corresponding to the service information are stored in the one or more memories.

10. The electronic device according to claim 8, wherein When the instructions are executed by the one or more processors, the electronic device is caused to perform the following steps: When the client process initiates a communication request to the service process, recording the number of the communication requests; When the number of communication requests is greater than a threshold, the service information and data corresponding to the service information are stored in the one or more memories.

11. The electronic device according to any one of claims 7 to 10, characterized in that: The data corresponding to the service information is updated by the service process.

12. The electronic device according to any one of claims 7 to 10, characterized in that: The one or more memories are cache memories.

13. A device, characterized in that: The apparatus comprises a processor configured to execute the method according to any one of claims 1 to 6.

14. A chip, characterized in that: The chip includes a processor and a communication interface, wherein the communication interface is configured to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method according to any one of claims 1 to 6 is executed.

15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a computer, the method according to any one of claims 1 to 6 is executed.

16. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Cross-process communication method and device based on Android platform

    CN106547631A

  • Method and apparatus for addressing system interprocess request

    CN108696551A

  • Result acquisition method, device and equipment

    CN111367683A

  • Method for accelerating starting of application program and electronic equipment

    CN112783564A