WO2021083378A1 - Method for accelerating starting of application, and electronic device - Google Patents

Method for accelerating starting of application, and electronic device Download PDF

Info

Publication number
WO2021083378A1
WO2021083378A1 PCT/CN2020/125814 CN2020125814W WO2021083378A1 WO 2021083378 A1 WO2021083378 A1 WO 2021083378A1 CN 2020125814 W CN2020125814 W CN 2020125814W WO 2021083378 A1 WO2021083378 A1 WO 2021083378A1
Authority
WO
WIPO (PCT)
Prior art keywords
page
file
application
memory
electronic device
Prior art date
Application number
PCT/CN2020/125814
Other languages
French (fr)
Chinese (zh)
Inventor
薛春
梁宇
石亮
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021083378A1 publication Critical patent/WO2021083378A1/en

Links

Images

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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Definitions

  • This application relates to the field of electronic equipment, and in particular to a method and electronic equipment for accelerating application startup.
  • the application (application, APP) installed on the mobile phone is divided into hot start and cold start when it is started.
  • the hot start means that the APP switches from the background to the foreground.
  • APP data is still cached in the memory of general mobile phones, which can be quickly started.
  • Cold start refers to the first start of the APP after the phone restarts, or the first start after the APP is killed (kill).
  • all or part of the data of the APP is not in the memory, and the APP needs to read the data from the external memory, so the startup delay is large and the user experience is poor.
  • the method and electronic device for accelerating the startup of an application provided by the present application can reduce the delay of the cold startup of the application and improve the user experience.
  • a method provided in this application is applied to an electronic device.
  • the electronic device contains a configuration file, and the configuration file includes information about a target page.
  • the method includes: in response to detecting an instruction to start a first application, the electronic device Start the first application; the electronic device requests to access the memory page required by the startup process of the first application; if the first memory page among the memory pages required for the startup process of the first application is not cached in the internal memory, the electronic device Read the content of the first memory page from the external memory and cache it in the internal memory; after the electronic device caches the first memory page from the external memory to the internal memory, the electronic device determines according to the information of the target page in the configuration file Whether the first memory page is the target page; after determining that the first memory page is the target page, the electronic device locks the first memory page in the internal memory.
  • the method further includes: the electronic device detects the instruction to exit the first application program, and the electronic device exits the first application program; when the electronic device detects the instruction to start the first application program again, the electronic device again Start the first application program; the electronic device obtains the memory page required by the startup process of the first application program; the electronic device displays the main interface of the first application program.
  • the missing pages can be read directly from the memory, reducing page missing due to the target page, improving the startup speed of the first application, and reducing the first screen time of the first application , Improve the user experience.
  • the target page is one or more pages in the target file, and the target page has been missing during the start of the first application; the target file is the one accessed when the first application is started.
  • One or more read-only files and are one or more files that are not related to user data when the first application program is accessed at startup, and the number of page missing occurrences is not related to the user data.
  • the file is writable (not read-only), it means that the file may be modified, and the position and content of each page in the file may change, and the page where the page is missing will not be fixed, and the page cannot be locked in advance In memory.
  • the file size can be used to judge. If the file size does not change during the running process, the file has a high probability of being a read-only file.
  • the judgment can also be made by obtaining the read and write information of the file, and the read and write information clearly indicates that the file is a read-only file or a readable and writable file.
  • the file read and write information can be obtained from the VFS.
  • other methods can also be used to determine whether the file is a read-only file, which is not limited in the embodiment of the present application.
  • the number of times a file has page missing is related to the user. For example, when using different accounts to log in to the application or the user data stored in the mobile phone is different, the page where the page is missing may not be fixed, and the page cannot be locked in memory in advance, which is inconvenient.
  • the mobile phone is deployed uniformly before leaving the factory.
  • the target file is one or more files whose access times are greater than a threshold when the first application is started.
  • the first preset number for example, 15
  • other methods can also be used to determine frequently accessed files.
  • the information of the target page in the configuration file includes the information of the target file and the information of the target page; the electronic device determines whether the first memory page is the target page according to the information of the target page in the configuration file, specifically: electronic The device determines whether the file where the first memory page is located is the target file according to the information of the target file in the configuration file; after determining that the file where the first memory page is located is the target file, the electronic device determines the first memory according to the information of the target page in the configuration file Whether the page is the target page.
  • the information of the target file in the configuration file includes the name of the target file.
  • the information of the target file may include: file name (file name), file index number (inode number), file size (file size), request size (request size), request offset (request offset), cache hit (hit ) Or miss, etc.
  • the target page information in the configuration file includes the size and offset of the target page.
  • the target page information may include: file index number, file size, request size, request offset, etc.
  • the method further includes: when the electronic device updates the operating system or the electronic device updates the first application program, the electronic device obtains the latest configuration file from the server to update it.
  • the target file and the configuration file of the target page may be one or more.
  • a configuration file can include target files and target pages corresponding to one or more applications.
  • a mobile phone contains a configuration file that contains target files and target pages of multiple applications.
  • the configuration file is usually maintained by the mobile phone manufacturer or mobile phone operating system manufacturer. Therefore, when the operating system of the mobile phone is upgraded, the target pages of multiple applications that need to be locked and unlocked can be adjusted directly according to the updated configuration file.
  • the mobile phone contains multiple configuration files, and each configuration file includes a target file and a target page of an application.
  • the configuration file corresponding to each application can be maintained by the application manufacturer. In this way, when a mobile phone installs and updates an application, the mobile phone can adjust the target page that the application needs to lock and unlock according to the updated configuration file of the application.
  • it is determined whether the file where the first memory page is located is the target file specifically: obtaining the read request of the first memory page, and obtaining the information of the file where the first memory page is located from the read request of the first memory page File index number, and obtain the file index number of the target file according to the name of the target file in the configuration file; determine whether the first memory page is the target file according to the file index number of the file where the first memory page is located and the file index number of the target file .
  • determining whether the first memory page is the target page is specifically: obtaining the size and offset of the first memory page from the read request of the first memory page; according to the size of the first memory page And offset, as well as the size and offset of the target page, determine whether the first memory page is the target page.
  • the electronic device after determining that the first memory page is the target page, locks the first memory page in the internal memory, specifically: after determining the first memory page as the target page, the electronic device locks the first memory page as the target page.
  • the content of a memory page is added to the non-removable linked list of the internal memory.
  • the method further includes: in response to detecting the instruction to uninstall the first application program, the electronic device unlocks the first memory page from the internal memory.
  • the electronic device unlocks the first memory page from the internal memory, specifically: the electronic device removes the content of the first memory page from the non-removable linked list of the memory storage.
  • an electronic device including: a processor, a memory, and a touch screen, the memory, the touch screen are coupled to the processor, and the memory is used to store computer program code, the computer program code including a computer Instruction, when the processor reads the computer instruction from the memory, so that the electronic device executes the method described in the foregoing aspects and any one of the possible implementation manners.
  • a device in a third aspect, is provided, the device is included in an electronic device, and the device has the function of realizing the behavior of the electronic device in any of the foregoing aspects and possible implementation manners.
  • This function can be realized by hardware, or by hardware executing corresponding software.
  • the hardware or software includes at least one module or unit corresponding to the above-mentioned functions. For example, detecting modules or units, determining modules or units, and locking modules or units, and so on.
  • a computer-readable storage medium including computer instructions, which when the computer instructions run on a terminal, cause the terminal to execute the method described in the above aspects and any one of the possible implementation manners.
  • a computer program product which when the computer program product runs on a computer, enables the computer to execute the method described in the above aspects and any one of the possible implementation manners.
  • a chip system is provided, the chip system is applied to the electronic device in the above aspects and any one of the possible implementations; the chip system includes one or more interface circuits and one or more The processor; the interface circuit and the processor are interconnected by wires; the processor receives and executes computer instructions from the memory of the electronic device through the interface circuit.
  • FIG. 1 is a schematic diagram of an application program reading process provided by an embodiment of the application
  • FIG. 2 is a comparison diagram of application startup time when page missing and no page missing according to an embodiment of the application
  • FIG. 3 is a schematic structural diagram of an electronic device provided by an embodiment of the application.
  • FIG. 4 is a schematic structural diagram of another electronic device provided by an embodiment of the application.
  • FIG. 5 is a schematic flowchart of a method for accelerating application startup according to an embodiment of the application
  • FIG. 6 is a schematic process diagram of another method for accelerating application startup according to an embodiment of the application.
  • FIG. 7 is a schematic process diagram of yet another method for accelerating application startup according to an embodiment of the application.
  • FIG. 8 is a schematic structural diagram of a chip system provided by an embodiment of the application.
  • A/B means or, for example, A/B can mean A or B; "and/or” in this document is only an association describing the associated object Relationship means that there can be three kinds of relationships.
  • a and/or B can mean that: A alone exists, A and B exist at the same time, and B exists alone.
  • first and second are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with “first” and “second” may explicitly or implicitly include one or more of these features.
  • plural means two or more.
  • words such as “exemplary” or “for example” are used as examples, illustrations, or illustrations. Any embodiment or design solution described as “exemplary” or “for example” in the embodiments of the present application should not be construed as being more preferable or advantageous than other embodiments or design solutions.
  • words such as “exemplary” or “for example” are used to present related concepts in a specific manner.
  • Memory also known as internal memory, physical memory (physical memory), main memory, etc., refers to the memory space obtained through physical memory sticks.
  • the main function is to provide temporary storage instructions and instructions for electronic devices to run operating systems and various applications. data.
  • the address in the memory is the physical address (physical address).
  • Virtual memory is a technology of memory management in an electronic device operating system, and an abstraction of memory provided by the operating system. The realization of virtual memory is completed by the combination of operating system software and hardware. Virtual memory is not limited to the size of physical memory, providing a larger private address space for applications. In other words, each application process allocates its own virtual memory space independently. From the perspective of the application process, the application process has a continuous available virtual memory space (a continuous and complete address space). In fact, this segment of virtual memory space is usually mapped to a discontinuous address space in physical memory, and part of it is mapped to an address space in external memory.
  • the addresses in virtual memory are virtual addresses, or logical addresses. The electronic device can look up the corresponding physical address according to the virtual address, so as to read data from the physical memory and write the data into the physical memory.
  • External storage also known as external storage, etc.
  • external storage refers to storage other than memory and CPU cache. Such storage can generally retain data after power failure.
  • Common external storages include SD cards, flash storage, hard disks, CDs, U disks, and so on.
  • the electronic device is specifically used to organize, manage, and store data on the external memory through the file system.
  • the file system also searches for the physical address in the corresponding external memory according to the virtual address, so as to read data from the external memory to the memory, and write data from the memory to the external memory.
  • an application on an electronic device When an application on an electronic device is started, it will create its own process.
  • the application process specifically allocates virtual memory space, and the operating system allocates physical memory space for the virtual memory space of the application program, that is, maps the virtual memory space allocated by the application process to the physical memory space. If the application process runs for a long time and does not actively release the physical memory space, or when a large number of application processes apply for physical memory space, the operating system will follow a certain algorithm (for example, the least recently used (LRU) algorithm) ) Reclaim physical memory space that has not been used recently. It is precisely because of the existence of the recycling mechanism that the data requested when the application is subsequently started may not be in the memory, and page misses (miss) occur, also known as page faults.
  • LRU least recently used
  • the virtual address is divided into multiple pages (pages) according to a fixed length in the virtual memory, also called memory pages, usually 4KB.
  • the physical memory is divided into multiple page frames (page frames) according to a fixed length.
  • the operating system maps pages in virtual memory to page frames in physical memory. It can be seen that the operating system manages memory at the granularity of pages.
  • the application when the application is running, it will read data from the memory or external storage, or write data to the internal memory or external storage.
  • the reading and writing process of the application directly affects the running speed of the application. Among them, the read process has a greater impact on the running speed of the application, because the application needs to wait for the returned data when executing the read process.
  • FIG. 1 it is a schematic diagram of the reading process when the application is started.
  • the application When the application is started, it sends multiple page read requests to the virtual file system (VFS) at the kernel layer.
  • the virtual file system confirms whether the requested page is cached in the page cache in memory. If the cache is in the page cache, the data of the requested page is directly read from the page cache. If it is not cached in the page cache, that is, a page is missing, a read request is sent to the file system (file system) for the page where the page is missing (referred to as the missing page for short).
  • file system file system
  • the file system requests the missing page data from the external memory through the block device and the input/output caller. It can be seen that it takes a long time for the application to process the page missing, which will cause a large delay in the running of the application.
  • the time required for the application to display the main interface (also referred to as the first screen time) is the most intuitive indicator for the user to experience the running speed of the application. Therefore, speeding up application startup speed and compressing the first screen time have become important factors for improving the performance of electronic devices and improving user experience.
  • FIG. 2 it is a comparison diagram of the startup time of multiple applications when a page missing occurs and the startup time without a page missing. It can be seen that the time taken by the operating system to deal with page missing accounts for a large part of the application startup time. Therefore, the embodiment of the present application provides a method for accelerating the startup of an application program, which can lock the pages that are more than a threshold and are prone to page missing in the memory, thereby reducing the occurrence of page missing and improving the operation of the application program. speed.
  • the electronic device in this application may be a mobile phone, a tablet computer, a personal computer (PC), a personal digital assistant (personal digital assistant, PDA), a smart watch, a netbook, a wearable electronic device, and augmented reality technology (Augmented reality, AR) equipment, virtual reality (VR) equipment, in-vehicle equipment, smart cars, smart audio, robots, etc.
  • augmented reality technology Augmented reality, AR
  • VR virtual reality
  • in-vehicle equipment smart cars
  • smart audio, robots etc.
  • FIG. 3 shows a schematic diagram of the structure of the electronic device 100.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2.
  • Mobile communication module 150 wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195, etc.
  • SIM Subscriber identification module
  • 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, and ambient light Sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100.
  • the electronic device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc.
  • AP application processor
  • modem processor modem processor
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • the different processing units may be independent devices or integrated in one or more processors.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, and a universal asynchronous transmitter/receiver (universal asynchronous) interface.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transmitter/receiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB Universal Serial Bus
  • the I2C interface is a bidirectional synchronous serial bus, which includes a serial data line (SDA) and a serial clock line (SCL).
  • the processor 110 may include multiple sets of I2C buses.
  • the processor 110 may couple the touch sensor 180K, charger, flash, camera 193, etc., respectively through different I2C bus interfaces.
  • the processor 110 may couple the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through an I2C bus interface to implement the touch function of the electronic device 100.
  • the I2S interface can be used for audio communication.
  • the processor 110 may include multiple sets of I2S buses.
  • the processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170.
  • the audio module 170 may transmit audio signals to the wireless communication module 160 through an I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communication to sample, quantize and encode analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 may also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus can be a two-way communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • the UART interface is generally used to connect the processor 110 and the wireless communication module 160.
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to realize the Bluetooth function.
  • the audio module 170 may transmit audio signals to the wireless communication module 160 through a UART interface, so as to realize the function of playing music through a Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with the display screen 194, the camera 193 and other peripheral devices.
  • the MIPI interface includes a camera serial interface (camera serial interface, CSI), a display serial interface (display serial interface, DSI), and so on.
  • the processor 110 and the camera 193 communicate through a CSI interface to implement the shooting function of the electronic device 100.
  • the processor 110 and the display screen 194 communicate through a DSI interface to realize the display function of the electronic device 100.
  • the GPIO interface can be configured through software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and so on.
  • the GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that complies with the USB standard specification, and specifically may be a Mini USB interface, a Micro USB interface, a USB Type C interface, and so on.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect earphones and play audio through earphones. This interface can also be used to connect to other electronic devices, such as AR devices.
  • the interface connection relationship between the modules illustrated in the embodiment of the present invention is merely a schematic description, and does not constitute a structural limitation of the electronic device 100.
  • the electronic device 100 may also adopt different interface connection modes in the foregoing embodiments, or a combination of multiple interface connection modes.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger can be a wireless charger or a wired charger.
  • the charging management module 140 may receive the charging input of the wired charger through the USB interface 130.
  • the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device 100. While the charging management module 140 charges the battery 142, it can also supply power to the electronic device through the power management module 141.
  • the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110.
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110.
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor.
  • the antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.
  • the antenna can be used in combination with a tuning switch.
  • the mobile communication module 150 can provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the electronic device 100.
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • the mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering, amplifying and transmitting the received electromagnetic waves to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic wave radiation via the antenna 1.
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110.
  • at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor.
  • the application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194.
  • the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites. System (global navigation satellite system, GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110.
  • the wireless communication module 160 may also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic waves to radiate through the antenna 2.
  • the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite-based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite-based augmentation systems
  • the electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is an image processing microprocessor, which is connected to the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
  • the display screen 194 is used to display images, videos, and the like.
  • the display screen 194 includes a display panel.
  • the display panel can use liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
  • LCD liquid crystal display
  • OLED organic light-emitting diode
  • active-matrix organic light-emitting diode active-matrix organic light-emitting diode
  • AMOLED flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc.
  • the electronic device 100 may include one or N display screens 194, and N is a positive integer greater than one.
  • the electronic device 100 can realize a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
  • the ISP is used to process the data fed back by the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and is converted into an image visible to the naked eye.
  • ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera 193.
  • the camera 193 is used to capture still images or videos.
  • the object generates an optical image through the lens and is projected to the photosensitive element.
  • the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transfers the electrical signal to the ISP to convert it into a digital image signal.
  • ISP outputs digital image signals to DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the electronic device 100 may include one or N cameras 193, and N is a positive integer greater than one.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, and so on.
  • MPEG moving picture experts group
  • MPEG2 MPEG2, MPEG3, MPEG4, and so on.
  • NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, and so on.
  • the external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video and other files in an external memory card.
  • the internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area can store an operating system, at least one application program (such as a sound playback function, an image playback function, etc.) required by at least one function.
  • the data storage area can store data (such as audio data, phone book, etc.) created during the use of the electronic device 100.
  • the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
  • the electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. For example, music playback, recording, etc.
  • the audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal.
  • the audio module 170 can also be used to encode and decode audio signals.
  • the audio module 170 may be provided in the processor 110, or part of the functional modules of the audio module 170 may be provided in the processor 110.
  • the speaker 170A also called “speaker” is used to convert audio electrical signals into sound signals.
  • the electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
  • the receiver 170B also called “earpiece” is used to convert audio electrical signals into sound signals.
  • the electronic device 100 answers a call or voice message, it can receive the voice by bringing the receiver 170B close to the human ear.
  • the microphone 170C also called “microphone”, “microphone”, is used to convert sound signals into electrical signals.
  • the user can make a sound by approaching the microphone 170C through the human mouth, and input the sound signal into the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement noise reduction functions in addition to collecting sound signals. In other embodiments, the electronic device 100 may also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and realize directional recording functions.
  • the earphone interface 170D is used to connect wired earphones.
  • the earphone interface 170D may be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, and a cellular telecommunications industry association (cellular telecommunications industry association of the USA, CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA, CTIA
  • the pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal.
  • the pressure sensor 180A may be provided on the display screen 194.
  • the capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes.
  • the electronic device 100 determines the intensity of the pressure according to the change in capacitance.
  • the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A.
  • the electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A.
  • touch operations that act on the same touch position but have different touch operation strengths can correspond to different operation instructions. For example, when a touch operation whose intensity of the touch operation is less than the first pressure threshold is applied to the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
  • the gyro sensor 180B may be used to determine the movement posture of the electronic device 100.
  • the angular velocity of the electronic device 100 around three axes ie, x, y, and z axes
  • the gyro sensor 180B can be used for image stabilization.
  • the gyro sensor 180B detects the shake angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to counteract the shake of the electronic device 100 through reverse movement to achieve anti-shake.
  • the gyro sensor 180B can also be used for navigation and somatosensory game scenes.
  • the air pressure sensor 180C is used to measure air pressure.
  • the electronic device 100 calculates the altitude based on the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
  • the magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 may use the magnetic sensor 180D to detect the opening and closing of the flip holster.
  • the electronic device 100 can detect the opening and closing of the flip according to the magnetic sensor 180D.
  • features such as automatic unlocking of the flip cover are set.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of electronic devices, and be used in applications such as horizontal and vertical screen switching, pedometers and so on.
  • the electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 may use the distance sensor 180F to measure the distance to achieve fast focusing.
  • the proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector such as a photodiode.
  • the light emitting diode may be an infrared light emitting diode.
  • the electronic device 100 emits infrared light to the outside through the light emitting diode.
  • the electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100.
  • the electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power.
  • the proximity light sensor 180G can also be used in leather case mode, and the pocket mode will automatically unlock and lock the screen.
  • the ambient light sensor 180L is used to sense the brightness of the ambient light.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived brightness of the ambient light.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket to prevent accidental touch.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photographs, fingerprint answering calls, and so on.
  • the temperature sensor 180J is used to detect temperature.
  • the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J, so as to reduce power consumption and implement thermal protection.
  • the electronic device 100 when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature.
  • the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
  • Touch sensor 180K also called “touch device”.
  • the touch sensor 180K may be disposed on the display screen 194, and the touch screen is composed of the touch sensor 180K and the display screen 194, which is also called a “touch screen”.
  • the touch sensor 180K is used to detect touch operations acting on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • the visual output related to the touch operation can be provided through the display screen 194.
  • the touch sensor 180K may also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.
  • the bone conduction sensor 180M can acquire vibration signals.
  • the bone conduction sensor 180M can obtain the vibration signal of the vibrating bone mass of the human voice.
  • the bone conduction sensor 180M can also contact the human pulse and receive the blood pressure pulse signal.
  • the bone conduction sensor 180M may also be provided in the earphone, combined with the bone conduction earphone.
  • the audio module 170 can parse the voice signal based on the vibration signal of the vibrating bone block of the voice obtained by the bone conduction sensor 180M, and realize the voice function.
  • the application processor can analyze the heart rate information based on the blood pressure beating signal obtained by the bone conduction sensor 180M, and realize the heart rate detection function.
  • the button 190 includes a power-on button, a volume button, and so on.
  • the button 190 may be a mechanical button. It can also be a touch button.
  • the electronic device 100 may receive key input, and generate key signal input related to user settings and function control of the electronic device 100.
  • the motor 191 can generate vibration prompts.
  • the motor 191 can be used for incoming call vibration notification, and can also be used for touch vibration feedback.
  • touch operations that act on different applications can correspond to different vibration feedback effects.
  • Acting on touch operations in different areas of the display screen 194, the motor 191 can also correspond to different vibration feedback effects.
  • Different application scenarios for example: time reminding, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 may be an indicator light, which may be used to indicate the charging status, power change, or to indicate messages, missed calls, notifications, and so on.
  • the SIM card interface 195 is used to connect to the SIM card.
  • the SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the electronic device 100.
  • the electronic device 100 may support 1 or N SIM card interfaces, and N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.
  • the same SIM card interface 195 can insert multiple cards at the same time. The types of the multiple cards can be the same or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 may also be compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
  • the electronic device 100 adopts an eSIM, that is, an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiment of the present invention takes an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 by way of example.
  • FIG. 4 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface.
  • the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
  • the application layer can include a series of application packages.
  • the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, and a notification manager.
  • the window manager is used to manage window programs.
  • the window manager can obtain the size of the display, determine whether there is a status bar, lock the screen, take a screenshot, etc.
  • the content provider is used to store and retrieve data and make these data accessible to applications.
  • the data may include videos, images, audios, phone calls made and received, browsing history and bookmarks, phone book, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, and so on.
  • the view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface that includes a short message notification icon may include a view that displays text and a view that displays pictures.
  • the phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call status (including connecting, hanging up, etc.).
  • the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
  • the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and it can disappear automatically after a short stay without user interaction.
  • the notification manager is used to notify download completion, message reminders, and so on.
  • the notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or a scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, text messages are prompted in the status bar, prompt sounds, electronic devices vibrate, and indicator lights flash.
  • Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
  • the application layer and the application framework layer run in a virtual machine.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
  • the system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
  • the 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
  • the kernel layer also includes a virtual VFS, a page cache, a memory management module, and a file system.
  • VFS is the external interface of the Linux file system, that is to say, upper-level applications access data in internal storage and external storage through the framework layer and VFS.
  • Page cache is an important disk cache of the Linux kernel, used to cache the contents of memory pages. For example, when the kernel reads data, it first searches the page cache to see if the read data already exists. If it does not exist, add a new memory page to the page cache, and then fill the new memory page with data read from the external memory.
  • the memory management module is used to allocate and manage the memory resources of the electronic device 100.
  • the file system can also be referred to as a file management system, which is used to organize and allocate the space of file storage devices (for example, external memory), is responsible for file storage, and protects and retrieves stored files.
  • the mobile terminal 100 may support multiple types of file systems, for example: fourth-generation extended file system (ext4), flash friendly file system (F2FS), etc.
  • the target page is the memory page that the mobile phone needs to lock in the memory. That is, when the mobile phone is powered on, the target page can always be cached in the memory, and specifically can be stored in the page cache as shown in FIG. 4. In other words, when the mobile phone's operating system reclaims memory space, the target page will not be reclaimed.
  • the target page is the page where the application is prone to page missing. In this way, when the target page is locked in the memory and the application program is running, page missing due to the target page can be avoided, and the running speed of the application program can be improved. In some examples, it is possible to select pages that are prone to page missing among the pages that are called when the application is started, which can increase the application startup speed, reduce the first screen time, and improve the user experience.
  • the solution of this application is to lock the target page in memory, that is, the location of the target page (offset in the target file) and content (specific data of the memory page) are unchanged, so when determining the target page, You need to find a page whose location and content in the application are unchanged as the target page.
  • the target file may be determined from the files called by the application, and then the target page may be determined from the target file.
  • the target file is a file whose location and content are unchanged called by the application program, and the number of target files is one or more.
  • a file that meets the following conditions 1 and 2 can be selected as the target file, as follows:
  • the file size can be used to judge. If the file size does not change during the running process, the file has a high probability of being a read-only file.
  • the judgment can also be made by obtaining the read and write information of the file, and the read and write information clearly indicates that the file is a read-only file or a readable and writable file.
  • the file read and write information can be obtained from the VFS.
  • other methods can also be used to determine whether the file is a read-only file, which is not limited in the embodiment of the application.
  • the target file can satisfy condition 3 in addition to condition 1 and condition 2.
  • the first preset number for example, 15
  • other methods can also be used to determine frequently accessed files.
  • the target file After the target file is determined, it is determined from the target file that the page where the page is missing when the application is started is the target page.
  • the application program is run multiple times (for example, 2 times or more) under the same conditions, and a page in the target file that is missing almost every time is found, and the page is determined as the target page.
  • the target page may be one or more pages in a target file.
  • the information of the target file and the information of the target page can be obtained according to the request of the application program to access the above-mentioned target file.
  • the information of the target file may include: file name (file name), file index number (inode number), file size (file size), request size (request size), request offset (request offset), cache hit (hit ) Or miss, etc.
  • the information of the target page may include: file index number, file size, request size, request offset, etc.
  • an application startup scenario is taken as an example to illustrate the process of determining the target file and the target page.
  • the target page of each application can be determined for different applications.
  • the determination of the target page in the first application is taken as an example, and the method of determining the target page is introduced.
  • the first application can be selected from the applications commonly used by the user.
  • the first application can be, for example, a social application, an entertainment application, such as a video playback application, or a tool application, such as a map.
  • the embodiment of the present application does not limit the first application program.
  • the test machine may be a mobile phone, or a server or computer that can simulate the operation of the first application on the mobile phone. That is to say, the functional modules on the test machine are the same or similar to the mobile phone, for example, have the same functional modules as shown in Figure 1. In addition, the flow of the first application running on the test machine is the same as the flow of running on the mobile phone.
  • test machine When the test machine starts the first application program, it obtains the information of the files accessed by the first application program, so as to subsequently determine the target file from the files accessed by the first application program, and then determine the target page from the target file.
  • the information about the file accessed by the first application in the reading process is printed in the virtual file system of the test machine.
  • the information of the first application to access the file includes: file name (file name), file index number (inode number), request size (request size), request offset (request offset), cache hit (hit) or miss ( miss) one or more of the others. It is understandable that when the application layer accesses the memory file, it passes through the virtual file system. Therefore, the virtual file system can obtain information about all the files accessed by the first application program.
  • the function dentry_path_raw() can be called in the virtual file system to obtain the file name (file name) of the file accessed by the first application.
  • the information about whether the first application accesses the file or not can be cached from the code of the memory management module, for example, do_generic_file_read() in /mm/filemap.c.
  • a read-only file can be determined from the files accessed when the first application is started according to the obtained read and write information of the accessed file, that is, the file that meets the condition 1 can be determined.
  • the missing pages may be different. It is also possible to collect information about files accessed when the first application is started under different conditions. Then, compare the information of the files accessed at startup under different conditions, and determine that the file that has a common page missing is a file that has nothing to do with user data, that is, a file that meets condition 2 is determined.
  • the format used by the first application to access the file is ⁇ file index number (inode number), request size (request size), request offset (request offset), cache hit (hit) or miss (miss) ⁇ .
  • the above takes the first application program as an example to explain the process of determining the target file and the target page in the first application program.
  • a mobile phone usually contains multiple applications, and the process of determining the target file and target page in other applications is similar, and will not be repeated here.
  • the information shown in Table 1 can be written into the kernel layer of the mobile phone in the form of a configuration file, so that the mobile phone locks the target page of each application according to the configuration file.
  • the target file and target page information can be written into the sysfs or proc file of the kernel layer.
  • the target file and the configuration file of the target page may be one or more.
  • a configuration file can include target files and target pages corresponding to one or more applications.
  • a mobile phone contains a configuration file that contains target files and target pages of multiple applications.
  • the configuration file is usually maintained by the mobile phone manufacturer or mobile phone operating system manufacturer. Therefore, when the operating system of the mobile phone is upgraded, the target pages of multiple applications that need to be locked and unlocked can be adjusted directly according to the updated configuration file.
  • the mobile phone contains multiple configuration files, and each configuration file includes a target file and a target page of an application.
  • the configuration file corresponding to each application can be maintained by the application manufacturer. In this way, when a mobile phone installs and updates an application, the mobile phone can adjust the target page that the application needs to lock and unlock according to the updated configuration file of the application.
  • the above process of determining the target file and target page can be carried out in a laboratory, that is to say, it can be determined through experiments in advance that the application program that the user frequently uses is prone to page missing and The page whose position and content are fixed is the target page. Later, write these target files and target page information into the configuration file of the mobile phone. That is, the configuration file stored after the mobile phone leaves the factory contains the target files and target page information of multiple applications. For example: the configuration file contains the file name of the target file, etc.
  • the target page information contained in the configuration file includes the size and offset of the target page. Later, when the mobile phone installs and starts the application, the target page can be locked according to the configuration file.
  • the mobile phone after leaving the factory may not store the configuration file in advance, but after the user selects the function of optimizing the startup speed of the application, the configuration file may be obtained from the server.
  • the mobile phone may request the server to send the configuration file, or the server may periodically push the latest configuration file to the mobile phone, which is not limited in this embodiment of the application.
  • the mobile phone starts the first application.
  • step S501 and step S503 the mobile phone starts the first application when receiving an instruction from the user to start the first application, or the mobile phone automatically starts the first application when a preset condition is met.
  • the process from the mobile phone receiving the user's instruction to start the first application program, or the mobile phone determining to start the first application program when the preset conditions are met, to the complete display of the main interface of the first application program on the mobile phone can be considered It is the startup process of the first application. For example, if the mobile phone detects that the user clicks the first application icon on the desktop, the click operation will trigger the mobile phone to call startActivity(Intent), and finally call the ActivityManagerService. ActivityManagerService creates a new process by calling the startProcessLocked() method. Then the mobile phone binds the created new process with the specified Application (ie, the first application). Later, the activity of the new process is started from the existing process, and the data of the first application is read.
  • the specified Application ie, the first application
  • the process of reading data in the memory is specifically: sending a read request for the page required to start the first application to the virtual file system of the kernel layer through the application framework layer .
  • the virtual file system determines whether each requested page is cached in the memory, that is, whether each requested page cache is cached. If it is determined that a certain page cache hits, the page is read from the page cache in the memory. If it is determined that a certain page cache misses (hit), a page miss occurs.
  • the virtual file system sends a read request to the file system for the page that is missed in the cache, requesting to read the page from the external memory.
  • the page with a cache miss is the missing page. In other words, the content of the missing page is cached in memory.
  • the mobile phone memory caches the contents of all pages required for starting the first application program, which is convenient for the mobile phone to start the first application program and display the main interface of the first application program.
  • the mobile phone After the mobile phone reads the content of the missing page from the external memory into the internal memory, the mobile phone determines whether the file where the missing page is located is the target file.
  • S505 If the file where the missing page is located is the target file, determine whether the missing page is the target page. If it is determined that the file where the missing page is located is not the target file, the process ends.
  • step S504 and step S505 when it is determined that the missing page cache misses, the information of the file where the missing page is located is obtained from the read request for the missing page, such as the file index number (inode number).
  • the configuration file of the mobile phone can include the file name of the target file in the first application. Therefore, the mobile phone can convert the file name of the target file in the configuration file into the corresponding file index number in advance. In this way, when the file index number of the missing page is obtained, it can be compared according to the file index number of the missing page and the file index number of the converted target file to determine whether the file where the missing page is located is the target file.
  • the missing page is the target page in the target file.
  • Obtain the information of the missing page according to the read request of the missing page for example: request size (request size), request offset (request offset).
  • request size request size
  • request offset request offset
  • the configuration file of the mobile phone contains information about the target page, such as the size and offset. Then, you can determine whether the missing page is the target page in the configuration file by searching the configuration file of the mobile phone.
  • step S504 and step S505 can be replaced by the mobile phone determining whether the missing page is the target page, and then step S506 is executed.
  • the information of the target page can be considered to include the file name of the file where the target page is located, the size of the target page, and the offset of the target page. Then, the mobile phone directly compares the information of the missing page with the information of the target page to determine whether the missing page is the target page.
  • the mobile phone needs to read the configuration file in advance before step S504 to obtain the information of the target file of the first application. For example, after the mobile phone is turned on, or after the operating system is upgraded, or after receiving the instruction to start the first application, or when the first application is installed, or after the first application is updated, it can read the configuration file and obtain the first application.
  • a target file and target page information in an application The embodiment of this application does not limit the time when the mobile phone reads the configuration file.
  • the non-removable LRU linked list (hereinafter referred to as the non-removable linked list) is a data structure that can store the contents of a memory page. Mounting the content of the missing page to the non-removable linked list in memory is equivalent to adding the content of the missing page to the non-removable linked list.
  • the non-removable linked list In the case of unremovable memory power, the contents of the memory pages in the unremovable linked list will not be recycled. Therefore, the contents of the missing pages will not be recycled. In other words, when the memory is powered on, the content of the missing pages will always be cached in the memory and will not be recycled.
  • key_inode[] is the file index number of the target file
  • key_offset0 is the offset of the target page
  • key_size0 is the size of the target page.
  • the missing pages can be directly read from the memory, which reduces page missing due to the target page, improves the startup speed of the first application, and reduces the first application of the first application. Screen time improves user experience.
  • the target page may change. For example, a new page that meets the conditions of the target page may appear in the first application, or the original target page no longer meets the conditions of the target page. , Or, the content of the target page changes, etc. In this case, you can update the target file and target page of each application in the configuration file.
  • the configuration file can be maintained by a mobile phone manufacturer or a mobile phone operating system manufacturer. Then, when the mobile phone upgrades the operating system, the latest configuration file can be obtained from the server, and the original configuration file can be replaced. Alternatively, the user can also download the latest configuration file from the application market or the Internet to update it. Then, the mobile phone adjusts the locked target page according to the updated configuration file, such as locking a new target page, and unlocking pages that no longer meet the target page conditions, so as to improve effective memory utilization. Among them, unlocking a page that no longer meets the conditions of the target page can remove the content of the page from the non-removable linked list.
  • the configuration file may be maintained by the first application manufacturer (for example, the developer or manager of the application). Then, when the mobile phone installs or updates the first application, the latest configuration file is obtained from the server, and the original configuration file is replaced. Then, the mobile phone adjusts the locked target page according to the updated configuration file, such as locking a new target page, and unlocking pages that no longer meet the target page conditions, so as to improve effective memory utilization. Among them, unlocking a page that no longer meets the conditions of the target page can remove the content of the page from the non-removable linked list.
  • the first application manufacturer for example, the developer or manager of the application.
  • the foregoing embodiment is described by taking as an example the first application program to lock the target page of the cache miss when checking whether the page is cache hit. It is understandable that based on the inventive concept of this application, the target page can also be locked at other times. For example, after the installation of the first application program is completed, the mobile phone can also read the target page from the external memory to the memory according to the configuration file (including the target file information and target page information of the first application program), and lock it. In this way, when the first application is started later, there will be no page missing due to reading the target page.
  • the above process of determining the target file can be performed in a laboratory, and then the determined target file is written into the configuration file of the mobile phone. Later, after the phone leaves the factory, the target page can also be automatically determined based on the target file and the actual running application on the phone. That is to say, the configuration file stored after the mobile phone leaves the factory contains the information of the target file in multiple applications, such as the file name of the target file contained in the configuration file. Later, after the mobile phone installs and starts the application, the target page can be determined according to the configuration file and the actual running situation of the application, and then the target page is locked.
  • the mobile phone installs or updates the first application.
  • the configuration file of the mobile phone before leaving the factory contains the information of the target file of each application, such as the file name of the target file.
  • the first application of the application layer will notify the kernel layer to read the target file through the framework layer.
  • Configuration file convert the file name of the target file in the configuration file to the corresponding file index number, so that the target file can be distinguished according to the file index number in the subsequent.
  • the mobile phone starts the first application multiple times, and every time it is started, it records pages with missing pages in each target file.
  • the mobile phone Every time the mobile phone starts the first application, it will request the kernel layer to read the page displaying the main interface of the first application.
  • the kernel layer will first determine whether the requested page is cached in memory. If the cache is in the memory, it is directly read from the memory and executed. If it is not cached in the memory, a page miss will occur, a read request for the missing page is requested from the file system, and the missing page is read from the external memory.
  • the mobile phone records the information of the page where the page is missing in each target file (for example: the file index number corresponding to the page) , Size, offset), and store the page information where the page is missing in a temporary file.
  • S604 Determine the target page according to the recorded pages in each target file where the page is missing.
  • the data in the startup process is collected at least twice, the data in the temporary file can be compared.
  • the page that will be missing every time it is started is determined as the target page.
  • the method of determining the target page has been described in detail above, so I won’t go into details here. After determining the target page and obtaining the information of the target page, you can delete the temporary file.
  • the mobile phone can automatically determine the target page according to the actual running situation of the first application, so that the determined target page is more targeted and accurate.
  • the target page may also be automatically updated, which is beneficial to improve the startup speed of the first application program.
  • the developer or manager of the application can also update and modify the target file.
  • the target file corresponding to the application program in the configuration file can also be modified at the same time.
  • the modification method can be, for example, the file name of the new target file can be carried in the installation package or upgrade package of the application.
  • the file name of the target file of the application in the original configuration file in the mobile phone can be replaced with the file name of the new target file.
  • the mobile phone may also provide an interface for modifying the configuration file for the user to choose whether to lock the target file of certain applications. For example, if the user can select certain applications that he rarely use or do not want to optimize in these interfaces, the mobile phone can unlock the target page corresponding to the application selected by the user.
  • the mobile phone after the mobile phone detects that the user has uninstalled certain applications, it can automatically unlock the target page corresponding to the uninstalled application to release memory space and improve memory utilization.
  • the target file of each application in the configuration file can also be updated, or the user can also update the target file of each application by downloading the latest configuration file. Further, according to the updated target file, the new target page is locked, and the page that is no longer the target page is unlocked.
  • the foregoing embodiments can be combined in any combination.
  • the embodiment of the present application also provides a chip system.
  • the chip system includes at least one processor 1101 and at least one interface circuit 1102.
  • the processor 1101 and the interface circuit 1102 may be interconnected by wires.
  • the interface circuit 1102 may be used to receive signals from other devices (such as the memory of the electronic device 100).
  • the interface circuit 1102 may be used to send signals to other devices (such as the processor 1101).
  • the interface circuit 1102 can read an instruction stored in the memory, and send the instruction to the processor 1101.
  • the electronic device can be made to execute the steps performed by the mobile phone (for example, the mobile phone) in the above-mentioned embodiment.
  • the chip system may also include other discrete devices, which are not specifically limited in the embodiment of the present application.
  • An embodiment of the present application also provides a device included in an electronic device, and the device has a function of realizing the behavior of the electronic device in any of the methods in the foregoing embodiments.
  • This function can be realized by hardware, or by hardware executing corresponding software.
  • the hardware or software includes at least one module or unit corresponding to the above-mentioned functions. For example, a detection module or unit, a cache module or unit, a determination module or unit, and a locking module or unit, etc.
  • An embodiment of the present application also provides a computer-readable storage medium, including computer instructions, which when the computer instructions run on an electronic device, cause the electronic device to perform any method as in the foregoing embodiments.
  • the embodiments of the present application also provide a computer program product, which when the computer program product runs on a computer, causes the computer to execute any method as in the above-mentioned embodiments.
  • the above-mentioned terminal and the like include hardware structures and/or software modules corresponding to each function.
  • the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered as going beyond the scope of the embodiments of the present invention.
  • the embodiment of the present application may divide the above-mentioned terminal and the like into functional modules according to the above-mentioned method examples.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or software function modules. It should be noted that the division of modules in the embodiment of the present invention is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • the functional units in the various embodiments of the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solutions of the embodiments of the present application are essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of software products, and the computer software products are stored in a storage
  • the medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephone Function (AREA)
  • Stored Programmes (AREA)

Abstract

Disclosed are a method for accelerating the starting of an application, and an electronic device, wherein same relate to the technical field of communications, and can reduce a cold start delay of an application and improve the user experience. The method is applied to an electronic device, the electronic device includes a configuration file, and the configuration file includes information of a target page. The method comprises: after an instruction for starting a first application is detected, an electronic device starting the first application, requesting access to an internal memory page required for the starting process of the first application, and reading the content of a first internal memory page from an external memory and caching same in an internal memory if the first internal memory page required for the starting process of the first application is not cached in the internal memory; and the electronic device determining, according to information of a target page in a configuration file, whether the first internal memory page is the target page, and locking the content of the first internal memory page in the internal memory if the first internal memory page is the target page.

Description

一种加速应用程序启动的方法及电子设备Method and electronic equipment for accelerating application start
本申请要求于2019年11月1日提交国家知识产权局、申请号为201911061362.0、申请名称为“一种加速应用程序启动的方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the State Intellectual Property Office on November 1, 2019, the application number is 201911061362.0, and the application name is "a method and electronic device for accelerating application startup", the entire content of which is by reference Incorporated in this application.
技术领域Technical field
本申请涉及电子设备领域,尤其涉及一种加速应用程序启动的方法及电子设备。This application relates to the field of electronic equipment, and in particular to a method and electronic equipment for accelerating application startup.
背景技术Background technique
手机上安装的应用程序(application,APP)启动时分为热启动和冷启动。其中,热启动是指APP从后台切换到前台。此时,一般手机的内存中还缓存着APP的数据,能够快速启动。冷启动是指APP在手机重启后的第一次启动,或者在APP被杀死(kill)后的第一次启动。此时,APP的全部或部分数据不在内存中,APP需要从外存中读取数据,故启动延迟较大,用户体验不佳。The application (application, APP) installed on the mobile phone is divided into hot start and cold start when it is started. Among them, the hot start means that the APP switches from the background to the foreground. At this time, APP data is still cached in the memory of general mobile phones, which can be quickly started. Cold start refers to the first start of the APP after the phone restarts, or the first start after the APP is killed (kill). At this time, all or part of the data of the APP is not in the memory, and the APP needs to read the data from the external memory, so the startup delay is large and the user experience is poor.
发明内容Summary of the invention
本申请提供的一种加速应用程序启动的方法及电子设备,可以减少应用程序冷启动延迟,提升用户体验。The method and electronic device for accelerating the startup of an application provided by the present application can reduce the delay of the cold startup of the application and improve the user experience.
为了实现上述目的,本申请实施例提供了以下技术方案:In order to achieve the foregoing objectives, the embodiments of the present application provide the following technical solutions:
第一方面、本申请提供的一种方法,应用于电子设备,电子设备包含有配置文件,配置文件包括目标页面的信息,该方法包括:响应于检测到启动第一应用程序的指令,电子设备启动第一应用程序;电子设备请求访问第一应用程序启动过程所需的内存页;若第一应用程序启动过程所需的内存页中的第一内存页未缓存在内部存储器中,则电子设备从外部存储器中读取第一内存页的内容,并缓存到内部存储器中;在电子设备将第一内存页从外部存储器中缓存到内部存储器中之后,电子设备根据配置文件中目标页面的信息确定第一内存页是否为目标页面;在确定第一内存页为目标页面之后,电子设备将第一内存页锁定在内部存储器中。In the first aspect, a method provided in this application is applied to an electronic device. The electronic device contains a configuration file, and the configuration file includes information about a target page. The method includes: in response to detecting an instruction to start a first application, the electronic device Start the first application; the electronic device requests to access the memory page required by the startup process of the first application; if the first memory page among the memory pages required for the startup process of the first application is not cached in the internal memory, the electronic device Read the content of the first memory page from the external memory and cache it in the internal memory; after the electronic device caches the first memory page from the external memory to the internal memory, the electronic device determines according to the information of the target page in the configuration file Whether the first memory page is the target page; after determining that the first memory page is the target page, the electronic device locks the first memory page in the internal memory.
由此可见,将手机启动第一应用程序的过程所需要读取的页面中,易发生页缺失的特定页面(即目标页面)锁定在手机的内存中。后续,当手机再次启动第一应用程序时,可以直接从内存中读取到相应的页面,避免这些页面再发生页缺失,进而加快了应用程序的启动速度。It can be seen that, among the pages that need to be read in the process of starting the first application by the mobile phone, a specific page that is prone to page missing (ie, the target page) is locked in the memory of the mobile phone. Later, when the mobile phone starts the first application again, it can directly read the corresponding pages from the memory, so as to avoid page missing of these pages again, thereby speeding up the startup of the application.
一种可能的实现方式中,该方法还包括:电子设备检测到退出第一应用程序的指令,电子设备退出第一应用程序;电子设备再次检测到启动第一应用程序的指令时,电子设备再次启动第一应用程序;电子设备获取第一应用程序启动过程所需的内存页;电子设备显示第一应用程序的主界面。In a possible implementation manner, the method further includes: the electronic device detects the instruction to exit the first application program, and the electronic device exits the first application program; when the electronic device detects the instruction to start the first application program again, the electronic device again Start the first application program; the electronic device obtains the memory page required by the startup process of the first application program; the electronic device displays the main interface of the first application program.
当后续再次启动第一应用程序时,缺失页面可以直接从内存中读出,减少了因目标页面而发生的页缺失,提升了第一应用程序启动速度,减少了第一应用程序的首屏时间,提升了用户体验。When the first application is started again later, the missing pages can be read directly from the memory, reducing page missing due to the target page, improving the startup speed of the first application, and reducing the first screen time of the first application , Improve the user experience.
一种可能的实现方式中,目标页面为目标文件中的一个或多个页面,且目标页面在第一应用程序启动的过程中曾发生过页缺失;目标文件为第一应用程序启动时访问的一个或多个只读文件,且为第一应用程序在启动时访问时发生页缺失的次数与用户数据无关的一个或多个文件。In a possible implementation, the target page is one or more pages in the target file, and the target page has been missing during the start of the first application; the target file is the one accessed when the first application is started. One or more read-only files, and are one or more files that are not related to user data when the first application program is accessed at startup, and the number of page missing occurrences is not related to the user data.
如果文件是可写(非只读的)的,则意味着文件可能会被修改,那么文件中的各个页面的位置和内容可能发生变化,发生页缺失的页面会不固定,无法预先将页面锁定在内存中。If the file is writable (not read-only), it means that the file may be modified, and the position and content of each page in the file may change, and the page where the page is missing will not be fixed, and the page cannot be locked in advance In memory.
在具体实现时,可以通过文件的尺寸大小进行判断,若文件的尺寸大小在运行过程中未发生改变,则该文件大概率是只读文件。或者,也可以通过获取文件的读写信息进行判断,读写信息明确指示该文件是只读文件或可读写文件。其中,文件的读写信息可从VFS中获取。当然,也可以采用其他方法确定文件是否是只读文件,本申请实施例对此不做限定。In the specific implementation, the file size can be used to judge. If the file size does not change during the running process, the file has a high probability of being a read-only file. Alternatively, the judgment can also be made by obtaining the read and write information of the file, and the read and write information clearly indicates that the file is a read-only file or a readable and writable file. Among them, the file read and write information can be obtained from the VFS. Of course, other methods can also be used to determine whether the file is a read-only file, which is not limited in the embodiment of the present application.
文件发生页缺失的次数与用户有关,例如使用不同账号登录应用程序或手机中存储的用户数据不同时,发生页缺失的页面可能不固定,那么也无法预先将页面锁定在内存中,不便于在手机出厂前做统一的部署。The number of times a file has page missing is related to the user. For example, when using different accounts to log in to the application or the user data stored in the mobile phone is different, the page where the page is missing may not be fixed, and the page cannot be locked in memory in advance, which is inconvenient. The mobile phone is deployed uniformly before leaving the factory.
在具体实现时,在统计之前,分别使用不同的账号登录,或者手机中存储不同的用户数据,然后分别统计应用程序运行时,各个文件发生的页缺失的次数。将各个情况下发生页缺失次数相近的文件确定为与用户无关的文件。In specific implementation, before counting, use different accounts to log in, or store different user data in the mobile phone, and then count the number of page missing occurrences of each file when the application is running. The files with the same number of page deletions in each case are determined as files irrelevant to the user.
一种可能的实现方式中,目标文件为第一应用程序在启动时访问次数大于阈值的一个或多个文件。In a possible implementation manner, the target file is one or more files whose access times are greater than a threshold when the first application is started.
一方面,将频繁访问的文件中容易发生页缺失的页面锁定在内存中,可以避免因该频繁访问文件频繁发生的页缺失,更有利于提升应用程序运行的速度。另一方面,由于手机内存有限,选择将频繁访问的文件中页面锁定在内存中,意味着不频繁访问文件中的页面可不用锁定在内存中,这将有利于提升内存的利用率。On the one hand, locking pages that are prone to page missing in frequently accessed files in the memory can avoid page missing frequently occurring due to frequently accessed files, which is more conducive to improving the running speed of the application. On the other hand, due to the limited memory of mobile phones, choosing to lock pages in frequently accessed files in memory means that pages in infrequently accessed files do not need to be locked in memory, which will help improve memory utilization.
在具体实现时,可以统计应用程序运行时访问文件的次数,将次数大于阈值的文件确定为频繁访问的文件。或者,按照访问文件的次数从多到少的顺序,选择前预设数量个(例如,15个)文件为频繁访问的文件。当然,也可以采用其他方法确定频繁访问的文件。In specific implementation, it is possible to count the number of times the file is accessed while the application is running, and determine the files whose times are greater than the threshold as frequently accessed files. Or, according to the order of the number of times of accessing the files, the first preset number (for example, 15) files are selected as frequently accessed files. Of course, other methods can also be used to determine frequently accessed files.
一种可能的实现方式中,配置文件中目标页面的信息包括目标文件的信息和目标页面的信息;电子设备根据配置文件中目标页面的信息确定第一内存页是否为目标页面,具体为:电子设备根据配置文件中目标文件的信息确定第一内存页所在的文件是否为目标文件;在确定第一内存页所在的文件为目标文件之后,电子设备根据配置文件中目标页面的信息确定第一内存页是否为目标页面。In a possible implementation manner, the information of the target page in the configuration file includes the information of the target file and the information of the target page; the electronic device determines whether the first memory page is the target page according to the information of the target page in the configuration file, specifically: electronic The device determines whether the file where the first memory page is located is the target file according to the information of the target file in the configuration file; after determining that the file where the first memory page is located is the target file, the electronic device determines the first memory according to the information of the target page in the configuration file Whether the page is the target page.
一种可能的实现方式中,配置文件中目标文件的信息包括目标文件的名称。例如,目标文件的信息可以包括:文件名称(file name)、文件索引号(inode number)、文件大小(file size)、请求大小(request size)、请求偏移(request offset)、缓存命中(hit)或未命中(miss)等。In a possible implementation manner, the information of the target file in the configuration file includes the name of the target file. For example, the information of the target file may include: file name (file name), file index number (inode number), file size (file size), request size (request size), request offset (request offset), cache hit (hit ) Or miss, etc.
一种可能的实现方式中,配置文件中目标页面的信息包括目标页面的尺寸大小和偏移。例如,目标页面的信息可以包括:文件索引号、文件大小、请求大小、请求偏 移等。In a possible implementation manner, the target page information in the configuration file includes the size and offset of the target page. For example, the target page information may include: file index number, file size, request size, request offset, etc.
一种可能的实现方式中,该方法还包括:当电子设备更新操作系统或电子设备更新第一应用程序时,电子设备从服务器获取最新的配置文件进行更新。In a possible implementation manner, the method further includes: when the electronic device updates the operating system or the electronic device updates the first application program, the electronic device obtains the latest configuration file from the server to update it.
其中,目标文件和目标页面的配置文件可以是一个或多个。一个配置文件中可以包括一个或多个应用程序对应的目标文件和目标页面。Among them, the target file and the configuration file of the target page may be one or more. A configuration file can include target files and target pages corresponding to one or more applications.
例如:手机内包含一个配置文件,该配置文件中包含多个应用程序的目标文件和目标页面。该配置文件通常是由手机厂商或手机操作系统厂商进行维护。因此,手机在操作系统升级时,可以直接根据更新后的配置文件对多个应用程序需要锁定和解锁的目标页面进行调整。For example: a mobile phone contains a configuration file that contains target files and target pages of multiple applications. The configuration file is usually maintained by the mobile phone manufacturer or mobile phone operating system manufacturer. Therefore, when the operating system of the mobile phone is upgraded, the target pages of multiple applications that need to be locked and unlocked can be adjusted directly according to the updated configuration file.
又例如:手机内包含多个配置文件,每个配置文件包含一个应用程序的目标文件和目标页面。每个应用程序对应的配置文件可以由应用程序厂商进行维护。这样,当手机安装和更新某个应用程序时,手机可以根据该应用程序更新后的配置文件,对该应用程序需要锁定和解锁的目标页面进行调整。Another example: the mobile phone contains multiple configuration files, and each configuration file includes a target file and a target page of an application. The configuration file corresponding to each application can be maintained by the application manufacturer. In this way, when a mobile phone installs and updates an application, the mobile phone can adjust the target page that the application needs to lock and unlock according to the updated configuration file of the application.
一种可能的实现方式中,确定第一内存页所在的文件是否为目标文件,具体为:获取第一内存页的读请求,从第一内存页的读请求中获取第一内存页所在文件的文件索引号,以及根据配置文件中的目标文件的名称获取目标文件的文件索引号;根据第一内存页所在文件的文件索引号和目标文件的文件索引号,确定第一内存页是否为目标文件。In one possible implementation, it is determined whether the file where the first memory page is located is the target file, specifically: obtaining the read request of the first memory page, and obtaining the information of the file where the first memory page is located from the read request of the first memory page File index number, and obtain the file index number of the target file according to the name of the target file in the configuration file; determine whether the first memory page is the target file according to the file index number of the file where the first memory page is located and the file index number of the target file .
一种可能的实现方式中,确定第一内存页是否为目标页面,具体为:从第一内存页的读请求中获取第一内存页的尺寸大小和偏移;根据第一内存页的尺寸大小和偏移,以及目标页面的尺寸大小和偏移,确定第一内存页是否为目标页面。In a possible implementation, determining whether the first memory page is the target page is specifically: obtaining the size and offset of the first memory page from the read request of the first memory page; according to the size of the first memory page And offset, as well as the size and offset of the target page, determine whether the first memory page is the target page.
一种可能的实现方式中,在确定第一内存页为目标页面之后,电子设备将第一内存页锁定在内部存储器中,具体为:在确定第一内存页为目标页面之后,电子设备将第一内存页的内容添加到内部存储器的不可移除链表中。In a possible implementation manner, after determining that the first memory page is the target page, the electronic device locks the first memory page in the internal memory, specifically: after determining the first memory page as the target page, the electronic device locks the first memory page as the target page. The content of a memory page is added to the non-removable linked list of the internal memory.
一种可能的实现方式中,该方法还包括:响应于检测到卸载第一应用程序的指令,电子设备从内部存储器中解锁第一内存页。In a possible implementation manner, the method further includes: in response to detecting the instruction to uninstall the first application program, the electronic device unlocks the first memory page from the internal memory.
一种可能的实现方式中,电子设备从内部存储器中解锁第一内存页,具体为:电子设备从内存存储器的不可移除链表中移除第一内存页的内容。In a possible implementation manner, the electronic device unlocks the first memory page from the internal memory, specifically: the electronic device removes the content of the first memory page from the non-removable linked list of the memory storage.
第二方面、提供一种电子设备,包括:处理器、存储器和触摸屏,所述存储器、所述触摸屏与所述处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,当所述处理器从所述存储器中读取所述计算机指令,以使得所述电子设备执行上述方面中及其中任一种可能的实现方式中所述的方法。In a second aspect, an electronic device is provided, including: a processor, a memory, and a touch screen, the memory, the touch screen are coupled to the processor, and the memory is used to store computer program code, the computer program code including a computer Instruction, when the processor reads the computer instruction from the memory, so that the electronic device executes the method described in the foregoing aspects and any one of the possible implementation manners.
第三方面、提供一种装置,该装置包含在电子设备中,该装置具有实现上述方面及可能的实现方式中任一方法中电子设备行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括至少一个与上述功能相对应的模块或单元。例如,检测模块或单元、确定模块或单元、以及锁定模块或单元等。In a third aspect, a device is provided, the device is included in an electronic device, and the device has the function of realizing the behavior of the electronic device in any of the foregoing aspects and possible implementation manners. This function can be realized by hardware, or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above-mentioned functions. For example, detecting modules or units, determining modules or units, and locking modules or units, and so on.
第四方面、提供一种计算机可读存储介质,包括计算机指令,当计算机指令在终端上运行时,使得终端执行如上述方面及其中任一种可能的实现方式中所述的方法。In a fourth aspect, a computer-readable storage medium is provided, including computer instructions, which when the computer instructions run on a terminal, cause the terminal to execute the method described in the above aspects and any one of the possible implementation manners.
第五方面、提供一种计算机程序产品,当计算机程序产品在计算机上运行时,使 得计算机执行如上述方面中及其中任一种可能的实现方式中所述的方法。In a fifth aspect, a computer program product is provided, which when the computer program product runs on a computer, enables the computer to execute the method described in the above aspects and any one of the possible implementation manners.
第六方面、提供一种芯片系统,所述芯片系统应用于上述方面中及其中任一种可能的实现方式中的电子设备;所述芯片系统包括一个或多个接口电路和一个或多个所述处理器;所述接口电路和所述处理器通过线路互联;所述处理器通过所述接口电路从所述电子设备的存储器接收并执行计算机指令。In a sixth aspect, a chip system is provided, the chip system is applied to the electronic device in the above aspects and any one of the possible implementations; the chip system includes one or more interface circuits and one or more The processor; the interface circuit and the processor are interconnected by wires; the processor receives and executes computer instructions from the memory of the electronic device through the interface circuit.
附图说明Description of the drawings
图1为本申请实施例提供的一种应用程序读流程的示意图;FIG. 1 is a schematic diagram of an application program reading process provided by an embodiment of the application;
图2为本申请实施例提供的一种发生页缺失和未发生页缺失时应用程序启动时间的对比图;FIG. 2 is a comparison diagram of application startup time when page missing and no page missing according to an embodiment of the application;
图3为本申请实施例提供的一种电子设备的结构示意图;FIG. 3 is a schematic structural diagram of an electronic device provided by an embodiment of the application;
图4为本申请实施例提供的又一种电子设备的结构示意图;FIG. 4 is a schematic structural diagram of another electronic device provided by an embodiment of the application;
图5为本申请实施例提供的一种加速应用程序启动的方法的流程示意图;FIG. 5 is a schematic flowchart of a method for accelerating application startup according to an embodiment of the application;
图6为本申请实施例提供的另一种加速应用程序启动的方法的过程示意图;FIG. 6 is a schematic process diagram of another method for accelerating application startup according to an embodiment of the application;
图7为本申请实施例提供的又一种加速应用程序启动的方法的过程示意图;FIG. 7 is a schematic process diagram of yet another method for accelerating application startup according to an embodiment of the application;
图8为本申请实施例提供的一种芯片系统的结构示意图。FIG. 8 is a schematic structural diagram of a chip system provided by an embodiment of the application.
具体实施方式Detailed ways
在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。In the description of the embodiments of the present application, unless otherwise specified, "/" means or, for example, A/B can mean A or B; "and/or" in this document is only an association describing the associated object Relationship means that there can be three kinds of relationships. For example, A and/or B can mean that: A alone exists, A and B exist at the same time, and B exists alone.
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。Hereinafter, the terms “first” and “second” are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first" and "second" may explicitly or implicitly include one or more of these features.
在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more. In the embodiments of the present application, words such as "exemplary" or "for example" are used as examples, illustrations, or illustrations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferable or advantageous than other embodiments or design solutions. To be precise, words such as "exemplary" or "for example" are used to present related concepts in a specific manner.
为了更好理解本申请的技术方案,先对本申请涉及的技术术语进行说明。In order to better understand the technical solutions of this application, the technical terms involved in this application will be explained first.
内存,也称为内部存储器、物理内存(physical memory)、主存等,指通过物理内存条而获得的内存空间,主要作用是为电子设备运行操作系统和各种应用程序时提供临时储存指令和数据。内存中的地址为物理地址(physical address)。Memory, also known as internal memory, physical memory (physical memory), main memory, etc., refers to the memory space obtained through physical memory sticks. The main function is to provide temporary storage instructions and instructions for electronic devices to run operating systems and various applications. data. The address in the memory is the physical address (physical address).
虚拟内存(virtual memory),是电子设备操作系统中内存管理的一种技术,是操作系统提供的一种对内存的抽象。虚拟内存的实现是由操作系统软件和硬件结合完成。虚拟内存可以不受限于物理内存大小的限制,为应用程序的提供了一个更大的私有的地址空间。也就是说,每个应用程序进程独立分配自己的虚拟内存空间。在应用程序进程看来,应用程序进程拥有连续的可用的虚拟内存空间(一段连续完整的地址空间)。而事实上,这段虚拟内存空间通常会被映射到物理内存中不连续的地址空间,还有部分映射到外部存储器中的地址空间。虚拟内存中地址为虚拟地址,或称为逻辑地址 (logical address)。电子设备可以根据该虚拟地址查找对应的物理地址,以便从物理内存中读取数据,以及将数据写入物理内存中。Virtual memory (virtual memory) is a technology of memory management in an electronic device operating system, and an abstraction of memory provided by the operating system. The realization of virtual memory is completed by the combination of operating system software and hardware. Virtual memory is not limited to the size of physical memory, providing a larger private address space for applications. In other words, each application process allocates its own virtual memory space independently. From the perspective of the application process, the application process has a continuous available virtual memory space (a continuous and complete address space). In fact, this segment of virtual memory space is usually mapped to a discontinuous address space in physical memory, and part of it is mapped to an address space in external memory. The addresses in virtual memory are virtual addresses, or logical addresses. The electronic device can look up the corresponding physical address according to the virtual address, so as to read data from the physical memory and write the data into the physical memory.
外部存储器,也称为外存等,是指除内存以及CPU缓存以外的存储器,此类存储器一般断电后仍然能保存数据。常见的外部存储器有SD卡、闪存存储、硬盘、光盘、U盘等。电子设备通过文件系统具体用于在外部存储器上组织、管理和存储数据。文件系统也是根据虚拟地址查找对应的外部存储器中的物理地址,以便从外部存储器中读取数据到内存,以及将数据从内存写入外部存储器的。External storage, also known as external storage, etc., refers to storage other than memory and CPU cache. Such storage can generally retain data after power failure. Common external storages include SD cards, flash storage, hard disks, CDs, U disks, and so on. The electronic device is specifically used to organize, manage, and store data on the external memory through the file system. The file system also searches for the physical address in the corresponding external memory according to the virtual address, so as to read data from the external memory to the memory, and write data from the memory to the external memory.
电子设备上的应用程序在启动时,都会创建自己的进程。应用程序进程具体分配虚拟内存空间,操作系统为应用程序的虚拟内存空间分配物理内存空间,即将应用程序进程分配的虚拟内存空间映射到物理内存空间中。如若应用程序进程长时间运行,也不主动释放物理内存空间,或者有大量的应用程序进程申请物理内存空间时,操作系统会根据一定的算法(如,最近最少使用(least recently used,LRU)算法)回收最近未使用的物理内存空间。正是由于回收机制的存在,会造成应用程序后续启动时请求的数据可能不在内存中,发生页缺失(miss),也称为页错误。When an application on an electronic device is started, it will create its own process. The application process specifically allocates virtual memory space, and the operating system allocates physical memory space for the virtual memory space of the application program, that is, maps the virtual memory space allocated by the application process to the physical memory space. If the application process runs for a long time and does not actively release the physical memory space, or when a large number of application processes apply for physical memory space, the operating system will follow a certain algorithm (for example, the least recently used (LRU) algorithm) ) Reclaim physical memory space that has not been used recently. It is precisely because of the existence of the recycling mechanism that the data requested when the application is subsequently started may not be in the memory, and page misses (miss) occur, also known as page faults.
需要说明的是,在虚拟内存中按照固定长度将虚拟地址划分为多个页面(page),也称为内存页,通常为4KB。同时,物理内存中也按照固定长度将物理地址划分为多页面帧(page frame)。操作系统会将虚拟内存中的页面映射到物理内存中的页面帧。可见,操作系统是以页面为粒度管理内存的。It should be noted that the virtual address is divided into multiple pages (pages) according to a fixed length in the virtual memory, also called memory pages, usually 4KB. At the same time, the physical memory is divided into multiple page frames (page frames) according to a fixed length. The operating system maps pages in virtual memory to page frames in physical memory. It can be seen that the operating system manages memory at the granularity of pages.
可以理解的是,应用程序在运行时,会从内存或外部存储器中读取数据,或向内存或外部存储器中写入数据。应用程序读写流程直接影响着应用程序的运行速度。其中,读流程对应用程序的运行速度影响更大,这是因为,应用程序执行读流程时需要等待返回的数据。It is understandable that when the application is running, it will read data from the memory or external storage, or write data to the internal memory or external storage. The reading and writing process of the application directly affects the running speed of the application. Among them, the read process has a greater impact on the running speed of the application, because the application needs to wait for the returned data when executing the read process.
如图1所示,为应用程序启动时读流程的示意图。应用程序启动时,向内核层的虚拟文件系统(virtual file system,VFS)发送多个页面的读请求。虚拟文件系统确认请求的页面是否缓存在内存中的页缓存中。若缓存在页缓存中,则直接从页缓存中读取请求的页面的数据。若未缓存在页缓存中,即发生页缺失,则针对发生页缺失的页面(简称为缺失页),向文件系统(file system)发送读请求。文件系统通过块设备、输入/输出调用器从外部存储器请求缺失页的数据。可见,应用程序处理页缺失的时间较长,会造成应用程序运行时延较大。As shown in Figure 1, it is a schematic diagram of the reading process when the application is started. When the application is started, it sends multiple page read requests to the virtual file system (VFS) at the kernel layer. The virtual file system confirms whether the requested page is cached in the page cache in memory. If the cache is in the page cache, the data of the requested page is directly read from the page cache. If it is not cached in the page cache, that is, a page is missing, a read request is sent to the file system (file system) for the page where the page is missing (referred to as the missing page for short). The file system requests the missing page data from the external memory through the block device and the input/output caller. It can be seen that it takes a long time for the application to process the page missing, which will cause a large delay in the running of the application.
由于应用程序启动时,应用程序显示主界面所需的时间(也称为首屏时间)是用户体验应用程序运行速度的最直观的指标。故,加快应用程序启动速度,压缩首屏时间成为提升电子设备性能,提升用户体验的重要因素。When the application is started, the time required for the application to display the main interface (also referred to as the first screen time) is the most intuitive indicator for the user to experience the running speed of the application. Therefore, speeding up application startup speed and compressing the first screen time have become important factors for improving the performance of electronic devices and improving user experience.
如图2所示,为多个应用程序在发生页缺失的启动时间和未发生页缺失的启动时间对比图。可以看到,操作系统处理页缺失的时间占应用程序启动时间的很大一部分。因此,本申请实施例提供了一种加速应用程序启动的方法,可以将应用程序请求次数大于阈值且容易发生页缺失的页面锁定在内存中,从而减少发生页缺失的情况,提升应用程序的运行速度。As shown in Figure 2, it is a comparison diagram of the startup time of multiple applications when a page missing occurs and the startup time without a page missing. It can be seen that the time taken by the operating system to deal with page missing accounts for a large part of the application startup time. Therefore, the embodiment of the present application provides a method for accelerating the startup of an application program, which can lock the pages that are more than a threshold and are prone to page missing in the memory, thereby reducing the occurrence of page missing and improving the operation of the application program. speed.
示例性的,本申请中的电子设备可以为手机、平板电脑、个人计算机(personal computer,PC)、个人数字助理(personal digital assistant,PDA)、智能手表、上网 本、可穿戴电子设备、增强现实技术(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、车载设备、智能汽车、智能音响、机器人等,本申请对该电子设备的具体形式不做特殊限制。Exemplarily, the electronic device in this application may be a mobile phone, a tablet computer, a personal computer (PC), a personal digital assistant (personal digital assistant, PDA), a smart watch, a netbook, a wearable electronic device, and augmented reality technology (Augmented reality, AR) equipment, virtual reality (VR) equipment, in-vehicle equipment, smart cars, smart audio, robots, etc. This application does not impose special restrictions on the specific form of the electronic equipment.
图3示出了电子设备100的结构示意图。FIG. 3 shows a schematic diagram of the structure of the electronic device 100.
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2. , Mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (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, and ambient light Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU), etc. Among them, the different processing units may be independent devices or integrated in one or more processors.
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 to store instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, and a universal asynchronous transmitter/receiver (universal asynchronous) interface. receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / Or Universal Serial Bus (USB) interface, etc.
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C总线接口分别耦合触摸传感器180K,充 电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。The I2C interface is a bidirectional synchronous serial bus, which includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple sets of I2C buses. The processor 110 may couple the touch sensor 180K, charger, flash, camera 193, etc., respectively through different I2C bus interfaces. For example, the processor 110 may couple the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through an I2C bus interface to implement the touch function of the electronic device 100.
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple sets of I2S buses. The processor 110 may be coupled with the audio module 170 through an I2S bus to implement communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 may transmit audio signals to the wireless communication module 160 through an I2S interface, so as to realize the function of answering calls through a Bluetooth headset.
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。The PCM interface can also be used for audio communication to sample, quantize and encode analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface. In some embodiments, the audio module 170 may also transmit audio signals to the wireless communication module 160 through the PCM interface, so as to realize the function of answering calls through the Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。The UART interface is a universal serial data bus used for asynchronous communication. The bus can be a two-way communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to realize the Bluetooth function. In some embodiments, the audio module 170 may transmit audio signals to the wireless communication module 160 through a UART interface, so as to realize the function of playing music through a Bluetooth headset.
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。The MIPI interface can be used to connect the processor 110 with the display screen 194, the camera 193 and other peripheral devices. The MIPI interface includes a camera serial interface (camera serial interface, CSI), a display serial interface (display serial interface, DSI), and so on. In some embodiments, the processor 110 and the camera 193 communicate through a CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate through a DSI interface to realize the display function of the electronic device 100.
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。The GPIO interface can be configured through software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, and so on. The GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。The USB interface 130 is an interface that complies with the USB standard specification, and specifically may be a Mini USB interface, a Micro USB interface, a USB Type C interface, and so on. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect earphones and play audio through earphones. This interface can also be used to connect to other electronic devices, such as AR devices.
可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is merely a schematic description, and does not constitute a structural limitation of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection modes in the foregoing embodiments, or a combination of multiple interface connection modes.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The charging management module 140 is used to receive charging input from the charger. Among them, the charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive the charging input of the wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device 100. While the charging management module 140 charges the battery 142, it can also supply power to the electronic device through the power management module 141.
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理 模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 may also be provided in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be provided in the same device.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna can be used in combination with a tuning switch.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 can provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering, amplifying and transmitting the received electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic wave radiation via the antenna 1. In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110. In some embodiments, at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites. System (global navigation satellite system, GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic waves to radiate through the antenna 2.
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division  multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi -zenith satellite system, QZSS) and/or satellite-based augmentation systems (SBAS).
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like. The GPU is an image processing microprocessor, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。The display screen 194 is used to display images, videos, and the like. The display screen 194 includes a display panel. The display panel can use liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode). AMOLED, flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, and N is a positive integer greater than one.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can realize a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。The ISP is used to process the data fed back by the camera 193. For example, when taking a picture, the shutter is opened, the light is transmitted to the photosensitive element of the camera through the lens, the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and is converted into an image visible to the naked eye. ISP can also optimize the image noise, brightness, and skin color. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera 193.
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and is projected to the photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transfers the electrical signal to the ISP to convert it into a digital image signal. ISP outputs digital image signals to DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats of image signals. In some embodiments, the electronic device 100 may include one or N cameras 193, and N is a positive integer greater than one.
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG2, MPEG3, MPEG4, and so on.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音 识别,文本理解等。NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, for example, the transfer mode between human brain neurons, it can quickly process input information, and it can also continuously self-learn. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, and so on.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example, save music, video and other files in an external memory card.
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能应用以及数据处理。The internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions. The internal memory 121 may include a storage program area and a storage data area. Among them, the storage program area can store an operating system, at least one application program (such as a sound playback function, an image playback function, etc.) required by at least one function. The data storage area can store data (such as audio data, phone book, etc.) created during the use of the electronic device 100. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. For example, music playback, recording, etc.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110, or part of the functional modules of the audio module 170 may be provided in the processor 110.
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。The speaker 170A, also called "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music through the speaker 170A, or listen to a hands-free call.
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。The receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or voice message, it can receive the voice by bringing the receiver 170B close to the human ear.
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。The microphone 170C, also called "microphone", "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C through the human mouth, and input the sound signal into the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can implement noise reduction functions in addition to collecting sound signals. In other embodiments, the electronic device 100 may also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and realize directional recording functions.
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。The earphone interface 170D is used to connect wired earphones. The earphone interface 170D may be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, and a cellular telecommunications industry association (cellular telecommunications industry association of the USA, CTIA) standard interface.
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于 相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be provided on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors and so on. The capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 may also calculate the touched position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations that act on the same touch position but have different touch operation strengths can correspond to different operation instructions. For example, when a touch operation whose intensity of the touch operation is less than the first pressure threshold is applied to the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。The gyro sensor 180B may be used to determine the movement posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (ie, x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for image stabilization. Exemplarily, when the shutter is pressed, the gyro sensor 180B detects the shake angle of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and allows the lens to counteract the shake of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.
气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude based on the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。在一些实施例中,当电子设备100是翻盖机时,电子设备100可以根据磁传感器180D检测翻盖的开合。进而根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。The magnetic sensor 180D includes a Hall sensor. The electronic device 100 may use the magnetic sensor 180D to detect the opening and closing of the flip holster. In some embodiments, when the electronic device 100 is a flip machine, the electronic device 100 can detect the opening and closing of the flip according to the magnetic sensor 180D. Furthermore, according to the detected opening and closing state of the holster or the opening and closing state of the flip cover, features such as automatic unlocking of the flip cover are set.
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of electronic devices, and be used in applications such as horizontal and vertical screen switching, pedometers and so on.
距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。Distance sensor 180F, used to measure distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 may use the distance sensor 180F to measure the distance to achieve fast focusing.
接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外光。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。当检测到不充分的反射光时,电子设备100可以确定电子设备100附近没有物体。电子设备100可以利用接近光传感器180G检测用户手持电子设备100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light to the outside through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode, and the pocket mode will automatically unlock and lock the screen.
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。The ambient light sensor 180L is used to sense the brightness of the ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived brightness of the ambient light. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket to prevent accidental touch.
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photographs, fingerprint answering calls, and so on.
温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热, 以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold value, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J, so as to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In some other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。Touch sensor 180K, also called "touch device". The touch sensor 180K may be disposed on the display screen 194, and the touch screen is composed of the touch sensor 180K and the display screen 194, which is also called a “touch screen”. The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. The visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.
骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。在一些实施例中,骨传导传感器180M也可以设置于耳机中,结合成骨传导耳机。音频模块170可以基于所述骨传导传感器180M获取的声部振动骨块的振动信号,解析出语音信号,实现语音功能。应用处理器可以基于所述骨传导传感器180M获取的血压跳动信号解析心率信息,实现心率检测功能。The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can obtain the vibration signal of the vibrating bone mass of the human voice. The bone conduction sensor 180M can also contact the human pulse and receive the blood pressure pulse signal. In some embodiments, the bone conduction sensor 180M may also be provided in the earphone, combined with the bone conduction earphone. The audio module 170 can parse the voice signal based on the vibration signal of the vibrating bone block of the voice obtained by the bone conduction sensor 180M, and realize the voice function. The application processor can analyze the heart rate information based on the blood pressure beating signal obtained by the bone conduction sensor 180M, and realize the heart rate detection function.
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The button 190 includes a power-on button, a volume button, and so on. The button 190 may be a mechanical button. It can also be a touch button. The electronic device 100 may receive key input, and generate key signal input related to user settings and function control of the electronic device 100.
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。The motor 191 can generate vibration prompts. The motor 191 can be used for incoming call vibration notification, and can also be used for touch vibration feedback. For example, touch operations that act on different applications (such as photographing, audio playback, etc.) can correspond to different vibration feedback effects. Acting on touch operations in different areas of the display screen 194, the motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminding, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 may be an indicator light, which may be used to indicate the charging status, power change, or to indicate messages, missed calls, notifications, and so on.
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。The SIM card interface 195 is used to connect to the SIM card. The SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the electronic device 100. The electronic device 100 may support 1 or N SIM card interfaces, and N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. The same SIM card interface 195 can insert multiple cards at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 may also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication. In some embodiments, the electronic device 100 adopts an eSIM, that is, an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiment of the present invention takes an Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100 by way of example.
图4是本发明实施例的电子设备100的软件结构框图。FIG. 4 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present invention.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.
如图4所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。As shown in Figure 4, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图4所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in Figure 4, the application framework layer can include a window manager, a content provider, a view system, a phone manager, a resource manager, and a notification manager.
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。The window manager is used to manage window programs. The window manager can obtain the size of the display, determine whether there is a status bar, lock the screen, take a screenshot, etc.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。The content provider is used to store and retrieve data and make these data accessible to applications. The data may include videos, images, audios, phone calls made and received, browsing history and bookmarks, phone book, etc.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls that display text, controls that display pictures, and so on. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface that includes a short message notification icon may include a view that displays text and a view that displays pictures.
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide the communication function of the electronic device 100. For example, the management of the call status (including connecting, hanging up, etc.).
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and it can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, and so on. The notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or a scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, text messages are prompted in the status bar, prompt sounds, electronic devices vibrate, and indicator lights flash.
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in a virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。The system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。The 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
2D图形引擎是2D绘图的绘图引擎。The 2D graphics engine is a drawing engine for 2D drawing.
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
在本申请实施例中,内核层还包括虚拟VFS、页缓存、内存管理模块和文件系统。其中,VFS是Linux文件系统对外的接口,也就是说,上层应用通过框架层和VFS访问内部存储器和外部存储器中的数据。页缓存,是Linux内核一种重要的磁盘高速缓存,用于缓存内存页的内容。例如,内核在读数据时,首先在页缓存中查找所读取的数据是否已经存在。如果不存在,则添加一个新的内存页到页缓存中,然后用从外部存储器中读取的数据填充该新的内存页。内存管理(memory management)模块,用于对电子设备100的内存资源的进行分配和管理。具体包括高效快速的分配内存资源,以及在合适的时候进行释放和回收内存资源。文件系统也可称为文件管理系统,用于对文件存储设备(例如外部存储器)的空间进行组织和分配,负责文件存储并对存入的文件进行保护和检索的系统。移动终端100可支持多种类型的文件系统,例如:第四代扩展文件系统(fourth extended filesystem,ext4)、闪存友好文件系统(flash friendly file system,F2FS)等。In the embodiment of the present application, the kernel layer also includes a virtual VFS, a page cache, a memory management module, and a file system. Among them, VFS is the external interface of the Linux file system, that is to say, upper-level applications access data in internal storage and external storage through the framework layer and VFS. Page cache is an important disk cache of the Linux kernel, used to cache the contents of memory pages. For example, when the kernel reads data, it first searches the page cache to see if the read data already exists. If it does not exist, add a new memory page to the page cache, and then fill the new memory page with data read from the external memory. The memory management module is used to allocate and manage the memory resources of the electronic device 100. Specifically, it includes the efficient and fast allocation of memory resources, and the release and recovery of memory resources when appropriate. The file system can also be referred to as a file management system, which is used to organize and allocate the space of file storage devices (for example, external memory), is responsible for file storage, and protects and retrieves stored files. The mobile terminal 100 may support multiple types of file systems, for example: fourth-generation extended file system (ext4), flash friendly file system (F2FS), etc.
下面以电子设备100是手机为例,结合附图对本申请实施例提供的技术方案进行详细说明。Hereinafter, taking the electronic device 100 as a mobile phone as an example, the technical solutions provided by the embodiments of the present application will be described in detail with reference to the accompanying drawings.
1、确定目标页面的方法1. How to determine the target page
本申请中,目标页面为手机需要锁定在内存中的内存页。即,在手机不断电的情况下,目标页面可以一直缓存在内存中,具体可存储在如图4中所示的页缓存中。也就是说,当手机的操作系统回收内存空间时,不会对目标页面进行回收。In this application, the target page is the memory page that the mobile phone needs to lock in the memory. That is, when the mobile phone is powered on, the target page can always be cached in the memory, and specifically can be stored in the page cache as shown in FIG. 4. In other words, when the mobile phone's operating system reclaims memory space, the target page will not be reclaimed.
目标页面为应用程序容易发生页缺失的页面。这样,当目标页面锁定在内存中时,应用程序运行时,能避免发生因目标页面发生的页缺失,提升应用程序运行速度。在一些示例中,可以选取应用程序启动时调用的页面中容易发生页缺失的页面,可以提升应用程序启动速度,减少首屏时间,提升用户体验。The target page is the page where the application is prone to page missing. In this way, when the target page is locked in the memory and the application program is running, page missing due to the target page can be avoided, and the running speed of the application program can be improved. In some examples, it is possible to select pages that are prone to page missing among the pages that are called when the application is started, which can increase the application startup speed, reduce the first screen time, and improve the user experience.
由于本申请的方案是将目标页面锁定在内存中,即目标页面的位置(在目标文件中的偏移量)和内容(内存页的具体数据)是不变的,因此在确定目标页面时,需要查找应用程序中位置和内容均不变的页面作为目标页面。Since the solution of this application is to lock the target page in memory, that is, the location of the target page (offset in the target file) and content (specific data of the memory page) are unchanged, so when determining the target page, You need to find a page whose location and content in the application are unchanged as the target page.
示例性的,可以根据应用程序调用的文件中确定目标文件,再从目标文件中确定目标页面。其中,目标文件为应用程序调用的位置和内容不变的文件,目标文件的数量为一个或多个。Exemplarily, the target file may be determined from the files called by the application, and then the target page may be determined from the target file. Among them, the target file is a file whose location and content are unchanged called by the application program, and the number of target files is one or more.
其中,可以选取满足以下条件1和条件2的文件作为目标文件,具体如下:Among them, a file that meets the following conditions 1 and 2 can be selected as the target file, as follows:
条件1、只读文件。 Condition 1. Read-only file.
这是因为,如果文件是可写的,则意味着文件可能会被修改,那么文件中的各个页面的位置和内容可能发生变化,发生页缺失的页面会不固定,无法预先将页面锁定在内存中。This is because if the file is writable, it means that the file may be modified, and the position and content of each page in the file may change, and the page where the page is missing will not be fixed, and the page cannot be locked in memory in advance. in.
在具体实现时,可以通过文件的尺寸大小进行判断,若文件的尺寸大小在运行过程中未发生改变,则该文件大概率是只读文件。或者,也可以通过获取文件的读写信息进行判断,读写信息明确指示该文件是只读文件或可读写文件。其中,文件的读写信息可从VFS中获取。当然,也可以采用其他方法确定文件是否是只读文件,本申请 实施例对此不做限定。In the specific implementation, the file size can be used to judge. If the file size does not change during the running process, the file has a high probability of being a read-only file. Alternatively, the judgment can also be made by obtaining the read and write information of the file, and the read and write information clearly indicates that the file is a read-only file or a readable and writable file. Among them, the file read and write information can be obtained from the VFS. Of course, other methods can also be used to determine whether the file is a read-only file, which is not limited in the embodiment of the application.
条件2、发生页缺失的次数与用户无关的文件。 Condition 2. The number of occurrences of page deletions has nothing to do with the user.
这是因为,文件发生页缺失的次数与用户有关,例如使用不同账号登录应用程序或手机中存储的用户数据不同时,发生页缺失的页面可能不固定,那么也无法预先将页面锁定在内存中,不便于在手机出厂前做统一的部署。This is because the number of times a file has page missing is related to the user. For example, when using different accounts to log in to the application or the user data stored in the mobile phone is different, the page where the page is missing may not be fixed, and the page cannot be locked in memory in advance. , It is not convenient to do a unified deployment before the mobile phone leaves the factory.
在具体实现时,在统计之前,分别使用不同的账号登录,或者手机中存储不同的用户数据,然后分别统计应用程序运行时,各个文件发生的页缺失的次数。将各个情况下发生页缺失次数相近的文件确定为与用户无关的文件。In specific implementation, before counting, use different accounts to log in, or store different user data in the mobile phone, and then count the number of page missing occurrences of each file when the application is running. The files with the same number of page deletions in each case are determined as files irrelevant to the user.
在另一些实施例中,目标文件除了满足条件1和条件2外,还可以满足条件3。In other embodiments, the target file can satisfy condition 3 in addition to condition 1 and condition 2.
条件3、应用程序频繁访问的文件。Condition 3. Files frequently accessed by the application.
一方面,将频繁访问的文件中容易发生页缺失的页面锁定在内存中,可以避免因该频繁访问文件频繁发生的页缺失,更有利于提升应用程序运行的速度。另一方面,由于手机内存有限,选择将频繁访问的文件中页面锁定在内存中,意味着不频繁访问文件中的页面可不用锁定在内存中,这将有利于提升内存的利用率。On the one hand, locking pages that are prone to page missing in frequently accessed files in the memory can avoid page missing frequently occurring due to frequently accessed files, which is more conducive to improving the running speed of the application. On the other hand, due to the limited memory of mobile phones, choosing to lock pages in frequently accessed files in memory means that pages in infrequently accessed files do not need to be locked in memory, which will help improve memory utilization.
在具体实现时,可以统计应用程序运行时访问文件的次数,将次数大于阈值的文件确定为频繁访问的文件。或者,按照访问文件的次数从多到少的顺序,选择前预设数量个(例如,15个)文件为频繁访问的文件。当然,也可以采用其他方法确定频繁访问的文件。In specific implementation, it is possible to count the number of times the file is accessed while the application is running, and determine the files whose times are greater than the threshold as frequently accessed files. Or, according to the order of the number of times of accessing the files, the first preset number (for example, 15) files are selected as frequently accessed files. Of course, other methods can also be used to determine frequently accessed files.
在确定目标文件后,从目标文件中确定应用程序启动时发生页缺失的页面为目标页面。After the target file is determined, it is determined from the target file that the page where the page is missing when the application is started is the target page.
示例性的,应用程序在相同的条件下运行多次(例如2次或2次以上),找到目标文件中几乎每次都会发生页缺失的页面,将该页面确定为目标页面。其中,目标页面可以是一个目标文件中的一个或多个页面。Exemplarily, the application program is run multiple times (for example, 2 times or more) under the same conditions, and a page in the target file that is missing almost every time is found, and the page is determined as the target page. Among them, the target page may be one or more pages in a target file.
具体的,可以根据应用程序访问上述目标文件的请求中,获取目标文件的信息以及目标页面的信息。例如,目标文件的信息可以包括:文件名称(file name)、文件索引号(inode number)、文件大小(file size)、请求大小(request size)、请求偏移(request offset)、缓存命中(hit)或未命中(miss)等。目标页面的信息可以包括:文件索引号、文件大小、请求大小、请求偏移等。Specifically, the information of the target file and the information of the target page can be obtained according to the request of the application program to access the above-mentioned target file. For example, the information of the target file may include: file name (file name), file index number (inode number), file size (file size), request size (request size), request offset (request offset), cache hit (hit ) Or miss, etc. The information of the target page may include: file index number, file size, request size, request offset, etc.
下面,以应用程序启动场景为例,对确定目标文件和目标页面的过程进行示例性说明。In the following, an application startup scenario is taken as an example to illustrate the process of determining the target file and the target page.
本申请中,可以针对不同的应用程序确定各个应用程序的目标页面。这里以确定第一应用程序中的目标页面为例,介绍确定目标页面的方法。In this application, the target page of each application can be determined for different applications. Here, the determination of the target page in the first application is taken as an example, and the method of determining the target page is introduced.
首先,可以从用户常用的应用程序中选取第一应用程序,第一应用程序例如可以是社交类应用,也可以是娱乐类应用,例如视频播放应用等,还可以是工具类应用,例如:地图应用等,本申请实施例对第一应用程序不做限定。First, the first application can be selected from the applications commonly used by the user. The first application can be, for example, a social application, an entertainment application, such as a video playback application, or a tool application, such as a map. For applications, etc., the embodiment of the present application does not limit the first application program.
在测试机上启动第一应用程序。其中,测试机可以是手机,或者是可以模拟第一应用程序在手机运行情况的服务器或计算机等。也就是说,测试机上的功能模块与手机相同或相似,例如,具有如图1相同的功能模块。并且,第一应用程序在测试机上运行的流程与在手机上运行的流程相同。Start the first application on the test machine. The test machine may be a mobile phone, or a server or computer that can simulate the operation of the first application on the mobile phone. That is to say, the functional modules on the test machine are the same or similar to the mobile phone, for example, have the same functional modules as shown in Figure 1. In addition, the flow of the first application running on the test machine is the same as the flow of running on the mobile phone.
测试机启动第一应用程序时,获取第一应用程序访问文件的信息,以便后续从第一应用程序访问的文件中确定目标文件,再从目标文件中确定目标页面。When the test machine starts the first application program, it obtains the information of the files accessed by the first application program, so as to subsequently determine the target file from the files accessed by the first application program, and then determine the target page from the target file.
示例性的,在测试机的虚拟文件系统中打印读流程中第一应用程序访问文件的信息。上述第一应用程序访问文件的信息包括:文件名称(file name)、文件索引号(inode number)、请求大小(request size)、请求偏移(request offset)、缓存命中(hit)或未命中(miss)等中的一项或多项。可以理解的是,应用层访问内存文件时会经过虚拟文件系统,因此在虚拟文件系统可以获取到第一应用程序访问的全部文件的信息。Exemplarily, the information about the file accessed by the first application in the reading process is printed in the virtual file system of the test machine. The information of the first application to access the file includes: file name (file name), file index number (inode number), request size (request size), request offset (request offset), cache hit (hit) or miss ( miss) one or more of the others. It is understandable that when the application layer accesses the memory file, it passes through the virtual file system. Therefore, the virtual file system can obtain information about all the files accessed by the first application program.
在一个具体的实现方式中,可以从虚拟文件系统获取/fs/read_write.c(VFS中的一个文件),并从该文件中sync_new_read()处获取第一应用访问文件的请求大小(request size)和请求偏移(request offset)的信息,以及访问文件的读写信息。可以在虚拟文件系统中调用函数dentry_path_raw()获取第一应用访问的文件的文件名称(file name)。可以从内存管理模块的代码中,例如/mm/filemap.c中do_generic_file_read()处获取第一应用访问文件是否缓存命中的信息。In a specific implementation, you can obtain /fs/read_write.c (a file in the VFS) from the virtual file system, and obtain the request size (request size) of the first application to access the file from sync_new_read() in the file And request offset information, and read and write information for accessing files. The function dentry_path_raw() can be called in the virtual file system to obtain the file name (file name) of the file accessed by the first application. The information about whether the first application accesses the file or not can be cached from the code of the memory management module, for example, do_generic_file_read() in /mm/filemap.c.
例如:可以根据获取的访问文件的读写信息,从第一应用程序启动时访问的文件中确定出只读文件,即确定满足条件1的文件。For example, a read-only file can be determined from the files accessed when the first application is started according to the obtained read and write information of the accessed file, that is, the file that meets the condition 1 can be determined.
又例如:考虑到测试机的硬件配置不同、第一应用程序设置不同、第一应用使用的用户信息不同、第一应用已有的用户数据不同等因素,可能造成第一应用启动时容易发生页缺失的页面可能不同。也可以收集第一应用程序在不同条件下启动时访问的文件的信息。然后对比不同条件下启动时访问的文件的信息,确定其中共同发生页缺失的文件为与用户数据无关的文件,即确定满足条件2的文件。Another example: considering the different hardware configuration of the test machine, the different settings of the first application program, the different user information used by the first application, and the different user data of the first application, it may cause the page to occur easily when the first application starts. The missing pages may be different. It is also possible to collect information about files accessed when the first application is started under different conditions. Then, compare the information of the files accessed at startup under different conditions, and determine that the file that has a common page missing is a file that has nothing to do with user data, that is, a file that meets condition 2 is determined.
可以理解的是,为了提升收集数据的准确性,可以多收集几次数据,并且在每次启动第一应用程序前清理测试机的内存,以确定第一应用程序启动时为冷启动。这是因为,第一应用程序在冷启动时发生页缺失的情况较多,且第一应用程序冷启动时耗费的时间较长,减少第一应用程序在冷启动时的耗费的时间,提升用户体验的效果更显著。It is understandable that in order to improve the accuracy of the collected data, it is possible to collect data several times, and clean the memory of the test machine before starting the first application each time, so as to determine that the first application is started as a cold start. This is because there are many cases of page missing during the cold start of the first application, and it takes a long time for the first application to cold start, which reduces the time that the first application takes during the cold start and improves users The effect of the experience is more significant.
从收集第一应用程序启动时访问的文件信息中确定出满足上述条件1和条件2,或者满足上述条件1至条件3的文件为目标文件。然后从目标文件中选取发生页缺失的页面作为目标页面。From the collection of file information accessed when the first application is started, it is determined that the file that meets the above condition 1 and the condition 2, or the file that meets the above condition 1 to condition 3 is the target file. Then select the page where the page is missing from the target file as the target page.
例如:第一应用程序访问文件时采用的格式为{文件索引号(inode number)、请求大小(request size)、请求偏移(request offset)、缓存命中(hit)或未命中(miss)}。For example, the format used by the first application to access the file is {file index number (inode number), request size (request size), request offset (request offset), cache hit (hit) or miss (miss)}.
假设采用用户1的数据启动第一应用程序,在启动时,从虚拟文件系统中获取到第一应用程序访问如下的文件:Assuming that the first application program is started with the data of user 1, at the time of startup, it is obtained from the virtual file system that the first application program accesses the following files:
{1,4Byte,0,miss;{1, 4Byte, 0, miss;
1,30Byte,11956,hit;1, 30Byte, 11956, hit;
1,4Byte,24878,miss;1, 4Byte, 24878, miss;
2,4Byte,39109,hit}2, 4Byte, 39109, hit}
假设采用用户2的数据启动第一应用程序,在启动时,从虚拟文件系统中获取到第一应用程序访问如下的文件:Assuming that the first application program is started with user 2’s data, at startup, it is obtained from the virtual file system that the first application program accesses the following files:
{1,4Byte,0,miss;{1, 4Byte, 0, miss;
1,30Byte,11956,hit;1, 30Byte, 11956, hit;
2,4Byte,39109,hit}2, 4Byte, 39109, hit}
假设已确定a.apk为目标文件,该目标文件的文件索引号为“1”。比较第一应用程序在使用不同用户数据下启动时访问文件的情况可知,确定两次启动时都发生页缺失的页面为{1,4Byte,0},确定为目标页面。Assuming that a.apk has been determined to be the target file, and the file index number of the target file is "1". Comparing the situation of accessing files when the first application is started using different user data, it can be seen that the page that is missing page is determined to be {1, 4Byte, 0} during both startups, which is determined as the target page.
以上是以第一应用程序为例,解释确定第一应用程序中目标文件和目标页面的过程的。手机上通常包含有多个应用程序,其中,确定其他应用程序中的目标文件和目标页面的过程与之类似,不再赘述。The above takes the first application program as an example to explain the process of determining the target file and the target page in the first application program. A mobile phone usually contains multiple applications, and the process of determining the target file and target page in other applications is similar, and will not be repeated here.
为了便于理解确定出的各个应用程序的目标文件和目标页面,如表一所示,给出了多个应用程序的目标文件和目标页面的一个示例。在具体实现时,可以将表一所示的信息以配置文件的形式写入手机的内核层,以便手机根据该配置文件锁定各个应用程序的目标页面。在一些示例中,可以将目标文件和目标页面的信息写入内核层的sysfs或proc文件中。In order to facilitate the understanding of the determined target files and target pages of each application, as shown in Table 1, an example of target files and target pages of multiple applications is given. In specific implementation, the information shown in Table 1 can be written into the kernel layer of the mobile phone in the form of a configuration file, so that the mobile phone locks the target page of each application according to the configuration file. In some examples, the target file and target page information can be written into the sysfs or proc file of the kernel layer.
表一Table I
Figure PCTCN2020125814-appb-000001
Figure PCTCN2020125814-appb-000001
其中,目标文件和目标页面的配置文件可以是一个或多个。一个配置文件中可以包括一个或多个应用程序对应的目标文件和目标页面。Among them, the target file and the configuration file of the target page may be one or more. A configuration file can include target files and target pages corresponding to one or more applications.
例如:手机内包含一个配置文件,该配置文件中包含多个应用程序的目标文件和目标页面。该配置文件通常是由手机厂商或手机操作系统厂商进行维护。因此,手机在操作系统升级时,可以直接根据更新后的配置文件对多个应用程序需要锁定和解锁的目标页面进行调整。For example: a mobile phone contains a configuration file that contains target files and target pages of multiple applications. The configuration file is usually maintained by the mobile phone manufacturer or mobile phone operating system manufacturer. Therefore, when the operating system of the mobile phone is upgraded, the target pages of multiple applications that need to be locked and unlocked can be adjusted directly according to the updated configuration file.
又例如:手机内包含多个配置文件,每个配置文件包含一个应用程序的目标文件和目标页面。每个应用程序对应的配置文件可以由应用程序厂商进行维护。这样,当手机安装和更新某个应用程序时,手机可以根据该应用程序更新后的配置文件,对该应用程序需要锁定和解锁的目标页面进行调整。Another example: the mobile phone contains multiple configuration files, and each configuration file includes a target file and a target page of an application. The configuration file corresponding to each application can be maintained by the application manufacturer. In this way, when a mobile phone installs and updates an application, the mobile phone can adjust the target page that the application needs to lock and unlock according to the updated configuration file of the application.
2、锁定目标页面2. Lock the target page
在本申请的一个实施例中,上述确定目标文件和目标页面的过程可以在实验室中进行,也就是说,可以预先通过实验确定出用户经常使用的应用程序在启动时,容易发生页缺失且页面位置和页面内容固定不变的页面,即目标页面。后续,将这些目标文件和目标页面的信息写入手机的配置文件中。即,手机出厂后存储的配置文件中包含多个应用程序的目标文件和目标页面的信息。例如:配置文件中包含目标文件的文件名称(file name)等。配置文件中包含的目标页面的信息包括目标页面的尺寸大小(size)和偏移量(offset)等。后续,当手机安装和启动应用程序时,可以根据该配 置文件锁定目标页面。在另一个示例中,出厂后的手机也可以不预先存储该配置文件,而是在用户选择优化应用程序启动速度的功能后,可以从服务器获取该配置文件。具体的,手机可以请求服务器发送配置文件,也可以是服务器向手机定期推送最新的配置文件,本申请实施例对此不做限定。In an embodiment of the present application, the above process of determining the target file and target page can be carried out in a laboratory, that is to say, it can be determined through experiments in advance that the application program that the user frequently uses is prone to page missing and The page whose position and content are fixed is the target page. Later, write these target files and target page information into the configuration file of the mobile phone. That is, the configuration file stored after the mobile phone leaves the factory contains the target files and target page information of multiple applications. For example: the configuration file contains the file name of the target file, etc. The target page information contained in the configuration file includes the size and offset of the target page. Later, when the mobile phone installs and starts the application, the target page can be locked according to the configuration file. In another example, the mobile phone after leaving the factory may not store the configuration file in advance, but after the user selects the function of optimizing the startup speed of the application, the configuration file may be obtained from the server. Specifically, the mobile phone may request the server to send the configuration file, or the server may periodically push the latest configuration file to the mobile phone, which is not limited in this embodiment of the application.
以下,以锁定第一应用程序中的目标页面为例进行说明,如图5所示,为本申请实施例提供的一种锁定目标页面的方法的流程图,具体如下:In the following, description is made by taking the locking of the target page in the first application as an example. As shown in FIG. 5, a flowchart of a method for locking a target page provided by an embodiment of this application is specifically as follows:
S501、手机启动第一应用程序。S501. The mobile phone starts the first application.
S502、确定是否发生页缺失。S502. Determine whether page missing occurs.
S503、若手机发生页缺失,从外部存储器中读取缺失页面的内容到内部存储器中。S503: If a page is missing in the mobile phone, read the content of the missing page from the external memory to the internal memory.
在步骤S501和步骤S503中,手机在接收得到用户启动第一应用程序的指示时启动第一应用程序,或者手机在满足预设条件时自动启动第一应用程序。In step S501 and step S503, the mobile phone starts the first application when receiving an instruction from the user to start the first application, or the mobile phone automatically starts the first application when a preset condition is met.
在本申请中,从手机接收到用户启动第一应用程序的指示,或者手机确定满足预设条件时确定启动第一应用程序开始,到手机完整显示出第一应用程序主界面的过程,可认为是第一应用程序的启动过程。例如,手机检测到用户点击桌面上第一应用程序图标的操作,该点击操作会触发手机调用startActivity(Intent),并最终调用到ActivityManagerService。ActivityManagerService通过调用startProcessLocked()方法来创建新的进程。然后手机将创建的新的进程与和指定的Application(即第一应用程序)绑定起来。后面,从该已经存在的进程中启动新进程的activity,读取第一应用程序的数据。In this application, the process from the mobile phone receiving the user's instruction to start the first application program, or the mobile phone determining to start the first application program when the preset conditions are met, to the complete display of the main interface of the first application program on the mobile phone, can be considered It is the startup process of the first application. For example, if the mobile phone detects that the user clicks the first application icon on the desktop, the click operation will trigger the mobile phone to call startActivity(Intent), and finally call the ActivityManagerService. ActivityManagerService creates a new process by calling the startProcessLocked() method. Then the mobile phone binds the created new process with the specified Application (ie, the first application). Later, the activity of the new process is started from the existing process, and the data of the first application is read.
其中,在手机启动第一应用程序的过程中,读取内存中的数据的过程具体为:通过应用程序框架层向内核层的虚拟文件系统发送用于启动第一应用程序所需页面的读请求。虚拟文件系统确定内存中是否缓存有请求的各个页面,即请求的各个页面缓存是否缓存命中。若确定某个页面缓存命中时,则从内存的页缓存中读取该页面。若确定某个页面缓存未命中(hit)时,则发生页缺失。虚拟文件系统针对缓存未命中(miss)的页面,则向文件系统发送读请求,请求从外部存储器中读取该页面。其中,缓存未命中的页面即为缺失页面。也就是说,将缺失页面的内容缓存在内存中。Among them, in the process of starting the first application on the mobile phone, the process of reading data in the memory is specifically: sending a read request for the page required to start the first application to the virtual file system of the kernel layer through the application framework layer . The virtual file system determines whether each requested page is cached in the memory, that is, whether each requested page cache is cached. If it is determined that a certain page cache hits, the page is read from the page cache in the memory. If it is determined that a certain page cache misses (hit), a page miss occurs. The virtual file system sends a read request to the file system for the page that is missed in the cache, requesting to read the page from the external memory. Among them, the page with a cache miss is the missing page. In other words, the content of the missing page is cached in memory.
这样,手机内存中缓存有第一应用程序启动所需的所有页面的内容,便于手机启动第一应用程序并显示第一应用程序的主界面。In this way, the mobile phone memory caches the contents of all pages required for starting the first application program, which is convenient for the mobile phone to start the first application program and display the main interface of the first application program.
S504、在手机从外部存储器中读取缺失页面的内容到内部存储器中后,手机确定缺失页面所在的文件是否为目标文件。S504. After the mobile phone reads the content of the missing page from the external memory into the internal memory, the mobile phone determines whether the file where the missing page is located is the target file.
S505、若所述缺失页面所在的文件为目标文件,则确定所述缺失页面是否为目标页面。若确定缺失页面所在文件不为目标文件,则流程结束。S505: If the file where the missing page is located is the target file, determine whether the missing page is the target page. If it is determined that the file where the missing page is located is not the target file, the process ends.
在步骤S504和步骤S505中,当确定缺失页面缓存未命中时,从缺失页面的读请求中获取缺失页面所在的文件的信息,例如文件索引号(inode number)。上文已说明,手机的配置文件中可以包含第一应用程序中目标文件的文件名称,因此,手机可以预先将配置文件中目标文件的文件名称转换为相应的文件索引号。这样,当获取到缺失页面的文件索引号,可以根据缺失页面的文件索引号以及转换后的目标文件的文件索引号进行比对,以确定缺失页面所在文件是否为目标文件。In step S504 and step S505, when it is determined that the missing page cache misses, the information of the file where the missing page is located is obtained from the read request for the missing page, such as the file index number (inode number). As explained above, the configuration file of the mobile phone can include the file name of the target file in the first application. Therefore, the mobile phone can convert the file name of the target file in the configuration file into the corresponding file index number in advance. In this way, when the file index number of the missing page is obtained, it can be compared according to the file index number of the missing page and the file index number of the converted target file to determine whether the file where the missing page is located is the target file.
当然,在获取到缺失页面的文件索引号后,也可以将缺失页面的文件索引号转换 为文件名称,与配置文件中目标文件的文件名称进行比对,以确定缺失页面所在文件是否为目标文件,本申请实施例对确定缺失页面所在文件是否为目标文件的方法不做限定。Of course, after obtaining the file index number of the missing page, you can also convert the file index number of the missing page into a file name, and compare it with the file name of the target file in the configuration file to determine whether the file where the missing page is located is the target file The embodiment of the present application does not limit the method for determining whether the file where the missing page is located is the target file.
若确定缺失页面所在文件为目标文件,则进一步确定缺失页面是否为目标文件中的目标页面。根据缺失页面的读请求中获取缺失页面的信息,例如:请求大小(request size)、请求偏移(request offset)。上文已说明,手机的配置文件中包含目标页面的信息,例如尺寸大小和偏移量。那么,可以通过查找手机的配置文件,确定缺失页面是否为配置文件中的目标页面。If it is determined that the file where the missing page is located is the target file, it is further determined whether the missing page is the target page in the target file. Obtain the information of the missing page according to the read request of the missing page, for example: request size (request size), request offset (request offset). As explained above, the configuration file of the mobile phone contains information about the target page, such as the size and offset. Then, you can determine whether the missing page is the target page in the configuration file by searching the configuration file of the mobile phone.
可以理解的是,在手机将缺失页面缓存到内部存储器中后,手机也可以直接判断缺失页面是否是目标页面。也就是说,步骤S504和步骤S505可替换为,手机确定缺失页面是否为目标页面,而后执行步骤S506。此时,目标页面的信息可以认为是包括目标页面所在文件的文件名称、目标页面的尺寸大小和目标页面的偏移量。那么,手机直接将缺失页面的信息与目标页面的信息进行比对,确定缺失页面是否为目标页面。It is understandable that after the mobile phone caches the missing page in the internal memory, the mobile phone can also directly determine whether the missing page is the target page. That is, step S504 and step S505 can be replaced by the mobile phone determining whether the missing page is the target page, and then step S506 is executed. At this time, the information of the target page can be considered to include the file name of the file where the target page is located, the size of the target page, and the offset of the target page. Then, the mobile phone directly compares the information of the missing page with the information of the target page to determine whether the missing page is the target page.
需要说明的是,手机需要在步骤S504之前预先读取配置文件,获取第一应用程序的目标文件的信息。例如,手机可以在开机后,或操作系统升级后,或接收到启动第一应用程序指示后,或安装第一应用程序时,或更新第一应用程序后等,就读取配置文件,获取第一应用程序中的目标文件和目标页面的信息。本申请实施例对手机读取配置文件的时机不做限定。It should be noted that the mobile phone needs to read the configuration file in advance before step S504 to obtain the information of the target file of the first application. For example, after the mobile phone is turned on, or after the operating system is upgraded, or after receiving the instruction to start the first application, or when the first application is installed, or after the first application is updated, it can read the configuration file and obtain the first application. A target file and target page information in an application. The embodiment of this application does not limit the time when the mobile phone reads the configuration file.
S506、若所述缺失页面为目标页面,则将缺失页面的内容锁定到内部存储器中。若所述缺失页面不为目标页面,则流程结束。S506: If the missing page is the target page, lock the content of the missing page in the internal memory. If the missing page is not the target page, the process ends.
示例性的,由于步骤S503中,已经将缺失页面的内容缓存到内存中,这里可以将缺失页面的内容挂载到内存中的不可移除LRU链表(unevictable LRU list)中,实现该缺失页面的内容被锁定到内部存储器中。其中,不可移除LRU链表(以下简称不可移除链表)是一个可以存放内存页内容的数据结构。将缺失页面的内容挂载到内存中的不可移除链表中,相当于在不可移除链表中添加了缺失页面的内容。在内存不断电的情况下,不可移除链表中的内存页的内容不会被回收,因此,缺失页的内容也将不会被回收。也就是说,在内存不断电的情况下,缺失页面的内容会一直缓存在内存中,不会被回收。Exemplarily, since the content of the missing page has been cached in the memory in step S503, the content of the missing page can be mounted in the unremovable LRU list (unevictable LRU list) in the memory to realize the detection of the missing page. The content is locked into the internal memory. Among them, the non-removable LRU linked list (hereinafter referred to as the non-removable linked list) is a data structure that can store the contents of a memory page. Mounting the content of the missing page to the non-removable linked list in memory is equivalent to adding the content of the missing page to the non-removable linked list. In the case of unremovable memory power, the contents of the memory pages in the unremovable linked list will not be recycled. Therefore, the contents of the missing pages will not be recycled. In other words, when the memory is powered on, the content of the missing pages will always be cached in the memory and will not be recycled.
例如,以下给出实现上述步骤S504至步骤S506的一段代码示例,可通过在内核层的VFS中Mm/Filemap.c中的do_generic_file_read()处添加如下的代码:For example, the following is a code example that implements the above steps S504 to S506, and the following code can be added to the do_generic_file_read() in Mm/Filemap.c in the VFS of the kernel layer:
Figure PCTCN2020125814-appb-000002
Figure PCTCN2020125814-appb-000002
Figure PCTCN2020125814-appb-000003
Figure PCTCN2020125814-appb-000003
其中,key_inode[]为目标文件的文件索引号,key_offset0为目标页面的偏移量,key_size0为目标页面的尺寸大小。Among them, key_inode[] is the file index number of the target file, key_offset0 is the offset of the target page, and key_size0 is the size of the target page.
这样,当后续再次启动第一应用程序时,缺失页面可以直接从内存中读出,减少了因目标页面而发生的页缺失,提升了第一应用程序启动速度,减少了第一应用程序的首屏时间,提升了用户体验。In this way, when the first application is subsequently started again, the missing pages can be directly read from the memory, which reduces page missing due to the target page, improves the startup speed of the first application, and reduces the first application of the first application. Screen time improves user experience.
由此可见,将手机启动第一应用程序的过程所需要读取的页面中,易发生页缺失的特定页面(即目标页面)锁定在手机的内存中。后续,当手机再次启动第一应用程序时,可以直接从内存中读取到相应的页面,避免这些页面再发生页缺失,进而加快了应用程序的启动速度。It can be seen that, among the pages that need to be read in the process of starting the first application by the mobile phone, a specific page that is prone to page missing (ie, the target page) is locked in the memory of the mobile phone. Later, when the mobile phone starts the first application again, it can directly read the corresponding pages from the memory, so as to avoid page missing of these pages again, thereby speeding up the startup of the application.
在一些示例中,随着应用程序版本的升级等因素,可能造成目标页面发生变化,例如第一应用程序可能出现满足目标页面条件的新页面,或者原来的目标页面不再满足目标页面的条件时,又或者,目标页面的内容等发生变化等。在这种情况下,可以对配置文件中的各个应用程序的目标文件和目标页面进行更新。In some examples, with the upgrade of the application version and other factors, the target page may change. For example, a new page that meets the conditions of the target page may appear in the first application, or the original target page no longer meets the conditions of the target page. , Or, the content of the target page changes, etc. In this case, you can update the target file and target page of each application in the configuration file.
例如:配置文件可以由手机厂商或手机操作系统厂商进行维护。那么,在手机升级操作系统时,可以从服务器获取最新的配置文件,对原来的配置文件进行替换。或者,用户也可以从应用市场或网络上下载最新的配置文件进行更新。而后,手机根据更新后的配置文件对锁定的目标页面进行调整,例如锁定新的目标页面,解锁不再满足目标页面条件的页面,以提高内存有效利用率。其中,解锁不再满足目标页面条件的页面,可以将该页面的内容从不可移除链表中移除。For example, the configuration file can be maintained by a mobile phone manufacturer or a mobile phone operating system manufacturer. Then, when the mobile phone upgrades the operating system, the latest configuration file can be obtained from the server, and the original configuration file can be replaced. Alternatively, the user can also download the latest configuration file from the application market or the Internet to update it. Then, the mobile phone adjusts the locked target page according to the updated configuration file, such as locking a new target page, and unlocking pages that no longer meet the target page conditions, so as to improve effective memory utilization. Among them, unlocking a page that no longer meets the conditions of the target page can remove the content of the page from the non-removable linked list.
又例如:配置文件可以由第一应用程序厂商(例如应用程序的开发者或管理者)进行维护。那么,在手机安装或更新第一应用程序时,从服务器获取最新的配置文件,对原来的配置文件进行替换。而后,手机根据更新后的配置文件对锁定的目标页面进行调整,例如锁定新的目标页面,解锁不再满足目标页面条件的页面,以提高内存有效利用率。其中,解锁不再满足目标页面条件的页面,可以将该页面的内容从不可移除链表中移除。For another example, the configuration file may be maintained by the first application manufacturer (for example, the developer or manager of the application). Then, when the mobile phone installs or updates the first application, the latest configuration file is obtained from the server, and the original configuration file is replaced. Then, the mobile phone adjusts the locked target page according to the updated configuration file, such as locking a new target page, and unlocking pages that no longer meet the target page conditions, so as to improve effective memory utilization. Among them, unlocking a page that no longer meets the conditions of the target page can remove the content of the page from the non-removable linked list.
可以理解的是,上述实施例是以第一应用程序在检查页面是否缓存命中时,对缓存未命中的目标页面进行锁定为例进行说明的。可以理解的是,基于本申请的发明构思,也可以在其他时机对目标页面进行锁定。例如,当第一应用程序安装完成后,手机也可以根据配置文件(包含第一应用程序目标文件信息和目标页面信息),从外部 存储器中读取目标页面到内存,并进行锁定。这样,后续当启动第一应用程序时,将不会出现因读取目标页面而发生页缺失的情况。It can be understood that the foregoing embodiment is described by taking as an example the first application program to lock the target page of the cache miss when checking whether the page is cache hit. It is understandable that based on the inventive concept of this application, the target page can also be locked at other times. For example, after the installation of the first application program is completed, the mobile phone can also read the target page from the external memory to the memory according to the configuration file (including the target file information and target page information of the first application program), and lock it. In this way, when the first application is started later, there will be no page missing due to reading the target page.
在本申请的另一些实施例中,上述确定目标文件的过程可以在实验室中进行,而后,将确定的目标文件写入手机的配置文件。后续,手机出厂后,也可以根据目标文件,以及手机上实际运行应用程序的情况,自动确定出目标页面。也就是说,手机出厂后存储的配置文件中包含多个应用程序中目标文件的信息,例如配置文件中包含的目标文件的文件名称(file name)等。后续,当手机安装和启动应用程序后,可以根据该配置文件结合应用程序的实际运行情况确定出目标页面,再锁定目标页面。In some other embodiments of the present application, the above process of determining the target file can be performed in a laboratory, and then the determined target file is written into the configuration file of the mobile phone. Later, after the phone leaves the factory, the target page can also be automatically determined based on the target file and the actual running application on the phone. That is to say, the configuration file stored after the mobile phone leaves the factory contains the information of the target file in multiple applications, such as the file name of the target file contained in the configuration file. Later, after the mobile phone installs and starts the application, the target page can be determined according to the configuration file and the actual running situation of the application, and then the target page is locked.
如图6所示,为本申请实施例提供的又一种锁定目标页面的方法的流程图,具体如下:As shown in FIG. 6, a flowchart of another method for locking a target page provided by an embodiment of this application is as follows:
S601、手机安装或更新第一应用程序。S601. The mobile phone installs or updates the first application.
S602、获取第一应用程序对应的目标文件。S602. Obtain a target file corresponding to the first application program.
上文已说明,手机在出厂前的配置文件中包含有各个应用程序的目标文件的信息,例如目标文件的文件名称。在具体实现时,请参见图7中步骤(1)至步骤(3),在手机安装或更新第一应用程序后,应用层的第一应用程序会通过框架层通知内核层读取目标文件的配置文件。并将配置文件中目标文件的文件名称转换为相应的文件索引号,以便后续根据文件索引号区分出目标文件。As explained above, the configuration file of the mobile phone before leaving the factory contains the information of the target file of each application, such as the file name of the target file. For specific implementation, please refer to steps (1) to (3) in Figure 7. After the mobile phone installs or updates the first application, the first application of the application layer will notify the kernel layer to read the target file through the framework layer. Configuration file. And convert the file name of the target file in the configuration file to the corresponding file index number, so that the target file can be distinguished according to the file index number in the subsequent.
S603、手机多次启动第一应用程序,并在每次启动时,记录各个目标文件中发生页缺失的页面。S603. The mobile phone starts the first application multiple times, and every time it is started, it records pages with missing pages in each target file.
手机每一次启动第一应用程序时,都会向内核层请求读取显示第一应用程序主界面的页面。内核层会先判断请求的页面是否缓存在内存中。若缓存在内存中,则直接从内存中读取并执行。若未缓存在内存中,则会发生页缺失,向文件系统请求缺失页的读请求,从外部存储器中读取缺失页面。Every time the mobile phone starts the first application, it will request the kernel layer to read the page displaying the main interface of the first application. The kernel layer will first determine whether the requested page is cached in memory. If the cache is in the memory, it is directly read from the memory and executed. If it is not cached in the memory, a page miss will occur, a read request for the missing page is requested from the file system, and the missing page is read from the external memory.
请继续参见图7中步骤(4)至步骤(6),在每次启动第一应用程序的过程中,手机记录各个目标文件中发生页缺失的页面的信息(例如:页面对应的文件索引号、尺寸大小、偏移),并将发生页缺失的页面信息存储在临时文件中。Please continue to refer to steps (4) to (6) in Figure 7. Each time the first application is started, the mobile phone records the information of the page where the page is missing in each target file (for example: the file index number corresponding to the page) , Size, offset), and store the page information where the page is missing in a temporary file.
S604、根据记录的各个目标文件中发生页缺失的页面,确定目标页面。S604: Determine the target page according to the recorded pages in each target file where the page is missing.
请继续参见图7中的步骤(7),当收集了至少两次启动过程中的数据后,可以对临时文件中的数据进行对比。目标文件中每次启动时都会发生页缺失的页面确定为目标页面。上文已经详述了确定目标页面的方法,这里不做赘述。在确定目标页面,获取目标页面的信息后,可以删除临时文件。Please continue to refer to step (7) in Figure 7. When the data in the startup process is collected at least twice, the data in the temporary file can be compared. In the target file, the page that will be missing every time it is started is determined as the target page. The method of determining the target page has been described in detail above, so I won’t go into details here. After determining the target page and obtaining the information of the target page, you can delete the temporary file.
S605、将确定的目标页面锁定在内部存储器中。S605: Lock the determined target page in the internal memory.
本步骤可参见步骤S506中相关内容。For this step, refer to related content in step S506.
由此可见,手机可以根据第一应用程序实际运行的情况,自动确定目标页面,使得确定出的目标页面更具有针对性,更准确。并且,在第一应用程序更新时,也可以自动更新目标页面,利于提升第一应用程序的启动速度。It can be seen that the mobile phone can automatically determine the target page according to the actual running situation of the first application, so that the determined target page is more targeted and accurate. In addition, when the first application program is updated, the target page may also be automatically updated, which is beneficial to improve the startup speed of the first application program.
在一些示例中,应用程序的开发者或管理者也可以对目标文件进行更新和修改。例如,当应用程序升级时,也可以同时对配置文件中的该应用程序对应的目标文件进行修改。修改的方式,例如可以是应用程序的安装包或升级包中可以携带新的目标文 件的文件名称。在应用程序升级时,可以用新的目标文件的文件名称替换手机中原来的配置文件中该应用程序的目标文件的文件名称。In some examples, the developer or manager of the application can also update and modify the target file. For example, when the application program is upgraded, the target file corresponding to the application program in the configuration file can also be modified at the same time. The modification method can be, for example, the file name of the new target file can be carried in the installation package or upgrade package of the application. When the application is upgraded, the file name of the target file of the application in the original configuration file in the mobile phone can be replaced with the file name of the new target file.
在另一些示例中,手机也可以提供修改配置文件的界面,供用户选择是否锁定某些应用程序的目标文件。例如,若用户可以在这些界面中选择自己不常使用某些应用程序,或者不想优化的应用程序,手机可以将用户选择的应用程序对应的目标页面进行解锁。In other examples, the mobile phone may also provide an interface for modifying the configuration file for the user to choose whether to lock the target file of certain applications. For example, if the user can select certain applications that he rarely use or do not want to optimize in these interfaces, the mobile phone can unlock the target page corresponding to the application selected by the user.
在又一些示例中,手机在检测到用户卸载某些应用程序后,可以自动的将该卸载的应用程序对应的目标页面进行解锁,以释放内存空间,提升内存的利用率。In other examples, after the mobile phone detects that the user has uninstalled certain applications, it can automatically unlock the target page corresponding to the uninstalled application to release memory space and improve memory utilization.
当然,当手机更新操作系统时,也可以对配置文件中各个应用程序的目标文件进行更新或者,用户也可以通过下载最新的配置文件,对各个应用程序中的目标文件进行更新。进一步的,根据更新后的目标文件,锁定新的目标页面,解锁不再是目标页面的页面。Of course, when the mobile phone updates the operating system, the target file of each application in the configuration file can also be updated, or the user can also update the target file of each application by downloading the latest configuration file. Further, according to the updated target file, the new target page is locked, and the page that is no longer the target page is unlocked.
可以理解的是,在方案不矛盾的情况下,可以将上述实施例进行任意的组合。例如,也可以是在实验室中预先确定好目标文件和目标页面,并将目标文件和目标页面的信息写入手机的配置文件中。当手机出厂后,开始运行应用程序后,先根据配置文件中的目标文件和目标页面锁定预先设置的目标页面。后续,当应用程序更新、用户卸载或选择不优化某些应用程序时,对配置文件中的目标文件和目标页面进行适应性修改等。It can be understood that, provided that the solutions are not contradictory, the foregoing embodiments can be combined in any combination. For example, it is also possible to pre-determine the target file and target page in the laboratory, and write the target file and target page information into the configuration file of the mobile phone. After the phone leaves the factory and starts to run the application, it first locks the preset target page according to the target file and target page in the configuration file. Later, when the application is updated, the user uninstalls or chooses not to optimize some applications, the target file and target page in the configuration file are adaptively modified, etc.
本申请实施例还提供一种芯片系统,如图8所示,该芯片系统包括至少一个处理器1101和至少一个接口电路1102。处理器1101和接口电路1102可通过线路互联。例如,接口电路1102可用于从其它装置(例如电子设备100的存储器)接收信号。又例如,接口电路1102可用于向其它装置(例如处理器1101)发送信号。示例性的,接口电路1102可读取存储器中存储的指令,并将该指令发送给处理器1101。当所述指令被处理器1101执行时,可使得电子设备执行上述实施例中的手机(比如,手机)执行的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。The embodiment of the present application also provides a chip system. As shown in FIG. 8, the chip system includes at least one processor 1101 and at least one interface circuit 1102. The processor 1101 and the interface circuit 1102 may be interconnected by wires. For example, the interface circuit 1102 may be used to receive signals from other devices (such as the memory of the electronic device 100). For another example, the interface circuit 1102 may be used to send signals to other devices (such as the processor 1101). Exemplarily, the interface circuit 1102 can read an instruction stored in the memory, and send the instruction to the processor 1101. When the instructions are executed by the processor 1101, the electronic device can be made to execute the steps performed by the mobile phone (for example, the mobile phone) in the above-mentioned embodiment. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiment of the present application.
本申请实施例还提供一种装置,该装置包含在电子设备中,该装置具有实现上述实施例中任一方法中电子设备行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括至少一个与上述功能相对应的模块或单元。例如,检测模块或单元、缓存模块或单元、确定模块或单元、以及锁定模块或单元等。An embodiment of the present application also provides a device included in an electronic device, and the device has a function of realizing the behavior of the electronic device in any of the methods in the foregoing embodiments. This function can be realized by hardware, or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above-mentioned functions. For example, a detection module or unit, a cache module or unit, a determination module or unit, and a locking module or unit, etc.
本申请实施例还提供一种计算机可读存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行如上述实施例中任一方法。An embodiment of the present application also provides a computer-readable storage medium, including computer instructions, which when the computer instructions run on an electronic device, cause the electronic device to perform any method as in the foregoing embodiments.
本申请实施例还提供一种计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行如上述实施例中任一方法。The embodiments of the present application also provide a computer program product, which when the computer program product runs on a computer, causes the computer to execute any method as in the above-mentioned embodiments.
可以理解的是,上述终端等为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请实施例能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用 不同方法来实现所描述的功能,但是这种实现不应认为超出本发明实施例的范围。It can be understood that, in order to implement the above-mentioned functions, the above-mentioned terminal and the like include hardware structures and/or software modules corresponding to each function. Those skilled in the art should easily realize that in combination with the units and algorithm steps of the examples described in the embodiments disclosed herein, the embodiments of the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered as going beyond the scope of the embodiments of the present invention.
本申请实施例可以根据上述方法示例对上述终端等进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本发明实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment of the present application may divide the above-mentioned terminal and the like into functional modules according to the above-mentioned method examples. For example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The above-mentioned integrated modules can be implemented in the form of hardware or software function modules. It should be noted that the division of modules in the embodiment of the present invention is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of the description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned functions can be allocated according to needs. It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. For the specific working process of the above-described system, device, and unit, reference may be made to the corresponding process in the foregoing method embodiment, which is not repeated here.
在本申请实施例各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。The functional units in the various embodiments of the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:快闪存储器、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application are essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of software products, and the computer software products are stored in a storage The medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific implementations of this application, but the protection scope of this application is not limited to this. Any changes or substitutions within the technical scope disclosed in this application shall be covered by the protection scope of this application. . Therefore, the protection scope of this application should be subject to the protection scope of the claims.

Claims (16)

  1. 一种加速应用程序启动的方法,其特征在于,应用于电子设备,所述电子设备包含有配置文件,所述配置文件包括目标页面的信息,所述方法包括:A method for accelerating the startup of an application program, characterized in that it is applied to an electronic device, the electronic device contains a configuration file, the configuration file includes information of a target page, and the method includes:
    响应于检测到启动第一应用程序的指令,所述电子设备启动所述第一应用程序;In response to detecting the instruction to start the first application, the electronic device starts the first application;
    所述电子设备请求访问所述第一应用程序启动过程所需的内存页;The electronic device requests to access the memory page required by the startup process of the first application;
    若所述第一应用程序启动过程所需的内存页中的第一内存页未缓存在内部存储器中,则所述电子设备从外部存储器中读取所述第一内存页的内容,并缓存到内部存储器中;If the first memory page among the memory pages required for the startup process of the first application program is not cached in the internal memory, the electronic device reads the content of the first memory page from the external memory and caches it to In the internal memory;
    在所述电子设备将所述第一内存页从外部存储器中缓存到内部存储器中之后,所述电子设备根据所述配置文件中目标页面的信息确定所述第一内存页是否为目标页面;After the electronic device caches the first memory page from the external memory to the internal memory, the electronic device determines whether the first memory page is the target page according to the target page information in the configuration file;
    在确定所述第一内存页为目标页面之后,所述电子设备将所述第一内存页锁定在所述内部存储器中。After determining that the first memory page is the target page, the electronic device locks the first memory page in the internal memory.
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    所述电子设备检测到退出所述第一应用程序的指令,所述电子设备退出所述第一应用程序;The electronic device detects an instruction to exit the first application program, and the electronic device exits the first application program;
    所述电子设备再次检测到启动所述第一应用程序的指令时,所述电子设备再次启动所述第一应用程序;When the electronic device detects the instruction to start the first application again, the electronic device starts the first application again;
    所述电子设备获取所述第一应用程序启动过程所需的内存页;Acquiring, by the electronic device, a memory page required by the startup process of the first application program;
    所述电子设备显示所述第一应用程序的主界面。The electronic device displays the main interface of the first application.
  3. 根据权利要求1或2所述的方法,其特征在于,所述目标页面为目标文件中的一个或多个页面,且所述目标页面在所述第一应用程序启动的过程中曾发生过页缺失;所述目标文件为所述第一应用程序启动时访问的一个或多个只读文件,且为所述第一应用程序在启动时访问时发生页缺失的次数与用户数据无关的一个或多个文件。The method according to claim 1 or 2, wherein the target page is one or more pages in a target file, and the target page has been paged during the start of the first application. Missing; the target file is one or more read-only files accessed when the first application is started, and is one or more of the number of page deletions that have nothing to do with user data when the first application is accessed when the first application is started Multiple files.
  4. 根据权利要求3所述的方法,其特征在于,所述目标文件为所述第一应用程序在启动时访问次数大于阈值的一个或多个文件。The method according to claim 3, wherein the target file is one or more files whose access times are greater than a threshold when the first application is started.
  5. 根据权利要求3或4所述的方法,其特征在于,所述配置文件中所述目标页面的信息包括所述目标文件的信息和所述目标页面的信息;The method according to claim 3 or 4, wherein the information of the target page in the configuration file includes information of the target file and information of the target page;
    所述电子设备根据所述配置文件中目标页面的信息确定所述第一内存页是否为目标页面,具体为:The electronic device determines whether the first memory page is the target page according to the information of the target page in the configuration file, specifically:
    所述电子设备根据所述配置文件中目标文件的信息确定所述第一内存页所在的文件是否为目标文件;The electronic device determines whether the file where the first memory page is located is the target file according to the information of the target file in the configuration file;
    在确定所述第一内存页所在的文件为目标文件之后,所述电子设备根据所述配置文件中目标页面的信息确定所述第一内存页是否为目标页面。After determining that the file where the first memory page is located is the target file, the electronic device determines whether the first memory page is the target page according to the information of the target page in the configuration file.
  6. 根据权利要求5所述的方法,其特征在于,所述配置文件中所述目标文件的信息包括所述目标文件的名称。The method according to claim 5, wherein the information of the target file in the configuration file includes the name of the target file.
  7. 根据权利要求6所述的方法,其特征在于,所述配置文件中所述目标页面的信息包括所述目标页面的尺寸大小和偏移。The method according to claim 6, wherein the information of the target page in the configuration file includes the size and offset of the target page.
  8. 根据权利要求7所述的方法,其特征在于,所述方法还包括:The method according to claim 7, wherein the method further comprises:
    当所述电子设备更新操作系统或所述电子设备更新所述第一应用程序时,所述电 子设备从服务器获取最新的配置文件进行更新。When the electronic device updates the operating system or the electronic device updates the first application, the electronic device obtains the latest configuration file from the server for update.
  9. 根据权利要求5-8任一项所述的方法,其特征在于,所述确定所述第一内存页所在的文件是否为目标文件,具体为:The method according to any one of claims 5-8, wherein the determining whether the file in which the first memory page is located is a target file is specifically:
    获取所述第一内存页的读请求,从所述第一内存页的读请求中获取所述第一内存页所在文件的文件索引号,以及根据配置文件中的所述目标文件的名称获取所述目标文件的文件索引号;Obtain the read request of the first memory page, obtain the file index number of the file where the first memory page is located from the read request of the first memory page, and obtain all files according to the name of the target file in the configuration file. The file index number of the target file;
    根据所述第一内存页所在文件的文件索引号和所述目标文件的文件索引号,确定所述第一内存页是否为所述目标文件。Determine whether the first memory page is the target file according to the file index number of the file where the first memory page is located and the file index number of the target file.
  10. 根据权利要求9所述的方法,其特征在于,所述确定所述第一内存页是否为目标页面,具体为:The method according to claim 9, wherein the determining whether the first memory page is a target page is specifically:
    从所述第一内存页的读请求中获取所述第一内存页的尺寸大小和偏移;Acquiring the size and offset of the first memory page from the read request of the first memory page;
    根据所述第一内存页的尺寸大小和偏移,以及所述目标页面的尺寸大小和偏移,确定所述第一内存页是否为所述目标页面。Determine whether the first memory page is the target page according to the size and offset of the first memory page and the size and offset of the target page.
  11. 根据权利要求1-10任一项所述的方法,其特征在于,在确定所述第一内存页为目标页面之后,所述电子设备将所述第一内存页锁定在所述内部存储器中,具体为:The method according to any one of claims 1-10, wherein after determining that the first memory page is a target page, the electronic device locks the first memory page in the internal memory, Specifically:
    在确定所述第一内存页为目标页面之后,所述电子设备将所述第一内存页的内容添加到内部存储器的不可移除链表中。After determining that the first memory page is the target page, the electronic device adds the content of the first memory page to the non-removable linked list of the internal memory.
  12. 根据权利要求1-11任一项所述方法,其特征在于,所述方法还包括:The method according to any one of claims 1-11, wherein the method further comprises:
    响应于检测到卸载所述第一应用程序的指令,所述电子设备从所述内部存储器中解锁所述第一内存页。In response to detecting the instruction to uninstall the first application program, the electronic device unlocks the first memory page from the internal memory.
  13. 根据权利要求12所述的方法,其特征在于,所述电子设备从所述内部存储器中解锁所述第一内存页,具体为:The method according to claim 12, wherein the electronic device unlocks the first memory page from the internal memory, specifically:
    所述电子设备从所述内部存储器的不可移除链表中移除所述第一内存页的内容。The electronic device removes the content of the first memory page from the non-removable linked list of the internal memory.
  14. 一种电子设备,其特征在于,包括:处理器、存储器和触摸屏,所述存储器、所述触摸屏与所述处理器耦合,所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,当所述处理器从所述存储器中读取所述计算机指令,以使得所述电子设备执行如权利要求1-13中任一项所述加速应用程序启动的方法。An electronic device, characterized by comprising: a processor, a memory, and a touch screen, the memory, the touch screen are coupled to the processor, the memory is used to store computer program code, the computer program code includes computer instructions , When the processor reads the computer instruction from the memory, so that the electronic device executes the method for accelerating application startup according to any one of claims 1-13.
  15. 一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在终端上运行时,使得所述终端执行如权利要求1-13中任一项所述加速应用程序启动的方法。A computer-readable storage medium, characterized by comprising computer instructions, when the computer instructions run on a terminal, cause the terminal to execute the method for accelerating the startup of an application program according to any one of claims 1-13 .
  16. 一种芯片系统,其特征在于,包括一个或多个处理器,当所述一个或多个处理器执行指令时,所述一个或多个处理器执行如权利要求1-13中任一项所述加速应用程序启动的方法。A chip system, characterized in that it includes one or more processors, and when the one or more processors execute instructions, the one or more processors execute as described in any one of claims 1-13. Describes the method of accelerating application startup.
PCT/CN2020/125814 2019-11-01 2020-11-02 Method for accelerating starting of application, and electronic device WO2021083378A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911061362.0 2019-11-01
CN201911061362.0A CN112783564B (en) 2019-11-01 2019-11-01 Method for accelerating starting of application program and electronic equipment

Publications (1)

Publication Number Publication Date
WO2021083378A1 true WO2021083378A1 (en) 2021-05-06

Family

ID=75715882

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/125814 WO2021083378A1 (en) 2019-11-01 2020-11-02 Method for accelerating starting of application, and electronic device

Country Status (2)

Country Link
CN (1) CN112783564B (en)
WO (1) WO2021083378A1 (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020486A (en) * 2021-10-08 2022-02-08 中国联合网络通信集团有限公司 Data generation method, device, equipment and storage medium
CN114168224A (en) * 2021-12-06 2022-03-11 杭州筑龙信息技术股份有限公司 Application program starting method and device, electronic equipment and storage medium
CN115202902A (en) * 2022-07-01 2022-10-18 荣耀终端有限公司 Method for controlling process interaction and related device
CN115729684A (en) * 2021-08-25 2023-03-03 荣耀终端有限公司 Input/output request processing method and electronic equipment
CN116049810A (en) * 2022-08-26 2023-05-02 荣耀终端有限公司 System starting method and electronic equipment
CN116069723A (en) * 2021-11-04 2023-05-05 荣耀终端有限公司 File migration method, electronic equipment and storage medium
WO2023198104A1 (en) * 2022-04-15 2023-10-19 华为技术有限公司 Asynchronous authorization method and system, electronic device, and computer-readable storage medium
CN116909474A (en) * 2022-04-12 2023-10-20 荣耀终端有限公司 Device identification method and related device
CN117130947A (en) * 2023-01-31 2023-11-28 荣耀终端有限公司 Memory management method and electronic equipment

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489469B (en) * 2021-07-20 2022-12-23 荣耀终端有限公司 Data reading method, electronic equipment and storage medium
CN114490442B (en) * 2021-08-27 2023-01-13 荣耀终端有限公司 File fragment adjusting method and electronic equipment
CN113901485B (en) * 2021-12-07 2022-05-10 展讯通信(天津)有限公司 Application program loading method, electronic device and storage medium
CN114185569B (en) * 2022-02-16 2022-06-24 荣耀终端有限公司 Application starting method and electronic equipment
CN115061743A (en) * 2022-06-08 2022-09-16 Oppo广东移动通信有限公司 Interface calling method and device, computer readable medium and electronic equipment
CN116743903B (en) * 2022-09-09 2024-05-14 荣耀终端有限公司 Chip identification method and electronic equipment
CN116684728B (en) * 2022-09-30 2024-03-05 荣耀终端有限公司 Method and device for controlling DTOF device
CN115481444B (en) * 2022-11-10 2023-03-31 荣耀终端有限公司 File protection method and electronic equipment
CN115858046B (en) * 2023-02-28 2023-07-21 荣耀终端有限公司 Method for preloading memory pages, electronic equipment and chip system
CN117112046B (en) * 2023-04-04 2024-05-10 荣耀终端有限公司 Application program starting method and electronic equipment
CN116665752B (en) * 2023-07-25 2023-11-21 成都佰维存储科技有限公司 UFS steady-state performance test method and device, readable storage medium and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080320209A1 (en) * 2000-01-06 2008-12-25 Super Talent Electronics, Inc. High Performance and Endurance Non-volatile Memory Based Storage Systems
CN103309740A (en) * 2013-06-05 2013-09-18 腾讯科技(深圳)有限公司 Program starting method, device and equipment
CN108762833A (en) * 2018-05-16 2018-11-06 北京安云世纪科技有限公司 Application in Android system starts method and apparatus

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6463509B1 (en) * 1999-01-26 2002-10-08 Motive Power, Inc. Preloading data in a cache memory according to user-specified preload criteria
CN102207881B (en) * 2011-07-07 2014-01-22 电子科技大学 Quick operation system start-up method based on Android
US10296508B2 (en) * 2013-06-06 2019-05-21 Sap Se Systems and methods to manage online analytical and transactional processing for an in-memory columnar database

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080320209A1 (en) * 2000-01-06 2008-12-25 Super Talent Electronics, Inc. High Performance and Endurance Non-volatile Memory Based Storage Systems
CN103309740A (en) * 2013-06-05 2013-09-18 腾讯科技(深圳)有限公司 Program starting method, device and equipment
CN108762833A (en) * 2018-05-16 2018-11-06 北京安云世纪科技有限公司 Application in Android system starts method and apparatus

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115729684B (en) * 2021-08-25 2023-09-19 荣耀终端有限公司 Input/output request processing method and electronic equipment
CN115729684A (en) * 2021-08-25 2023-03-03 荣耀终端有限公司 Input/output request processing method and electronic equipment
CN114020486A (en) * 2021-10-08 2022-02-08 中国联合网络通信集团有限公司 Data generation method, device, equipment and storage medium
CN116069723A (en) * 2021-11-04 2023-05-05 荣耀终端有限公司 File migration method, electronic equipment and storage medium
CN114168224A (en) * 2021-12-06 2022-03-11 杭州筑龙信息技术股份有限公司 Application program starting method and device, electronic equipment and storage medium
CN114168224B (en) * 2021-12-06 2024-02-20 杭州筑龙信息技术股份有限公司 Application program starting method and device, electronic equipment and storage medium
CN116909474A (en) * 2022-04-12 2023-10-20 荣耀终端有限公司 Device identification method and related device
WO2023198104A1 (en) * 2022-04-15 2023-10-19 华为技术有限公司 Asynchronous authorization method and system, electronic device, and computer-readable storage medium
CN115202902B (en) * 2022-07-01 2023-08-22 荣耀终端有限公司 Method for controlling process interaction and related device
CN115202902A (en) * 2022-07-01 2022-10-18 荣耀终端有限公司 Method for controlling process interaction and related device
CN116049810A (en) * 2022-08-26 2023-05-02 荣耀终端有限公司 System starting method and electronic equipment
CN116049810B (en) * 2022-08-26 2023-11-07 荣耀终端有限公司 System starting method and electronic equipment
CN117130947A (en) * 2023-01-31 2023-11-28 荣耀终端有限公司 Memory management method and electronic equipment

Also Published As

Publication number Publication date
CN112783564A (en) 2021-05-11
CN112783564B (en) 2023-03-03

Similar Documents

Publication Publication Date Title
WO2021083378A1 (en) Method for accelerating starting of application, and electronic device
WO2020103764A1 (en) Voice control method and electronic device
CN114443277A (en) Memory management method and device, electronic equipment and computer readable storage medium
WO2021159746A1 (en) File sharing method and system, and related device
WO2022267664A1 (en) Memory cold page processing method and electronic device
CN114461588B (en) Method for adjusting pre-reading window and electronic equipment
WO2021115112A1 (en) Installation package downloading method, installation package distribution method, terminal device, server, and system
WO2021253975A1 (en) Permission management method and apparatus for application, and electronic device
WO2021093626A1 (en) Memory management method and electronic device
WO2021185352A1 (en) Version upgrade method and related apparatus
CN113704205B (en) Log storage method, chip, electronic device and readable storage medium
CN113568634B (en) Processing method and processing device for application optimization
WO2022078105A1 (en) Memory management method, electronic device, and computer-readable storage medium
WO2021073337A1 (en) Method and apparatus for installing plug-in, and storage medium
WO2021104117A1 (en) Method for constructing application program resource packet, construction apparatus, and terminal device
WO2021238376A1 (en) Function pack loading method and apparatus, and server and electronic device
CN114461589B (en) Method for reading compressed file, file system and electronic equipment
CN114489469B (en) Data reading method, electronic equipment and storage medium
CN112783418B (en) Method for storing application program data and mobile terminal
CN113590346B (en) Method and electronic equipment for processing service request
CN114168115B (en) Communication system, application downloading method and device
CN116709609B (en) Message delivery method, electronic device and storage medium
WO2023036134A1 (en) Resource searching method and related apparatus
WO2023109569A1 (en) File storage method, file access method, electronic device, and storage medium
WO2022089206A1 (en) Management and control method and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20881730

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20881730

Country of ref document: EP

Kind code of ref document: A1