CN116954936A - Inter-process communication method and electronic equipment - Google Patents

Inter-process communication method and electronic equipment Download PDF

Info

Publication number
CN116954936A
CN116954936A CN202210390253.9A CN202210390253A CN116954936A CN 116954936 A CN116954936 A CN 116954936A CN 202210390253 A CN202210390253 A CN 202210390253A CN 116954936 A CN116954936 A CN 116954936A
Authority
CN
China
Prior art keywords
service
service information
memory
processor
data corresponding
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210390253.9A
Other languages
Chinese (zh)
Inventor
闫昊
窦峥
刘喜龙
海庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202210390253.9A priority Critical patent/CN116954936A/en
Priority to PCT/CN2023/087802 priority patent/WO2023198103A1/en
Publication of CN116954936A publication Critical patent/CN116954936A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the application provides an inter-process communication method and electronic equipment, wherein the method comprises the following steps: the method comprises the steps that a processor obtains a request message of a client process for initiating a communication request to a service process, and determines whether service information is stored in a memory or not according to the service information in the request message, wherein the memory is located in a kernel space; if the service information is stored in the memory, the data corresponding to the service information is acquired from the memory and sent to the client process. By the method or the electronic device provided by the embodiment of the application, the client process can acquire the data corresponding to the service information from the memory in the kernel space without accessing the service process in the user space, and unnecessary call of the service process can be reduced, so that the running speed and the system performance of the electronic device can be improved, and the user experience is enhanced.

Description

Inter-process communication method and electronic equipment
Technical Field
The embodiment of the application relates to the field of computer application, and more particularly relates to an inter-process communication method and electronic equipment.
Background
In an operating system (such as an android system and a hong-mo system), a client process communicates with a service process, and generally, an inter-process communication (inter-process communication, IPC) mode may be adopted, for example, the client process may perform information transmission through a binder mechanism, so as to obtain data in the service process.
In the communication process using the binder mechanism, when the service process receives information and processes the information, the request of the client process is suspended until the service process returns a processing result. Therefore, when the service process is longer, problems such as jamming, slow response, and even no response (application not responding, ANR) of the application may occur, thereby affecting the system performance of the electronic device and further reducing the user experience. There is currently no system optimization solution to this problem.
Disclosure of Invention
The embodiment of the application provides an inter-process communication method and electronic equipment, which can reduce the calling of unnecessary service processes, thereby improving the running speed and system performance of the electronic equipment and enhancing the user experience.
In a first aspect, there is provided an inter-process communication method, the method comprising: the method comprises the steps that a processor obtains a request message of a client process for initiating a communication request to a service process; determining service information according to the service information in the request message, and storing the service information in a memory, wherein the memory is positioned in a kernel space; the processor acquires data corresponding to the service information from the memory; and sending the data corresponding to the service information to the client process.
In the embodiment of the application, the processor can determine the service information to be stored in the memory according to the service information in the request message, so that the data corresponding to the service information can be directly obtained from the memory and sent to the client process. Because the memory is located in the kernel space, the client process can acquire 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, so that unnecessary service call can be reduced, the problems of system blocking and the like caused by IPC operation are avoided, the occupation of system resources can be effectively reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
With reference to the first aspect, in certain implementations of the first aspect, before determining that the service information is stored in the memory according to the service information in the request message, the method further includes: the processor sends the request message to the service process; and receiving data corresponding to the service information sent by the service process, and storing the service information and the data corresponding to the service information in a memory.
In the embodiment of the application, the processor can send the request message to the service process, acquire the data corresponding to the service information returned by the service process, and store the service information and the data corresponding to the service information in the memory, namely, cache the result returned by the service process, so that the processor can directly acquire the data corresponding to the service information from the memory and send the data to the client process when the client process calls the service again next time, thereby reducing unnecessary service call, avoiding the problems of system blocking and the like caused by IPC operation, effectively reducing the occupation of system resources, improving the running speed and the system performance of the electronic equipment, and enhancing the user experience.
With reference to the first aspect, in some implementations of the first aspect, storing the service information and data corresponding to the service information in a memory includes: when a client process initiates a communication request to a service process, a 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 service waiting time according to the first time point and the second time point; when the service waiting time is greater than the threshold value, the processor stores the service information in the communication request and data corresponding to the service information in the memory.
In the embodiment of the application, the processor can detect the time consumption of IPC operation, detect the service causing the overlong waiting time of the client process by setting the threshold value of the service waiting time, 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, further unnecessary service call can be reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
With reference to the first aspect, in some implementations of the first aspect, storing the service information and data corresponding to the service information in a memory includes: when a client process initiates a communication request to a service process, a processor records the times of the communication request; when the number of communication requests is greater than a threshold, the processor saves the service information and data corresponding to the service information in a memory.
In the embodiment of the application, the processor can detect the times of service requests, detect frequently-called services by setting the threshold value of the times of service requests, and store the service information corresponding to the services and the data corresponding to the service information in the memory, so that when a client process calls the services again, the data corresponding to the services can be directly obtained from the memory, further unnecessary service calls can be reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
Optionally, the processor may also detect the service waiting time and the number of service requests at the same time, and when the service waiting time is greater than a threshold value and the number of communication requests initiated by the client process to the service process is greater than the threshold value, the processor may store the service information and data corresponding to the service information in the memory.
By setting the threshold value of service waiting time and the threshold value of service request times, the service which causes the waiting time of the client process to be too long and initiates the communication request for many times is detected, and the service information corresponding to the service and the data corresponding to the service information can be stored 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, further unnecessary service call can be reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
Optionally, when the number of times that the client process calls the service is far greater than the number of times that the service process modifies the service, the processor may also store such services in the memory, so that when the client process calls the services again, data corresponding to the services may be directly obtained from the memory, thereby reducing unnecessary service calls, improving the running speed and system performance of the electronic device, and enhancing user experience.
With reference to the first aspect, in some implementations of the first aspect, the data corresponding to the service information is updated by a service process.
It should be understood that the service information and the data corresponding to the service information are stored in the memory. The data corresponding to the service information may be updated by the service process, that is, the data corresponding to the service information may be dynamically changed in real time, and when the service process detects that the data corresponding to the service information is changed, the data corresponding to the service information may be updated.
In the embodiment of the application, the information stored in the memory can be updated in real time by the service process, so that when a user invokes the corresponding service, a result corresponding to the service can be obtained accurately.
Optionally, if the processor detects that the service corresponding to a certain service information in the memory is not invoked for a long time, the processor may actively delete the service information and the data corresponding to the service information, so that a storage space in the memory may be saved, so as to store other service information and the data corresponding to the service information.
Optionally, if the processor detects that a certain service consumes longer time and/or has too high access frequency, 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 the service again, the data corresponding to the service may be directly obtained from the memory, thereby reducing unnecessary service call, improving the running speed and system performance of the electronic device, and enhancing the user experience.
With reference to the first aspect, in certain implementation manners of the first aspect, the service information includes a service name and interface information corresponding to the service.
In the embodiment of the application, the processor can accurately identify the service request of the client according to the service name in the service information and the interface information corresponding to the service, thereby judging whether the service is positioned in the memory or not and avoiding sending the request message to the service process directly.
With reference to the first aspect, in certain implementations of the first aspect, the memory is a cache memory.
In the embodiment of the application, the service information meeting the preset condition and the data corresponding to the service information are stored in the cache memory, so that when the service is called again, the quick call can be directly realized from the cache, repeated access is avoided, the waiting time of a client process is reduced, the running speed and the system performance of the electronic equipment can be improved, and the user experience is enhanced.
In a second aspect, an interprocess communication apparatus is provided, where the apparatus includes a storage unit, a processing unit, and a transceiver unit, where the storage unit is configured to store service information and data corresponding to the service information; the processing unit is used for acquiring a request message of a communication request initiated by a client process to a service process, determining service information according to the service information in the request message, storing the service information in the storage unit, and acquiring data corresponding to the service information from the storage unit; the receiving and transmitting unit is used for transmitting the data corresponding to the service information to the client process.
With reference to the second aspect, in some implementations of the second aspect, the transceiver unit is further configured 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 further configured to store the service information and data corresponding to the service information in the storage unit.
With reference to the second aspect, in certain implementations of the second aspect, the processing unit is further configured to: recording a first time point when a client process initiates a communication request to a service process; recording a second time point when the service process responds to a communication request initiated by the client process; determining service waiting time according to the first time point and the second time point; when the service waiting time is greater than the threshold value, the service information in the communication request and the data corresponding to the service information are stored in the storage unit.
With reference to the second aspect, in certain implementations of the second aspect, the processing unit is further configured to: when a client process initiates a communication request to a service process, recording the times of the communication request; 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 storage unit.
With reference to the second aspect, in certain implementations of the second aspect, the processing unit is further configured to: when the service waiting time is greater than the threshold value and the number of communication requests is greater than the threshold value, the service information and the data corresponding to the service information are stored in the storage unit.
With reference to the second aspect, in some implementations of the second aspect, the data corresponding to the service information is updated by a service process.
With reference to the second aspect, in some implementations of the second aspect, the service information includes a service name and interface information corresponding to the service.
With reference to the second aspect, in certain implementations of the second aspect, the storage unit is a cache storage unit.
In a third aspect, there is provided an apparatus comprising a processor for performing the technical solution as described above in the first aspect and any possible designs of the first aspect thereof.
In a fourth aspect, there is provided an electronic device comprising: one or more processors; one or more memories storing service information and data corresponding to the service information; the one or more memories store one or more computer programs comprising instructions that, when executed by the one or more processors, cause the electronic device to perform the technical solution as described above in the first aspect and any of the possible designs of the first aspect thereof.
It will be appreciated that the electronic device may control the one or more processors to perform the technical solutions as described above in the first aspect and any possible designs of the first aspect thereof.
In a fifth aspect, a chip is provided, where the chip is coupled to a memory in an electronic device, and is configured to invoke a computer program stored in the memory and execute the technical solution of the first aspect and any possible design of the first aspect of the embodiment of the present application; "coupled" in embodiments of the present application means that the two components are directly or indirectly joined to each other.
In a sixth aspect, a computer readable storage medium is provided, the computer readable storage medium comprising a computer program, which when run on an electronic device causes the electronic device to perform the technical solution as described in the first aspect and any one of the possible designs of the first aspect.
In a seventh aspect, a computer program product is provided which, when run on an electronic device, causes the computer to carry out the technical solution as described above in the first aspect and any one of the possible designs of the first aspect.
The advantages of the second aspect to the seventh aspect may be referred to as the advantages of the first aspect, and the description thereof will not be repeated.
Drawings
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
FIG. 2 is a schematic block diagram of a storage hierarchy provided by an embodiment of the present application.
Fig. 3 is a schematic software structure of an electronic device according to an embodiment of the present application.
FIG. 4 is a schematic diagram of a binder communication mechanism.
FIG. 5 is a schematic flow chart of a binder communication mechanism.
Fig. 6 is a schematic flow chart of an inter-process communication method provided by an embodiment of the present application.
Fig. 7 is a schematic flow chart of another inter-process communication method provided by an embodiment of the present application.
FIG. 8 is a schematic flow chart of a time-consuming detection method for interprocess communication provided by an embodiment of the application.
Fig. 9 is a schematic flow chart of another inter-process communication method provided by an embodiment of the present application.
Fig. 10 is a schematic block diagram of an inter-process communication apparatus according to an embodiment of the present application.
Fig. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terminology used in the following examples is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include, for example, "one or more" such forms of expression, unless the context clearly indicates to the contrary. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" means one, two or more than two. The "first", "second" and various numerical numbers are merely for convenience of description and are not intended to limit the scope of embodiments of the present application. The character "/" generally indicates that the context-dependent object is an "or" relationship. The sequence numbers of the processes below do not mean the sequence of execution, and the execution sequence of the processes should be determined by the functions and the internal logic, and should not be construed as limiting the implementation process of the embodiments of the present application. For example, in the embodiments of the present application, words "501", "601", "701" and the like are merely identifiers for convenience of description, and do not limit the order of executing steps.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. In the present application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise. In the embodiment of the application, the descriptions of "when … …", "in the case of … …", "if" and "if" all refer to that the device will make corresponding processing under some objective condition, and are not limited in time, nor do the device require that the device have a judging action in implementation, nor are other limitations meant to exist.
Embodiments of electronic devices and methods for using such electronic devices are described below. In some embodiments, the electronic device may be a portable electronic device such as a cell phone, tablet computer, wearable electronic device (e.g., smart watch) with wireless communication capabilities, etc., that also includes other functionality such as personal digital assistant and/or music player functionality. Exemplary embodiments of portable electronic devices include, but are not limited to, piggy-back Hong (Harmony OS) or other operating system. The portable electronic device may also be other portable electronic devices such as a Laptop computer (Laptop) or the like. It should also be appreciated that in other embodiments, the electronic device described above may not be a portable electronic device, but rather a desktop computer, smart television, smart speaker, or the like.
Fig. 1 shows a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 1, fig. 1 shows a schematic configuration 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 (universal serial bus, USB) interface 130, a charge 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, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identity (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 may 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 sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It should be understood that the illustrated structure of the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the application, electronic device 100 may include more or fewer components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors. The controller may be a neural hub and a command center of the electronic device 100, among others. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include inter-integrated circuit (inter-integrated circuit, I2C) interfaces, inter-integrated circuit audio (inter-integrated circuit sound, I2S) interfaces, pulse code modulation (pulse code modulation, PCM) interfaces, universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interfaces, mobile industry processor interfaces (mobile industry processor interface, MIPI), general-purpose input/output (GPIO) interfaces, SIM card interfaces, and/or USB interfaces, among others. The USB interface 130 is an interface conforming to the USB standard, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 130 may be used to connect a charger to charge the electronic device 101, or may be used to transfer data between the electronic device 101 and a peripheral device. The USB interface 130 may also be used to connect headphones through which audio is played.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
The internal memory 121 may be used to store one or more computer programs, including instructions. The processor 110 may execute the above-described instructions stored in the internal memory 121. The internal memory 121 may include a storage program area and a storage data area. The storage program area can store an operating system; the storage program area may also store one or more applications (such as gallery, contacts, etc.), etc. The storage data area may store data created during use of the electronic device 101 (e.g., photos, contacts, etc.), and so on. In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as one or more disk storage units, flash memory units, universal flash memory (universal flash storage, UFS), embedded multimedia cards (Embedded Multi Media Card, eMMC), and the like. In some embodiments, processor 110 may cause electronic device 101 to perform methods, as well as other applications and data processing, provided in embodiments of the present application by executing instructions stored in internal memory 121, and/or instructions stored in a memory provided in processor 110. The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playing, recording, etc.
FIG. 2 shows a schematic block diagram of a storage hierarchy provided by an embodiment of the present application. As shown in fig. 2, the storage hierarchy is divided into 4 layers, namely, a register memory (register memory), a cache memory (cache memory), a main memory (main memory) and an auxiliary memory (auxiliary memory) from top to bottom.
The storage hierarchy is the arrangement sequence of the storage system hierarchy, and each layer has higher read-write speed and lower delay and smaller capacity compared with the next layer.
The register is a storage area for storing data by the processor, and is used for temporarily storing the data participating in the operation and the operation result. The registers may be provided inside the processor. The registers may typically be located inside the processor.
The cache memory is a memory existing between the main memory and the register, and has a smaller capacity, but is faster in read and write speed than the main memory. The data in part of the main memory can be stored in the cache memory, so that the processor can access the cache memory when reading the data, and can access the main memory when the cache memory does not contain the needed data.
Main memory, also referred to as main memory, internal memory, is referred to as internal memory (i.e., 121 in FIG. 1) and is used for storing instructions and data. When the processor needs to read the data, the data can be read in the cache memory first, when the data is not in the cache memory, the processor can search the data in the main memory, and when the processor finds the data in the main memory, the found data can be cached in the cache memory so that the data can be read in the cache memory directly next time. The main memory is slower than the cache memory and faster than the auxiliary memory.
The secondary memory, also referred to as external memory (i.e. 120 in fig. 1), refers to memories other than main memory, cache memory, registers in the electronic device, such as hard disk (hard disk), optical disk memory.
It should be noted that the storage hierarchy shown in fig. 2 is only an example, and the present application is not limited thereto, and 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, L3 cache.
Fig. 3 shows a software architecture block diagram of the electronic device 100 of an embodiment of the application.
The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers, from top to bottom, an application layer, an application framework layer, an Zhuoyun row (Android run) and system libraries, and a kernel layer, respectively. The application layer may include a series of application packages.
As shown in fig. 3, the application layer may include gallery, calendar, map, navigation, talk, camera, setup, video, music, text, etc. applications. The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer may include some predefined functions. As shown in FIG. 2, the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like. The content provider is used to store and retrieve data and make such data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebooks, etc. The content provider is used to store and retrieve data and make such data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebooks, etc. The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a text message notification icon may include a view displaying text and a view displaying a picture. The telephony manager is used to provide the communication functions of the electronic device 100. Such as the management of call status (including on, hung-up, etc.). The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like. The notification manager allows the application to display notification information in a status bar, can be used to communicate notification type messages, can automatically disappear after a short dwell, and does not require user interaction. Such as notification manager is used to inform that the download is complete, message alerts, etc. The notification manager may also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, e.g., a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For another example, a text message is presented in a status bar, a warning tone is emitted, the electronic device vibrates, and an indicator light blinks.
Android runtimes include core libraries and virtual machines. Android run time is responsible for scheduling and management of the Android system. The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
The system library may include a plurality of functional modules. For example: surface manager (surface manager), media library (media library), three-dimensional graphics processing library (e.g., openGL ES), 2D graphics engine (e.g., SGL), etc. The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications. Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc. The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like. The 2D graphics engine is a drawing engine for 2D drawing. In addition, the system library can also comprise a state monitoring service module and the like, such as a physical state recognition module, which is used for analyzing and recognizing gestures of a user; the sensor service module is configured to monitor sensor data uploaded by various sensors in the hardware layer, and determine a physical state of the electronic device 100.
The kernel layer is a layer between hardware and software. The kernel layer may contain display drivers, camera drivers, audio drivers, sensor drivers, and binder drivers, etc.
For easy understanding, the following embodiments of the present application will take an electronic device having a structure shown in fig. 1 to 3 as an example, and specifically describe an inter-process communication method provided by the embodiments of the present application with reference to the accompanying drawings and application scenarios.
FIG. 4 shows a schematic diagram of a binder communication mechanism.
In operating systems such as Android and hong Meng, user IPC is realized by depending on a binder, which is one of very important characteristics in the operating system, and a communication mechanism model is realized based on a communication mode of a client/server (C/S). The binder communication adopts a C/S mode, and from the view point of the components, the binder communication comprises a client (client) end, a service (server) end, a service manager (service manager) and a binder driver.
For each Android process, only the virtual address space owned by the process itself can be run. For example, an Android process corresponds to a 4GB virtual address space, where 3GB is user space and 1GB is kernel space, and the size of the kernel space can be adjusted by parameter configuration. For user space, different processes cannot share each other, while kernel space is shareable. 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), the kernel memory space sharable between the processes can be used to complete the underlying communication work, and the client process and the server process can interact with the binder driver of the kernel space by adopting a function ioctl or the like for managing the I/O channels of the device in the device driver.
As shown in fig. 4, the communication procedure based on the binder mechanism can be mainly summarized as the following three procedures: registration of services, acquisition of services, and use of services. Registration service: the server process registers the service to the service manager first. Acquisition service: before a client process uses a certain service, the client process acquires the corresponding service from the service manager. Use of the service: the client process establishes a communication path with the server process where the service is located according to the obtained service information, and then can directly interact with the service. It will be appreciated that interactions between client processes, server processes, and service manager in FIG. 4 are all shown in dashed lines, as they are not directly interacting with each other, but rather through interactions with the binder driver, thereby enabling IPC communications. The client process may also be referred to as a client, and the server process may also be referred to as a server.
Wherein the binder driver is located in kernel space (i.e., in kernel layer), and the client process, server process, and service manager are located in user space. The client driver and the service manager can be regarded as the basic framework of the operating system, the client process and the server process are application layers of the operating system, and a user only needs to realize the client process and the server process in a self-defined mode, and IPC communication can be directly carried out by means of the basic platform framework of the operating system.
FIG. 5 shows a schematic flow chart of a binder communication mechanism.
From the above, it can be seen that the client process and the server process interact through a binder driver. The specific procedure of the client process requesting the service, which may specifically include S501 to S505 as shown in fig. 5, will be described in detail below taking the service of requesting to acquire the phone number of "Zhang san".
S501, registering a service with a service management by a server process.
The server process is a process for providing services in the C/S mode, namely a service process.
In this step, since the server process cannot directly interact with the service management, the server process registers a service with the service management including many services, for example, a service for acquiring a phone number, through a binder driver.
It should be appreciated that the server process first registers the directory number acquisition service with the binder driver, and then the binder driver will send the registered directory number acquisition service to the service manager.
S502, a client process initiates a request for acquiring a service to service management.
Wherein, the client process is a process using a service in a C/S mode, namely, a client process.
In this step, since the client process cannot directly interact with the service management, the client process initiates a request for acquiring a service to the service management through the driver, and transmits information such as a service name. The request may be a service request for obtaining a telephone number, and the service name may be a service for obtaining a telephone number.
Illustratively, the client process first sends a request to the binder driver to obtain the service of the phone number, and then the binder driver sends the request to the service manager, which can know that the client process needs to obtain the relevant service information of the phone number.
S503, the service management returns service information to the client process.
Specifically, after service management finds service information of a corresponding server according to a service name in a service acquisition request sent by a client process, the corresponding server service information is returned to the client process through a binder driver, and operations such as memory mapping are realized to prepare for inter-process communication IPC. The service information is understood here to mean the acquisition of service information corresponding to a telephone service.
S504, the client process sends data to the server process.
Specifically, after receiving service information corresponding to the service returned by the binder driver, the client process packages the data to be acquired, and sends the data to the service management and/or to the server process by means of the memory map created by the binder driver to perform corresponding processing. That is, the client process first sends the data to be acquired to the binder driver, which then sends the data to be acquired to the service management and/or server process.
It should be understood that the data to be acquired is data corresponding to the service information, that is, data that the user wants to acquire, and the data may be, for example, a phone number of "Zhang Sanj".
S505, the server process sends a return result to the client process through the binder driver.
Specifically, after receiving data, the server process takes out threads from the thread pool, unpacks the data and calls a target method, and finally returns the original path of the processing result to the client process. That is, the server process and/or the service manager may obtain a corresponding result according to the data sent by the client process, and send the result to the binder driver, which in turn sends the result to the client process. It should be appreciated that the return result here may be, for example, a "Zhang Sanj" telephone number.
In summary, the service request of the user (for example, the service of obtaining the phone number of Zhang Sanning) can be completed through S501 to S505, the user can know what type of service needs to be obtained (for example, the service of obtaining the phone) through S501 to S503, and specific data corresponding to the service (for example, the phone number of Zhang Sanning) can be obtained through S504 and S505. In the step S503, the returned service information is obtained, and in the step S505, the client process needs to send information to the service management or server process through the driver, and the service management or server process processes the information according to the received information and then returns the corresponding result through the driver.
Under the communication mechanism of the binder, when the server process receives and processes the request message, the request thread of the client process is suspended until the processing result of the server process is returned. Therefore, when the server process has long processing time, the client process may have problems such as jamming, slow response, and even ANR. For this problem, there is no system optimization scheme at present.
Therefore, the application provides an inter-process communication IPC method, which is characterized in that a cache mechanism is added in a binder driver to cache the returned result of a service process, so that the service execution times of the service process and the waiting time of a client process are reduced, the running speed of electronic equipment can be improved, and the user experience is enhanced.
Fig. 6 shows a schematic flow chart of a method for interprocess communication provided by an embodiment of the application. As shown in fig. 6, the method 600 may be performed by a processor in an electronic device, and the method 600 includes S601 to S604, and a specific procedure of obtaining a service by a client process will be described in detail below taking the service of obtaining a phone number of "Zhang san".
S601, the processor acquires a request message of a client process for initiating a communication request to a service process.
It should be understood that. When a user needs to obtain a certain service, a request message needs to be sent to a service process. The request message may be, for example, a request for acquiring a service sent by the client process to the service process in S502, and/or a request for data to be acquired sent by the client process to the service process in S504.
S602, the processor determines the service information to be stored in the memory according to the service information in the request message.
It should be appreciated that the processor may determine which services are needed by the client process based on the service information in the request message sent by the client process. For example, a request message sent by the client process to the server process is used for requesting to acquire the phone number of "Zhang Sanning", the service information is used for indicating to acquire the phone number of "Zhang Sanning", and the service information includes a service name and interface information corresponding to the service. The service name may be understood as a service name corresponding to the acquired telephone service, and the interface information corresponding to the service may be understood as interface information to be accessed by acquiring the telephone number of Zhang Saner. The server process confirms which information is needed by the client process according to the service information, so that the information needed by the client process is sent to the client process.
It should also be appreciated that the memory is located in kernel space (i.e., kernel layer), which may be, for example, a cache memory (cache). The memory stores service information and data corresponding to the service information, wherein the service information comprises a service name and interface information corresponding to the service. When the processor determines from the service information in the request message that the service information has been stored in the memory, the processor may directly obtain data corresponding to the service information from the memory and return the data to the client process.
For example, when the user wants to obtain the phone number of "Zhang San", and the related service information corresponding to the obtained phone number of "Zhang San", is stored in the memory, the client process may first obtain the data corresponding to the phone service from the memory, and then may also obtain the phone number of "Zhang San", from the memory. That is, the service information may include service information for acquiring a telephone and interface information corresponding to a service for acquiring a telephone number, and the data corresponding to the service information may include related data corresponding to the acquired telephone number; alternatively, the service information may include service information corresponding to the telephone number of "Zhang Sanning" and interface information corresponding to the telephone number service of "Zhang Sanning" is acquired, and the data corresponding to the service information may include the telephone number of "Zhang Sanning".
It should also be appreciated that, before S602, the method may further perform the method shown in fig. 7, and the method 700 may store the service that satisfies the corresponding condition in the memory, so that when the client process invokes the service again, the service information and the data corresponding to the service information may be directly obtained from the memory.
S603, the processor acquires data corresponding to the service information from the memory.
It should be understood that the processor determines that the service information is stored in the memory (e.g. cache) according to the service information in the client process sending request message, so that the request message does not need to be sent to the server process, and the data corresponding to the service information can be directly obtained from the memory (e.g. cache), so that a large number of unnecessary service calls can be reduced, and the waiting time of the client process IPC is shortened.
For example, if the service information corresponding to the acquired "Zhang San" phone number is stored in the cache, the processor may directly acquire the "Zhang San" phone number from the cache, without sending the service information corresponding to the acquired "Zhang San" phone number to the server process, and then acquire the "Zhang San" phone number, so that unnecessary call of the server process may be reduced.
It should be noted that, the data corresponding to the service information may be updated by the service process. That is, the data corresponding to the service information may be dynamically changed in real time, and when the server process detects that the data corresponding to the service information is changed, the data corresponding to the service information may be updated, so that when the user invokes the service, an accurate result corresponding to the service may be obtained.
Optionally, if the processor detects that the service corresponding to a certain service information in the memory is not invoked for a long time, the processor may actively delete the service information and the data corresponding to the service information, so that a storage space in the memory may be saved, so as to store other service information and the data corresponding to the service information.
Optionally, if the processor detects that a service consumes longer time and/or has too high access frequency by using the method as shown in fig. 8, 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 the services again, the data corresponding to the services may be directly obtained from the memory, thereby reducing unnecessary service calls, improving the running speed and system performance of the electronic device, and enhancing the user experience.
And S604, the processor sends the data corresponding to the service information to the client process.
Specifically, the processor may obtain data corresponding to the service information from the memory (e.g., cache) according to the service information, and send the data to the client process, so that the processor may use the data corresponding to the service information for subsequent processing. For example, the data corresponding to the service information may be a telephone number of "Zhang San", or the like.
According to the IPC method provided by the embodiment of the application, the processor can determine the service information according to the service information in the request message and store the service information in the memory, so that the data corresponding to the service information can be directly obtained from the memory and sent to the client process. Because the memory is located in the kernel space, the client process can acquire 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, so that unnecessary service call can be reduced, the problems of system blocking and the like caused by IPC operation are avoided, the occupation of system resources can be effectively reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
Fig. 7 is a schematic flow chart of another method of inter-process communication provided by an embodiment of the present application. As shown in fig. 7, the method 700 may be performed by a processor in an electronic device, and the method 700 includes S701 to S704, which describe in detail a specific procedure in which a client process obtains a service.
It should be noted that, the method 700 may be performed before the method 600, that is, the processor may obtain the service that needs to be stored in the memory by performing S701 to S704, and then when the client process invokes the service, may directly obtain the required data from the memory, so that it is not necessary to send a request message to the service process to obtain the required data.
S701, the processor acquires a request message that the client process initiates a communication request to the service process.
This step may refer to S601, and will not be described herein.
S702, the processor sends the request message to the service process.
It should be appreciated that the processor may send the request message to the service process through the binder driver, for example, according to the method flow described in fig. 5, to obtain data in the service process corresponding to the service information in the request message.
S703, the processor receives the 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.
Specifically, after the processor sends the request message sent by the client process to the server process through the binder driver, the server process takes out the thread from the thread pool, performs data unpacking and target method calling, and determines the data corresponding to the service information in the request message. The processor receives data corresponding to the service information sent by the server process, and stores the service information and the data corresponding to the service information in a memory (e.g., a cache).
For example, after the server process obtains the data related to the "Zhang Sanning" number, the service information corresponding to the "Zhang Sanning" number and the related data corresponding to the "Zhang Sanning" number (for example, the "Zhang Sanning" number) may be stored in the cache, so that when the "Zhang Sanning" number is obtained next time, the data related to the "Zhang Sanning" number may be directly obtained from the cache, without sending the service information corresponding to the "Zhang Sanning" number to the server process, and then obtaining the related data corresponding to the "Zhang Sanning" number, thereby reducing unnecessary call of the server process.
Optionally, the service information and the data corresponding to the service information may be cached in the cache in a key value pair manner, and in specific storage, the service information may be used as a key value, and the data corresponding to the service information may be used as a value. Therefore, when the data stored in the cache is queried, the data corresponding to the service information can be acquired from the service information acquisition cache according to the service information in the request message.
It should be appreciated that the IPC operation duration and/or the ease of invoking a service and/or the number of service requests, etc. may be considered in determining which services may be stored in memory (e.g., cache).
In some embodiments, the processor records a first point in time when the client process initiates a communication request to the server process; when the server process responds to a communication request initiated by the client process, the processor records a second time point; the processor determines service waiting time according to the first time point and the second time point; when the preset condition is met, the processor stores the service information in the communication request and the data corresponding to the service information in the memory. Alternatively, the preset condition may be that the service waiting time is greater than a threshold, which may be an empirical value, for example, 6ms, 10ms, etc., which the present application is not limited to.
In some embodiments, the processor records the number of communication requests when the client process initiates a communication request to the server process; when the number of communication requests is greater than the threshold, the processor may store the service information in the communication request and data corresponding to the service information in the memory.
In some embodiments, the processor may also detect the service waiting time and the number of service requests at the same time, and when the service waiting time is greater than a threshold value and the number of times the client process initiates a communication request to the server process is greater than the threshold value, the processor may also store the service information in the communication request and the data corresponding to the service information in the memory
In general, for a service stored in memory, the number of times a client process invokes the service should be much greater than the number of times the service process modifies the service. The details are described below in conjunction with the content of fig. 8, and are not repeated here.
And S704, the processor sends the data corresponding to the service information to the client process.
Specifically, after receiving the data corresponding to the service information returned in the service process, the processor may send the data to the client process, so that the processor may use the data corresponding to the service information to perform subsequent processing. For example, the data corresponding to the service information may be a telephone number of "Zhang San", or the like.
According to the IPC method provided by the embodiment of the application, the processor can send the request message to the service process, acquire the data corresponding to the service information returned by the service process, and store the service information and the data corresponding to the service information in the memory, namely cache the result returned by the service process, so that the processor can directly acquire the data corresponding to the service information from the memory and send the data to the client process when the client process calls the service again next time, thereby reducing unnecessary service call, avoiding the problems of system blocking and the like caused by IPC operation, effectively reducing the occupation of system resources, improving the running speed and the system performance of the electronic equipment, and enhancing the user experience.
FIG. 8 is a schematic flow chart of a method for detecting time consumption of inter-process communication according to an embodiment of the present application. As shown in fig. 8, the method 800 specifically includes S801 to S808, and these steps are described in detail below, respectively.
S801, the program calls an IPC interface request service.
It should be appreciated that different request messages/programs, corresponding IPC application program interfaces are different, e.g. a request to open an address book and a request to open a camera application require access to different communication interfaces.
S802, entering a custom hook function (hook function).
It should be appreciated that in the embodiment of the present application, by writing a custom hook function by means of the hook technology, the hook operation of the IPC processing interface for all application processes is implemented by replacing one native program app_process (i.e., the main entry point of the application process) of the operating system (e.g., the android system) during the system running.
The hook technology is a technology for changing the execution result of the API, and can redirect the execution of the API function of the system. The start time and end time of the IPC can be recorded by the hook function, so that the IPC time consumption can be determined.
S803, record start time.
S804, calling a system function to perform IPC operation.
S805, after receiving the IPC result, recording the end time.
Through S803 to S805, the duration of each IPC operation (i.e., the operation duration of each service) is determined by recording the start time and the end time at the start position and the end position, respectively, using the hook function.
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. That is, the time detection may be the detection of the times of S502 and S503, that is, the time corresponding to the acquisition of the service to the return of the service information; the time from S502 to S505, i.e., the time from the acquisition of the service to the return of the specific data corresponding to the service, may also be detected.
S806, if the difference between the ending time and the starting time is larger than the set maximum duration, determining that IPC timeout occurs, and printing an abnormal log.
The waiting time length of the current IPC operation is obtained through the difference between the ending time and the starting time, the maximum waiting time length is set as a threshold value, and when the difference is larger than the threshold value (for example, 5ms and 10 ms), the phenomenon of waiting timeout is considered to occur. For the IPC operation causing the waiting timeout, log information such as waiting time length, stack and the like is printed for the next investigation and optimization.
S807, checking the source code according to the exception log, and judging the IPC operation type.
S808, if the IPC operation type is query type IPC operation, adding the IPC information into the cache, and setting the operation to be optimized.
It should be understood that the inquiry IPC operation can be understood as an operation of frequently using interfaces, and the number of accesses of these interfaces is much larger than the number of modifications. For such IPC operations, its service information and the data corresponding to the service information may be added to the cache.
Two types of values can be included in the cache, one type of target method identifier representing the IPC operation is service information, and the service information can be used for identifying the service name and interface information called by the IPC operation; the other type corresponds to the result of the service information, namely the data corresponding to the service information, wherein the data is the result returned by the server process.
In addition, in determining which services need to be stored in the memory, not only the IPC operation duration but also the difficulty of calling the service and/or the number of service requests may be considered.
In some embodiments, the processor may determine whether to save the service in memory based on how hard the invoked service is, e.g., the service to obtain the phone number of "Zhang Sanj" is relatively simple, while the service to dial the phone number of "Zhang Sanj" is relatively complex, in which case the service to obtain the phone number of "Zhang Sanj" may be saved in memory.
In some embodiments, the processor records the number of communication requests within a time frame when the client process initiates a communication request to the service process; when the number of communication requests is greater than a threshold, which may be, for example, an empirical value, the processor stores the service information and data corresponding to the service information in the memory.
By setting the threshold value of the service request times, the frequently called service is detected, and the service information corresponding to the service and the data corresponding to the service information are stored 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, unnecessary service call can be reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
In some embodiments, the processor may detect both the service latency and the number of service requests, and when the service latency 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 may store the service information and data corresponding to the service information in the memory.
By setting the threshold value of service waiting time and the threshold value of service request times, the service which causes the excessively long waiting time of the client process and initiates the communication request for multiple times is detected, and the service information corresponding to the service and the data corresponding to the service information can be stored in the memory, so that the running speed and the system performance of the electronic equipment can be further improved, and the user experience is enhanced.
In some embodiments, the processor may further comprehensively consider the IPC operation duration, the difficulty level of invoking the service, and the number of service requests, and further find the target interface to be cached by comprehensively considering these factors, so that the interface information and the service information invoking the interface may be stored in the cache, which may further improve the running speed and system performance of the electronic device, and enhance the user experience.
Through S801 to S808, the time consumption of IPC can be detected, a server process that causes the waiting time of a client process to be too long is identified, and the service information and the data corresponding to the acquired service information are stored in a memory (e.g., a cache), so that when the client process calls the service again, the data corresponding to the service can be directly acquired from the memory (e.g., the cache), and thus unnecessary service calls can be reduced.
In addition, by the IPC time-consuming detection method provided by the embodiment of the application, the hook function is written to replace app_process in the system starting process, so that the hook operation of the IPC interfaces of all application processes is realized under the condition that an upper application program is not aware, the execution time of each IPC operation can be further obtained, the service of a server process which causes the client process to wait for overtime of the IPC operation is found, and the subsequent positioning analysis is facilitated. Meanwhile, the IPC time-consuming detection method provided by the embodiment of the application is not limited by the android version, the root authority, the business function and the system performance.
Fig. 9 is a schematic flow chart of another method of interprocess communication provided by an embodiment of the application. As shown in fig. 9, the method 600 may be performed by a processor in an electronic device, and the method 900 specifically includes S901 to S907.
S901, the program calls an IPC interface request service.
S902, the binder driver receives the request message.
It should be understood that when the client process initiates communication to the server process, information interaction needs to be performed through the binder driver, and specific reference may be made to S501 to S505, which are not described herein.
When the binder driver receives the request message, the binder driver may first determine whether service information (i.e., the service name and interface information corresponding to the service) in the request message is stored in the cache, where the request message may be, for example, a phone number requesting to obtain "Zhang Sanj".
S903, judging according to service information provided by the client process.
S904, judging whether the cache has corresponding record item information.
When the client process sends a request message to the server process, the processor first judges whether service information in the request message is in the cache, namely judges whether corresponding record item information exists in the cache. If the service information is in the cache, that is, the cache has corresponding record item information, the processor may execute S905; if the service information is not in the cache, i.e. there is no corresponding entry information in the cache, the processor may execute S906 and S907.
The service information comprises a service name and interface information corresponding to the service. For example, the service name may be a service for acquiring a phone service, and the interface information corresponding to the service may be understood as interface information corresponding to a service for acquiring a "Zhang Sanj" phone number. The entry information may be understood as the service information and the data corresponding to the service information. The service information may be understood as service information of a server process provided by a client process in a service request process, that is, what system service is acquired (for example, a telephone service is acquired) and specific data under the system service (for example, a telephone number of "Zhang Sanj") needs to be acquired.
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) is changed, the server process may update through the interface provided by the binder driver, and store the updated information into the cache, so as to be convenient for the next call.
For example, an application in a mobile phone may often obtain location information of a user, but the location of the user may not change for several hours or even a day, and for such a service to obtain location information, the processor may also store it in a cache. When the server process discovers that the user positioning is changed, the specific content of the position can be updated through an interface which is provided by a binder driver and related to the positioning, so that the information stored in the cache is accurate and error-free, and the next call of the user is facilitated.
S905, if the cache has corresponding record item information, packaging the result information and returning the result information to the client process.
Specifically, the processor judges whether the service information is in the cache according to the service information in the client process sending request message, if the service information is not in the cache, the processor sends the request message to the server process, and the server process determines data corresponding to the service information according to the service information, wherein the data corresponding to the service information is, for example, the phone number of Zhang Saner.
S906, if the cache has no corresponding record item information, calling a server process corresponding service to process according to a normal flow, and waiting for a return result.
Specifically, the processor determines whether the service information is in the cache according to the service information in the client process sending the request message, if the service information is not in the cache, the processor sends the request message to the server process, and the server process determines data corresponding to the service information according to the service information, and details of the server process may refer to fig. 5 and will not be described herein.
For example, if the service information corresponding to the acquired "Zhang Sanj" phone number is not in the cache, the processor needs to send the service information corresponding to the acquired "Zhang Sanj" phone number to the server process, and then acquire the data related to the "Zhang Sanj" phone number.
S907, packaging and returning the result information to the client process according to the result returned by the server process, and inserting the processing result into the cache.
Specifically, after receiving the data corresponding to the service information returned in the service process, the processor may send the data to the client process, so that the processor may use the data corresponding to the service information to perform subsequent processing. For example, the data corresponding to the service information may be a telephone number of "Zhang San", or the like.
For example, if the cache does not have the corresponding record item information, the server process may be invoked to process the record item information, and in the process of ending the process and returning the result, the < service information and the data corresponding to the service information > may be used as a pair of < key, value >, i.e. the service information and the data corresponding to the service information are inserted into the cache in a key value pair manner.
It should be appreciated that the IPC operation duration and/or the ease of invoking a service and/or the number of service requests, etc. may be considered in determining which services may be stored in the cache.
In some embodiments, the processor records a first point in time when the client process initiates a communication request to the server process; when the server process responds to a communication request initiated by the client process, the processor records a second time point; the processor determines service waiting time according to the first time point and the second time point; and when the service waiting time is greater than the threshold value, the processor stores the service information in the communication request and the data corresponding to the service information in the cache.
In some embodiments, the processor records the number of communication requests when the client process initiates a communication request to the server process; and when the number of times of communication requests is greater than a threshold value, the processor stores the service information and data corresponding to the service information in a cache.
In some embodiments, the processor may also detect the service waiting time and the number of service requests at the same time, and when the service waiting time is greater than a threshold value and the number of times the client process initiates a communication request to the server process is greater than the threshold value, the processor may store the service information and data corresponding to the service information in the cache.
In general, for a service held in memory, the number of times that the client process calls the service should be much greater than the number of times that the server process modifies the service. The specific content may refer to fig. 8, and will not be described herein.
According to the IPC method provided by the embodiment of the application, whether the service information in the request message of the client process is in the cache is judged, if the service information is in the cache, the processor can directly acquire 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, acquire data corresponding to the service information returned by the server process, store the service information and the data corresponding to the service information in the cache, namely cache a result returned by the server process, so that when the client process recalls the service information next time, the processor can directly acquire the data corresponding to the service information from the cache and send the data to the client process. By the method provided by the embodiment of the application, unnecessary service call can be reduced, the problems of system blocking and the like caused by IPC operation are avoided, the occupation of system resources is effectively reduced, the running speed and the system performance of the electronic equipment are improved, and the user experience is enhanced.
The above description mainly describes an inter-process communication method provided by the embodiment of the application from the perspective of electronic equipment. It will be appreciated that the electronic device, in order to achieve the above-described functions, includes corresponding hardware structures and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application can divide the functional modules of the processor in the electronic device according to the method example, for example, each functional module can be divided corresponding to each function, and two or more functions can be integrated in one processing module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
Fig. 10 is a schematic block diagram of an inter-process communication apparatus according to an embodiment of the present application in the case where division of respective functional blocks corresponding to respective functions is employed. As shown in fig. 10, the IPC apparatus 1000 may include: a storage unit 1010, a processing unit 1020, and a transceiving unit 1030.
The storage unit 1010 is used for storing service information and data corresponding to the service information.
The processing unit 1020 is configured to obtain a request message that the client process initiates a communication request to the service process, determine service information according to service information in the request message, store the service information in the storage unit, and obtain data corresponding to the service information from the storage unit.
The transceiver 1030 is configured to transmit data corresponding to the service information to the client process.
Optionally, the transceiver 1030 is further configured to send a request message to a service process, and receive data corresponding to the service information sent by the service process; the processing unit 1020 is further configured to store the service information and data corresponding to the service information in the storage unit.
Optionally, the processing unit 1020 is further configured to: recording a first time point when a client process initiates a communication request to a service process; recording a second time point when the service process responds to a communication request initiated by the client process; determining service waiting time according to the first time point and the second time point; when the service waiting time is greater than the threshold value, service information in the communication request and data corresponding to the service information are stored in the storage unit 1010.
Optionally, the processing unit 1020 is further configured to: when a client process initiates a communication request to a service process, recording the times of the communication request; 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 storage unit.
Optionally, the processing unit 1020 is further configured to: when the service waiting time is greater than the threshold value and the number of communication requests is greater than the threshold value, the service information and the data corresponding to the service information are stored in the storage unit.
Optionally, the data corresponding to the service information is updated by the service process.
Optionally, the service information includes a service name and interface information corresponding to the service.
Alternatively, the storage unit 1010 is a cache storage unit.
It should be noted that, all relevant contents of each step related to the above method embodiment may be cited to the functional description of the corresponding functional module, which is not described herein. The inter-process communication device provided by the embodiment of the application is used for executing the inter-process communication method, so that the same effect as that of the processing method can be achieved.
Fig. 11 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. As shown in fig. 11, 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, including instructions. The instructions, when executed by the one or more processors 1110, cause the electronic device 1100 to perform the steps of the inter-process communication method of the embodiments described above.
Illustratively, the one or more processors 1110 may be the processor 110 shown in fig. 1, and the one or more memories 1120 may be the internal memory 120 shown in fig. 1 and/or an external memory connected to the electronic device.
The embodiment of the application provides a device which comprises a processor, wherein the processor is used for executing the inter-process communication method in each method embodiment.
The embodiment of the application also provides a chip, which comprises a processor and a communication interface, wherein the communication interface is used for receiving signals and transmitting the signals to the processor, and the processor processes the signals so that the inter-process communication method in the method embodiments is executed.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores computer instructions, which when run on the electronic device, cause the electronic device to execute the inter-process communication method in the above method embodiments.
The present application also provides a computer program product which, when run on a computer, causes the computer to perform the inter-process communication method of the method embodiments described above.
In addition, the embodiment of the application also provides a device, which can be a chip, a component or a module, and can comprise a processor and a memory which are connected; the memory is configured to store computer-executable instructions, and when the device is running, the processor may execute the computer-executable instructions stored in the memory, so that the chip performs the inter-process communication method in the above method embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (18)

1. An inter-process communication method, comprising:
the method comprises the steps that a processor obtains a request message of a client process for initiating a communication request to a service process;
the processor determines the service information to be stored in a memory according to the service information in the request message, wherein the memory is positioned in a kernel space;
the processor acquires data corresponding to the service information from the memory;
the processor sends the data to the client process.
2. The method of claim 1, wherein before the processor determines from the service information in the request message that the service information is stored in memory, the method further comprises:
the processor sends the request message to the service process;
the processor receives the 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 of claim 2, wherein storing the service information and the data corresponding to the service information in the memory comprises:
The processor records a first time point when the client process initiates a communication request to the service process;
the processor records a second time point when the service process responds to a communication request initiated by the client process;
the processor determines service waiting time according to the first time point and the second time point;
and when the service waiting time is greater than a threshold value, the processor stores the service information and data corresponding to the service information in the memory.
4. The method of claim 2, wherein storing the service information and the data corresponding to the service information in the memory comprises:
when the client process initiates a communication request to the service process, the processor records the times of the communication request;
and when the number of times of the communication request is greater than a threshold value, 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, wherein the data corresponding to the service information is updated by the service process.
6. The method according to any one of claims 1 to 5, wherein the service information includes a service name and interface information corresponding to a service.
7. The method of any one of claims 1 to 6, wherein the memory is a cache memory.
8. An electronic device, comprising:
one or more processors;
one or more memories;
the one or more memories store one or more computer programs comprising instructions that, when executed by the one or more processors, cause the electronic device to:
acquiring a request message of a client process for initiating a communication request to a service process;
determining that the service information is stored in the one or more memories according to the service information in the request message, wherein the one or more memories are positioned in a kernel space;
acquiring data corresponding to the service information from the one or more memories;
and sending the data to the client process.
9. The electronic device of claim 8, wherein the instructions, when executed by the one or more processors, cause the electronic device to perform the steps of:
Sending the request message to the service process;
and receiving data corresponding to the service information sent by the service process, and storing the service information and the data corresponding to the service information in the one or more memories.
10. The electronic device of claim 9, wherein the instructions, when executed by the one or more processors, cause the electronic device to perform the steps of:
recording a first time point when the client process initiates a communication request to the service process;
recording a second time point when the service process responds to a communication request initiated by the client process;
determining a service waiting time according to the first time point and the second time point;
and when the service waiting time is greater than a threshold value, storing service information in the communication request and data corresponding to the service information in the one or more memories.
11. The electronic device of claim 9, wherein the instructions, when executed by the one or more processors, cause the electronic device to perform the steps of:
recording the times of communication requests when the client process initiates the communication requests to the service process;
And when the number of times of the communication request is greater than a threshold value, storing the service information and data corresponding to the service information in the one or more memories.
12. The electronic device of any one of claims 8 to 11, wherein the data corresponding to the service information is updated by the service process.
13. The electronic device of any one of claims 8 to 12, wherein the service information includes a service name and interface information corresponding to a service.
14. The electronic device of any one of claims 8-13, wherein the one or more memories are cache memories.
15. An apparatus comprising a processor configured to perform the method of any one of claims 1 to 7.
16. A chip comprising a processor and a communication interface for receiving signals and transmitting the signals to the processor, the processor processing the signals such that the method of any of claims 1 to 7 is performed.
17. A computer readable storage medium having stored therein computer instructions which, when run on a computer, cause the method of any of claims 1 to 7 to be performed.
18. A computer program product, characterized in that the computer program product, when run on a computer, causes the computer to perform the method of any of claims 1 to 7.
CN202210390253.9A 2022-04-14 2022-04-14 Inter-process communication method and electronic equipment Pending CN116954936A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210390253.9A CN116954936A (en) 2022-04-14 2022-04-14 Inter-process communication method and electronic equipment
PCT/CN2023/087802 WO2023198103A1 (en) 2022-04-14 2023-04-12 Inter-process communication method and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210390253.9A CN116954936A (en) 2022-04-14 2022-04-14 Inter-process communication method and electronic equipment

Publications (1)

Publication Number Publication Date
CN116954936A true CN116954936A (en) 2023-10-27

Family

ID=88328984

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210390253.9A Pending CN116954936A (en) 2022-04-14 2022-04-14 Inter-process communication method and electronic equipment

Country Status (2)

Country Link
CN (1) CN116954936A (en)
WO (1) WO2023198103A1 (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9584620B1 (en) * 2015-12-31 2017-02-28 International Business Machines Corporation Caching in storage clients
CN106547631B (en) * 2016-09-26 2021-04-20 腾讯科技(深圳)有限公司 Cross-process communication method and device based on android platform
CN108696551A (en) * 2017-04-06 2018-10-23 中兴通讯股份有限公司 The method and apparatus that addressing is asked between system process
CN113495795A (en) * 2020-04-03 2021-10-12 华为技术有限公司 Inter-process communication method and related equipment
CN115061743A (en) * 2022-06-08 2022-09-16 Oppo广东移动通信有限公司 Interface calling method and device, computer readable medium and electronic equipment

Also Published As

Publication number Publication date
WO2023198103A1 (en) 2023-10-19

Similar Documents

Publication Publication Date Title
WO2021083378A1 (en) Method for accelerating starting of application, and electronic device
CN113434288B (en) Memory management method and electronic equipment
CN113032766B (en) Application authority management method and device
WO2021185352A1 (en) Version upgrade method and related apparatus
WO2023051355A1 (en) Permission check method and electronic device
CN114816167A (en) Application icon display method, electronic device and readable storage medium
CN112765084A (en) Computer device, virtualization acceleration device, data transmission method, and storage medium
CN114706633B (en) Preloading method, electronic device and storage medium
US20230153246A1 (en) Memory management method and terminal device
CN115017534A (en) File processing authority control method and device and storage medium
CN116126744A (en) Memory recycling method and device and terminal equipment
CN116048828B (en) Method for processing drawing message, electronic device and storage medium
CN114253737B (en) Electronic device, memory recovery method thereof and medium
CN116954936A (en) Inter-process communication method and electronic equipment
CN114489471B (en) Input and output processing method and electronic equipment
CN117632400A (en) Task scheduling method, electronic device and computer readable storage medium
CN112783418B (en) Method for storing application program data and mobile terminal
CN116450473A (en) Method for positioning memory stepping problem and electronic equipment
CN113642010A (en) Method for acquiring data of extended storage device and mobile terminal
CN116662270B (en) File analysis method and related device
CN115981576B (en) Method for sharing data, electronic device and storage medium
CN114490442B (en) File fragment adjusting method and electronic equipment
US20240231890A1 (en) Memory management method and electronic device
CN116541180B (en) Memory allocation method, electronic equipment and storage medium
CN116089320B (en) Garbage recycling method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination