File preloading method, device, electronic device and readable storage medium
By preloading file data into memory on the first thread of the target process and loading data from memory by the second thread, the problem of loading files into memory for a long time by external storage is solved, and faster application startup time is achieved and improved User experience.
Patent Information
- Application Number
- CN202310763497.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-27
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2043-06-27
AI Technical Summary
Loading files from external memory to memory takes a long time, resulting in an extended application startup time and affecting the user experience.
By preloading file data into memory on the first thread of the target process and loading file data from memory by the second thread, the first thread and the second thread are realized to run in parallel, reducing the time for loading file data into memory from external storage.
It saves time to load file data from external storage to memory, reduces the startup time of the target application, and gives users a better user experience.
Smart Images

Figure CN116541102B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminals, and in particular to a file preloading method, device, electronic device and readable storage medium. Background Art
[0002] Memory reclamation refers to returning the releasable portion of the allocated space in memory to the memory management system for reallocation by the memory management system.
[0003] When an application is not used for a period of time, the memory occupied by the process file corresponding to the application will be reclaimed. When the application is started again, the process file corresponding to the application needs to be reloaded.
[0004] However, when loading a process file, the process file needs to be read from the Universal Flash Storage (UFS). Reading the process file from UFS takes a long time, which will extend the startup time of the application and affect the user experience. Summary of the invention
[0005] The present application provides a file preloading method, device, electronic device and readable storage medium. When preloading file data through a first thread, a first event is also executed through a second thread. Therefore, the time for loading file data from external storage to memory can be saved, and the problem that it takes a long time to read process files from UFS and prolongs the startup time of the application can be improved, giving users a better user experience.
[0006] In order to achieve the above objectives, this application adopts the following technical solutions:
[0007] In a first aspect, a file preloading method is provided, which is applied to an electronic device, comprising:
[0008] The target process responds to the first event, and obtains the file index corresponding to the first event through the first thread of the target process, wherein the file index includes the file name and the acquisition path of at least one file to be loaded. The file data of the file to be loaded indicated by the file index is preloaded into the memory through the first thread. The file data is obtained and loaded from the memory through the second thread of the target process to complete the first event, and the first thread and the second thread run in parallel.
[0009] In an embodiment of the present application, the file preloading method is applied to electronic devices, and the electronic devices may include mobile phones, tablet computers, handheld game consoles, wearable devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc.
[0010] In the first aspect, when a first event occurs, the file data required to complete the first event is preloaded into the memory through the first thread, and the file data is read and loaded from the memory through the second thread to complete the first event. The first thread and the second thread run in parallel, that is, when the file data is preloaded through the first thread, the first event is also executed through the second thread. Therefore, the time for loading file data from external storage to the memory can be saved, thereby reducing the startup time of the target application and providing users with a better user experience.
[0011] In some possible implementations, the file index also includes a historical access record of the file to be loaded, and the historical access record is used to indicate the segments in the file to be loaded that have been loaded;
[0012] Preloading file data of a to-be-loaded file indicated by a file index into a memory through a first thread of a target process includes: determining a to-be-loaded segment in the to-be-loaded file through the first thread according to a historical access record of the file in the file index; and preloading the to-be-loaded segment into a memory.
[0013] In some possible implementations, the first event includes at least one process node;
[0014] The first event is completed by obtaining and loading the file data from the memory through the second thread of the target process, including:
[0015] The second thread determines the file to be loaded corresponding to the current process node;
[0016] The second thread obtains the file data of the file to be loaded from the memory and loads the file data, completing the first event.
[0017] In some possible implementations, the second thread obtains the file data of the file to be loaded from the memory and loads the file data, including:
[0018] When it is determined that the file to be loaded in the memory is incomplete, the file data of the missing file to be loaded is preloaded from the storage to the memory through the second thread; the second thread obtains the file data of the file to be loaded from the memory and loads the file data.
[0019] In some possible implementations, after the file data of the missing file to be loaded is loaded from the storage to the memory by the second thread, the method further includes: updating the file index corresponding to the first event according to the missing file to be loaded by the first thread.
[0020] In some possible implementations, the first event includes at least one process node;
[0021] Before the target process responds to the first event and obtains the file index corresponding to the first event, the method further includes:
[0022] The target process responds to the first event, and determines the file to be loaded corresponding to the current process node at each process node through the second thread; preloads the file data of the file to be loaded from the storage to the memory through the second thread; obtains the file data from the memory and loads the file data through the second thread to complete the first event; generates a file index corresponding to the first event according to the file data loaded into the memory through the first thread.
[0023] In a second aspect, a file preloading device is provided, which is applied to an electronic device, and includes:
[0024] An acquisition module, configured to respond to a first event and acquire a file index corresponding to the first event through a first thread of the target process, wherein the file index includes a file name and an acquisition path of at least one file to be loaded;
[0025] A loading module, used for preloading file data of the file to be loaded indicated by the file index into the memory through the first thread;
[0026] A processing module is used to obtain and load the file data from the memory through the second thread of the target process to complete the first event, and the first thread and the second thread run in parallel.
[0027] In some possible implementations, the file index also includes a historical access record of the file to be loaded, and the historical access record is used to indicate the segments in the file to be loaded that have been loaded;
[0028] The loading module is specifically used to determine the to-be-loaded segments in the to-be-loaded file through the first thread according to the historical access records of the file in the file index; and preload the to-be-loaded segments into the memory.
[0029] In some possible implementations, the first event includes at least one process node;
[0030] A processing module, specifically used by the second thread to determine the file to be loaded corresponding to the current process node;
[0031] The second thread obtains the file data of the file to be loaded from the memory and loads the file data, completing the first event.
[0032] In some possible implementations, the loading module is specifically used to preload the missing file data of the file to be loaded from the storage to the memory through the second thread when it is determined that the file to be loaded in the memory is incomplete; the second thread obtains the file data of the file to be loaded from the memory and loads the file data.
[0033] In some possible implementations, the device further includes an updating module, configured to update, through the first thread, a file index corresponding to the first event according to the missing file to be loaded.
[0034] In some possible implementations, the first event includes at least one process node;
[0035] A processing module, configured to respond to the first event and determine, at each process node, a file to be loaded corresponding to the current process node through a second thread;
[0036] A loading module, used for preloading file data of a to-be-loaded file from a storage device to a memory through a second thread;
[0037] The processing module is further used to obtain the file data from the memory and load the file data through the second thread to complete the first event;
[0038] The device also includes a generating module, which is used to generate a file index corresponding to the first event according to the file data loaded into the memory through the first thread.
[0039] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of processing in the first aspect or any one of the methods in the first aspect when executing the computer program.
[0040] In a fourth aspect, a chip is provided, comprising: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes the steps of processing in the first aspect or any one of the methods in the first aspect.
[0041] In a fifth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the steps of processing in the first aspect or any one of the methods in the first aspect.
[0042] In a sixth aspect, a computer program product is provided, the computer program product comprising: a computer program code, when the computer program code is executed by an electronic device, the electronic device executes the steps of processing in the first aspect or any one of the methods in the first aspect.
[0043] Among them, the beneficial effects of the second to sixth aspects can refer to the first aspect and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a schematic diagram of an application scenario of a file preloading method provided in an embodiment of the present application;
[0045] Figure 2 It is a hardware structure block diagram of an electronic device provided in an embodiment of the present application;
[0046] Figure 3 It is a software structure block diagram of an electronic device provided in an embodiment of the present application;
[0047] Figure 4 It is a flowchart of a file preloading method provided in an embodiment of the present application;
[0048] Figure 5 It is a schematic diagram of the data structure of a file index in a file preloading method provided in an embodiment of the present application;
[0049] Figure 6 It is a schematic diagram of preloading file data into a memory in a file preloading method provided in an embodiment of the present application;
[0050] Figure 7 It is a schematic diagram of a process of generating a file index in a file preloading method provided in an embodiment of the present application;
[0051] Figure 8 It is a flowchart of a file preloading method provided in an embodiment of the present application applied to a camera application;
[0052] Fig. 9 It is a structural block diagram of a file preloading device provided in an embodiment of the present application;
[0053] Fig.10 It is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0055] 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 article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0056] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0057] The memory of an electronic device is used to temporarily store the computational data in the processor and to store data loaded from an external memory (such as UFS). It is the medium for data exchange between the external memory and the processor. The running data of all applications in the electronic device needs to be processed in the memory. The strength of the memory performance and the size of the remaining memory space will affect the overall performance of the electronic device.
[0058] Memory recycling is a mechanism that returns the releasable portion of the allocated memory space to the memory management system, which then reallocates it. Memory recycling can release the memory occupied by inactive applications and provide it to active applications, thus improving the performance of electronic devices.
[0059] As an example, for an Android system, the memory management system may be a buddy system. For example, when a target application is not used for a period of time, the memory space occupied by the target application and the native process corresponding to the target application will be released for use by other active applications.
[0060] When the memory space occupied by the process file corresponding to the target application is released, when the target application is started again, the process file corresponding to the target application needs to be reloaded from the external memory to the internal memory.
[0061] For example, if the target application is a camera application, the native process corresponding to the camera application is "Camera Hal". When the CameraHal process is started, there are multiple process nodes. At each process node, the file data corresponding to the process node needs to be loaded. Therefore, at each process node, the Camera Hal process will access the memory to load the corresponding file data.
[0062] When the corresponding file data does not exist in the memory, Camera Hal will apply to load the required file data from UFS into the memory, and then load the corresponding file data from the memory.
[0063] However, loading files from UFS to memory takes a long time, which will prolong the startup time of the target application and affect the user experience. Currently, there is a solution that guarantees the startup speed of the target application by specifying that the memory occupied by the target application will not be recycled. However, this solution will lead to a waste of memory resources and cannot be fully utilized.
[0064] In view of this, the present application provides a file preloading method, which is applied to an electronic device, comprising:
[0065] The target process responds to the first event and obtains a file index corresponding to the first event, wherein the file index includes at least one file name and an acquisition path of a file to be loaded. The file data of the file to be loaded indicated by the file index is preloaded into the memory through the first thread of the target process. The file data is obtained and loaded from the memory through the second thread of the target process to complete the first event, and the first thread and the second thread run in parallel.
[0066] In the present application, when a first event occurs, the file data required to complete the first event is preloaded into the memory through the first thread, and the file data is read and loaded from the memory through the second thread to complete the first event. Since the first thread and the second thread run in parallel, that is, when the file data is preloaded through the first thread, the first event is also executed through the second thread. Therefore, the time for loading file data from external storage to the memory can be saved, thereby reducing the startup time of the target application and giving users a better user experience.
[0067] First, the application scenarios of the embodiments of the present application are briefly described.
[0068] Figure 1 It is a schematic diagram of an application scenario of a file preloading method provided in an embodiment of the present application.
[0069] refer to Figure 1 , which includes an electronic device 100.
[0070] In one possible scenario, refer to Figure 1, the electronic device 100 is in a locked screen state, and the electronic device responds to a sliding operation on the camera icon to start the camera application. In this scenario, the first event is a sliding operation on the camera icon, that is, a start event of the camera application. After the first event occurs, Camera Hal can preload the file data required for the start event into the memory through the first thread. In this case, Camera Hal can also execute multiple process nodes corresponding to the start event in parallel through the second thread. Since the file data required for each process node has been preloaded into the memory through the first thread, the second thread can directly load the file data from the memory at each process node, thereby completing the start event.
[0071] Figure 2 It is a hardware structure block diagram of an electronic device provided in an embodiment of the present application.
[0072] The electronic device may include a mobile phone, a tablet computer, a handheld game console, a wearable device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific type of the electronic device.
[0073] refer to Figure 2 The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a 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 light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0074] It is to 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 in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0075] For example, when the electronic device 100 is a mobile phone or a tablet computer, it may include all the components shown in the figure, or may include only some of the components shown in the figure.
[0076] 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 processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0077] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0078] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0079] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0080] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0081] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0082] 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 number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0083] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0084] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0085] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the electronic device 100 .
[0086] The modulation and demodulation processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
[0087] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0088] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to 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), 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. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0089] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects 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 that execute program instructions to generate or change display information.
[0090] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0091] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0092] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0093] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0094] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0095] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0096] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. 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 disk storage device, a flash memory device, a universal flash storage (UFS), etc. 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.
[0097] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0098] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0099] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0100] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0101] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0102] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0103] The pressure sensor 180A is used to sense pressure signals and convert the pressure signals into electrical signals.
[0104] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking 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.
[0105] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
[0106] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.
[0107] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all 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 the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0108] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
[0109] 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 outward 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 pocket mode to automatically unlock and lock the screen.
[0110] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. 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 a pocket to prevent accidental touches.
[0111] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0112] 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, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J 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 other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
[0113] In an embodiment of the present application, the temperature sensor 180J may include multiple ones for detecting the temperatures at different positions of the electronic device 100, such as being set near the processor to obtain the temperature of the processor, being set near the battery to obtain the temperature of the battery, or being set on the inside of the outer casing of the electronic device 100 to obtain the temperature of the outer casing of the electronic device 100.
[0114] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control 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. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0115] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. 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.
[0116] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0117] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power changes, messages, missed calls, notifications, etc.
[0118] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 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 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0119] for Figure 1 In the scenario, the operating system of the electronic device 100 may include, but is not limited to, Symbian, Android, Windows, MacOS, iOS, Blackberry, HarmonyOS, etc. This application does not impose any limitation on the operating system of the electronic device.
[0120] Figure 3 It is a software structure block diagram of an electronic device provided in an embodiment of the present application.
[0121] As an example, when the operating system of the electronic device 100 is Android, its software structure can refer to Figure 3 .
[0122] Among them, the layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer.
[0123] The application layer can include a series of application packages.
[0124] like Figure 3 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0125] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0126] like Figure 3 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0127] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0128] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0129] The view system includes visual controls, such as controls for displaying characters, controls for displaying pictures, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text message notification icon can include a view for displaying characters and a view for displaying pictures.
[0130] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
[0131] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0132] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0133] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0134] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0135] 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.
[0136] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0137] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0138] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0139] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing, etc.
[0140] A 2D graphics engine is a drawing engine for 2D drawings.
[0141] 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.
[0142] Figure 4 It is a flowchart of a file preloading method provided in an embodiment of the present application.
[0143] In this application, the application is a camera application and the background process is Camera Hal. In practical applications, the file preloading method provided by this application can also be applied to other applications, and this application does not limit this.
[0144] refer to Figure 4 , file preloading methods include:
[0145] S401: receiving an operation instruction, the application program requests a background process to respond to a first event.
[0146] In some possible implementations, the operation instruction may be a touch operation, a voice instruction, or a gesture operation received by the electronic device.
[0147] As an example, the operation instruction may be a click operation on the application icon area displayed on the electronic device screen, and the first event is the application startup event. Alternatively, the operation instruction may also be a voice instruction to start the application, and the first event is the application startup event. Alternatively, for the camera application, the operation instruction may also be to recognize a smiling face. When a smiling face is recognized, it may trigger the camera application's photo event, and the first event is the camera application's photo event, and the background process is Camera Hal.
[0148] S402: The first thread of the background process responds to a first event and obtains a file index corresponding to the first event.
[0149] In some possible implementations, the first thread may also be referred to as a preloading thread, which is used to preload file data required to complete the first event according to a file index corresponding to the first event.
[0150] In some possible implementations, the file index corresponding to the first event includes the file name corresponding to the file data loaded when the first event was completed at the historical moment and the acquisition path of the file. That is, the index file records the file name of the file loaded when the first event was completed at the historical moment.
[0151] For example, if the first event is a startup event of a camera application, the file name of the file to be loaded in the file index corresponding to the startup event may include the file name of the native process base library file of the camera application, such as "libc++_shared.so" and "libllvm-camx.so"; it may also include the file name of the preview algorithm engine library file "libarcsoft_agegender.so", the file name of the file that implements the fast capture function "libfastcvopt.so", the file name of the file that implements the beauty shot function "libarcsoft_beautyshot.so", etc.
[0152] In other examples, the first event is a photo event of a camera application, then the file names of the files to be loaded in the file index corresponding to the photo event may include the file name "libsit_core.so" of the photo algorithm engine library file, the file name "libcamera_facefeature.so" of the file that implements the portrait capture function, the file name "libHnFaceDetection.so" of the file that implements the face detection function, and the file name "libarcsoft_skinanalysis.so" of the file that implements the skin beautification function, etc.
[0153] In some other examples, the first event is a recording event of a camera application. The file names of the files to be loaded in the file index corresponding to the recording event may include the file name of the recording mode library file "libcam_video_optical_zoom.so", the file name of the artificial intelligence (AI) capture algorithm library file "libhonor_ai_capture.so", the file name of the single recording mode algorithm library file "libsinglecamvideomode.so", the file name of the multi-lens recording mode algorithm library file "libmulticamvideomode.so" and the file name of the neural network inference algorithm library file "libSNPE.so", etc.
[0154] In some other possible implementations, it is not necessary to completely load the file data of the entire file to complete the first event, but only necessary to load a plurality of fragments thereof.
[0155] In this case, the file index corresponding to the first event may also include the file name corresponding to the loaded file data when the first event is completed at the historical moment, the identifier of the segment corresponding to the file name, and the acquisition path of the file.
[0156] Figure 5 It is a data structure diagram of a file index in a file preloading method provided in an embodiment of the present application.
[0157] As an example, refer to Figure 5 , wherein the first event is a start event of the camera application, that is, the index type of the index file is: camera / start.
[0158] refer to Figure 5 ,The file index includes file names (file 1, file 2, file 3 to file M), and each file name corresponds to the identifiers of multiple fragments.
[0159] For example, file 1 corresponds to fragment 0, fragment 2 to fragment a;
[0160] File 2 corresponds to segments 1, 2, 5 to b;
[0161] File 3 corresponds to segments 4, 8 to c;
[0162] File M corresponds to segments 7, 9, 34 to d.
[0163] The file names and corresponding fragments in the index file are used to record the fragments of the files loaded when the first event is completed at the historical moment.
[0164] That is, when the first event was completed at the historical moment, fragments 0, 2 to a of file 1 were loaded; fragments 1, 2, 5 to b of file 2 were loaded; fragments 4, 8 to c of file 3 were loaded; and fragments 7, 9, 34 to d of file M were loaded.
[0165] S403: The first thread preloads file data of the to-be-loaded file indicated by the file index into the memory.
[0166] Figure 6 It is a schematic diagram of preloading file data into memory in a file preloading method provided in an embodiment of the present application.
[0167] In some possible implementations, reference is made to Figure 6 After the first thread accesses the file index, the file data may be loaded sequentially according to the file name indicated by the file index. For example, the file data corresponding to file 0 may be loaded into multiple pages of the physical memory first, and then the file data corresponding to file 1 may be loaded into multiple pages of the physical memory.
[0168] Here, the loading process is described by taking the loading of file data corresponding to file 1 into multiple pages of physical memory as an example, wherein the storage space of each physical memory page may be 4KB, and the data volume of the file data corresponding to each fragment may also be 4KB.
[0169] refer to Figure 5 and Figure 6 , the file index indicates that when the first event was completed at the historical moment, the file 1 fragments 0, 2 to a were loaded, a total of k fragments. Then the first thread can first obtain the file data of file 1 from UFS according to the acquisition path of file 1. Among them, file 1 can be stored in the form of 4K fragments to facilitate loading into the memory.
[0170] Then, file data 0, file data 2 to file data a corresponding to file 1 fragment 0, fragment 2 to fragment a are preloaded into physical memory page 0, physical memory page 1 to physical memory page k respectively.
[0171] S404: The second thread of the background process responds to the first event and obtains at least one process node of the first event.
[0172] In some possible implementations, the second thread may also be referred to as a service thread, which is used to actually complete the service corresponding to the first service event.
[0173] In some possible implementations, multiple process nodes may be required to complete the first event. Each process node needs to load the corresponding file data to execute the corresponding function according to the code in the file data. The process nodes of the first event can be pre-set. For example, for the startup event of the camera application, the process nodes may include loading the local process library, loading the preview algorithm engine library, and loading some default startup functions.
[0174] For the photo-taking event of the camera application, the process nodes may include loading the photo-taking algorithm engine library, loading the portrait capture function, loading the face detection function, loading the skin beautification function, etc.
[0175] For the recording events of the camera application, the process nodes may include loading the recording mode library, loading the AI capture algorithm library, loading the single recording mode algorithm library, loading the multi-lens recording mode algorithm library, and loading the neural network inference algorithm library.
[0176] S405: The second thread determines the file to be loaded corresponding to the current process node.
[0177] In some possible implementations, the file to be loaded corresponding to the current process node is a file corresponding to the function to be implemented by the process node.
[0178] As an example, for a camera application startup event, a local process needs to be loaded first at startup, so the process node may be loading a local process, and the corresponding file to be loaded is a local process basic library file.
[0179] In some possible implementations, the file to be loaded corresponding to the process node may be a complete file corresponding to the process node, or a partial file may be loaded according to a preset default function.
[0180] As an example, for the photo event of the camera application, the process node is to load the skin beautification function, wherein the skin beautification function may include a face-slimming function, a skin-grinding function, a whitening function, and the like. Then the file to be loaded may include the code corresponding to the face-slimming function, the code corresponding to the skin-grinding function, the code corresponding to the whitening function, and the like. Among them, the code corresponding to the face-slimming function, the code corresponding to the skin-grinding function, or the code corresponding to the whitening function may be recorded in the form of fragments in the file that implements the skin beautification function. When no default function is pre-set, the node that loads the skin beautification function may load the entire file that implements the skin beautification function. When the pre-set default functions are the face-slimming function and the skin-grinding function, the node that loads the skin beautification function may only load the code corresponding to the face-slimming function and the code corresponding to the skin-grinding function in the file that implements the skin beautification function.
[0181] S406: When it is determined that the file to be loaded in the memory is incomplete, the second thread preloads the missing file data of the file to be loaded from the storage device to the memory.
[0182] In some possible implementations, when at a process node, the second thread obtains file data of the file to be loaded from the memory. If a page fault occurs when the second thread accesses the virtual address corresponding to the memory, it indicates that the required file data does not exist in the memory, that is, it is determined that the file to be loaded is incomplete.
[0183] Taking the process node of loading the beauty function of the photo event as an example, the photo event that occurred at a historical moment may only have the face-slimming function and skin-smoothing function turned on, but not the whitening function. Since the file data corresponding to the whitening function is not loaded, the files and fragments corresponding to the whitening function will be missing when the file index is generated. When the first thread preloads the file data according to the file index, the file data corresponding to the whitening function will be missing, and the second thread cannot directly obtain the file data corresponding to the whitening function from the memory.
[0184] In this case, the second thread can load the missing file data to be loaded from the storage to the memory. The second thread loads the file data in a similar manner to the first thread in S403, which will not be described in detail here.
[0185] When the file data preloaded into the memory is incomplete, the missing file data can be obtained through the second thread to ensure that the first event is processed first. At the same time, since the amount of missing file data is often small, the processing speed of the first event will be less affected by obtaining the missing file data through the second thread, and will not significantly affect the processing speed of the first event.
[0186] S407: The second thread obtains file data of the file to be loaded from the memory and loads the file data.
[0187] For some possible implementations, refer to Figure 6 , the second thread accesses the virtual address corresponding to the file to be loaded in the memory, and obtains and loads the corresponding file data according to the virtual address.
[0188] S408: The second thread loads the to-be-loaded file corresponding to each process node, completing the first event.
[0189] In some possible implementations, when all files corresponding to a process node are loaded, the process node ends, and the second thread continues to process the next process node. When the second thread finishes processing all process nodes, the first event is completed.
[0190] S409: The first thread updates the file index corresponding to the first event according to the missing file to be loaded.
[0191] In some possible implementations, when S406 occurs, the first thread may also add the file name corresponding to the file data obtained by the second thread, the identifier of the segment corresponding to the file name, and the file acquisition path to the file index, and store the updated file index.
[0192] According to the missing files to be loaded, updating the file index corresponding to the first event can improve the accuracy of preloading files according to the file index next time, preloading files is more accurate, improving the processing speed of the first event and giving users a better experience.
[0193] In this embodiment, S402, S403, and S409 are implemented by the first thread, and S404-S408 are implemented by the second thread, and the first thread and the second thread run in parallel. When the first event occurs, the file data required to complete the first event is preloaded into the memory by the first thread, and the file data is read and loaded from the memory by the second thread to complete the first event. Since the first thread and the second thread run in parallel, preloading the file data by the first thread can save the time of loading the file from the UFS to the memory, thereby reducing the startup time of the target application and giving the user a better user experience.
[0194] In some possible implementations, the file index corresponding to the first event may be generated by the first thread when the first event is completed at a historical moment, or may be obtained from the cloud according to the type of the first event.
[0195] Figure 7 It is a flowchart of generating a file index in a file preloading method provided in an embodiment of the present application.
[0196] As an example, refer to Figure 7 When the first event is completed at a historical moment, generating a file index corresponding to the first event through a first thread may include:
[0197] S701: The application receives an operation instruction and requests a background process to respond to a first event.
[0198] S702: The second thread of the background process responds to the first event and obtains at least one process node of the first event.
[0199] S703: The second thread determines the file to be loaded corresponding to the current process node.
[0200] S704: The second thread preloads the file data of the to-be-loaded file from the storage device to the memory.
[0201] S705: The second thread obtains file data of the file to be loaded from the memory and loads the file data.
[0202] S706: The second thread loads the to-be-loaded file corresponding to each process node, completing the first event.
[0203] In this embodiment, the implementation of S701 to S706 may refer to S404 to S408 and will not be described in detail here.
[0204] S707: The first thread generates a file index corresponding to the first event according to the file data loaded into the memory.
[0205] In some implementations, the data structure of the file index may refer to Figure 5 It should be noted that the file index corresponding to the generated first event can be stored in UFS, for example, can be stored in the system partition of the electronic device.
[0206] After the electronic device is turned on, when the background process corresponding to the first event is started, the file index is loaded into the memory through the background process. When the first thread obtains the file index, it can be directly read from the memory.
[0207] In some implementations, the file index may be permanently stored in memory for easy access at any time.
[0208] In some implementations, the generated file index can also be uploaded to the cloud and aggregated according to the type of the first event. The cloud can merge the file indexes uploaded by the same model of electronic devices to obtain a more accurate file index. In this case, the electronic device can update the locally stored file index of the first event based on the file index of the first event stored on the cloud at a preset time interval to improve the accuracy of preloading and reduce the probability of incomplete files to be loaded in the memory.
[0209] Figure 8 1 is a flowchart of a file preloading method provided in an embodiment of the present application applied to a camera application. Figure 8 , taking the camera application as an example, the actual application process of the file preloading method is explained.
[0210] As an example, the background process corresponding to the camera application is Camera Hal. When the received operation instruction instructs the camera application to start, the camera application calls Camera Hal to execute the startup event of the camera application. The first thread of Camera Hal responds to the startup event, obtains the file index corresponding to the startup event, and preloads the file data of the file to be loaded indicated by the file index into the memory. The second thread of Camera Hal responds to the startup event, obtains the startup event process node, and then loads the file data corresponding to each process node from the memory in turn to complete the startup event. The startup event of the camera application is completed.
[0211] When the received operation instruction instructs the camera application to switch to the photo function, Camera Hal executes the photo event of the camera application. The first thread of Camera Hal responds to the photo event, obtains the file index corresponding to the photo event, and preloads the file data of the file to be loaded indicated by the file index into the memory. The second thread of Camera Hal responds to the photo event, obtains the photo event process node, and then loads the file data corresponding to each process node from the memory in sequence to complete the photo event. The photo event of the camera application is completed.
[0212] When the received operation instruction instructs the camera application to switch to the video recording function, Camera Hal executes the video recording event of the camera application. The first thread of Camera Hal responds to the video recording event, obtains the file index corresponding to the video recording event, and preloads the file data of the file to be loaded indicated by the file index into the memory. The second thread of Camera Hal responds to the video recording event, obtains the video recording event process node, and then loads the file data corresponding to each process node from the memory in sequence to complete the video recording event. The video recording event of the camera application is completed.
[0213] It should be noted that if the camera application is started and the photo-taking function is turned on by default, the operation of instructing the camera application to start can trigger the camera application startup event and the camera application photo-taking event. After the camera application startup event is completed, the camera application photo-taking event is automatically executed.
[0214] It should be understood that the above examples are intended to help those skilled in the art understand the embodiments of the present application, rather than to limit the embodiments of the present application to the specific numerical values or specific scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of the present application.
[0215] Corresponding to the file preloading method provided in the above embodiment, Fig. 9 This is a structural block diagram of a file preloading device provided in an embodiment of the present application. For the sake of convenience of explanation, only the parts related to the embodiment of the present application are shown.
[0216] Reference Fig. 9 , a file preloading device, applied to an electronic device, comprising:
[0217] An acquisition module 91 is used to respond to a first event and acquire a file index corresponding to the first event through a first thread of the target process, wherein the file index includes a file name and an acquisition path of at least one file to be loaded;
[0218] A loading module 92, configured to preload file data of the file to be loaded indicated by the file index into the memory through the first thread;
[0219] The processing module 93 is used to obtain and load the file data from the memory through the second thread of the target process to complete the first event, and the first thread and the second thread run in parallel.
[0220] In some possible implementations, the file index also includes a historical access record of the file to be loaded, and the historical access record is used to indicate the segments in the file to be loaded that have been loaded;
[0221] The loading module 92 is specifically configured to determine the to-be-loaded segments in the to-be-loaded file through the first thread according to the historical access records of the files in the file index; and preload the to-be-loaded segments into the memory.
[0222] In some possible implementations, the first event includes at least one process node;
[0223] Processing module 93, specifically used for the second thread to determine the file to be loaded corresponding to the current process node;
[0224] The second thread obtains the file data of the file to be loaded from the memory and loads the file data, completing the first event.
[0225] In some possible implementations, the loading module 92 is specifically used to preload the missing file data of the file to be loaded from the storage to the memory through the second thread when it is determined that the file to be loaded in the memory is incomplete; the second thread obtains the file data of the file to be loaded from the memory and loads the file data.
[0226] In some possible implementations, the device further includes an updating module 94, configured to update a file index corresponding to the first event according to the missing files to be loaded through the first thread.
[0227] In some possible implementations, the first event includes at least one process node;
[0228] A processing module 93, configured to respond to the first event and determine, at each process node, a file to be loaded corresponding to the current process node through a second thread;
[0229] A loading module 92, configured to preload file data of a file to be loaded from the storage to the memory through a second thread;
[0230] The processing module 93 is further used to obtain the file data from the memory and load the file data through the second thread to complete the first event;
[0231] The device also includes a generating module 95, which is used to generate a file index corresponding to the first event according to the file data loaded into the memory through the first thread.
[0232] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0233] It can be clearly understood by those skilled in the art that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units. For example, a "module" can be a software program, a hardware circuit, or a combination of the two to implement the above-mentioned functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a merged logic circuit, and / or other suitable components that support the described functions.
[0234] Therefore, the modules of each example described in the embodiments of the present application can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0235] In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other and are not used to limit the protection scope of this application. The specific working process of the units and modules in the above system can refer to the corresponding process in the above method embodiment, which will not be repeated here.
[0236] It should be understood that the hardware systems, devices and chips in the embodiments of the present application can execute the various file preloading methods in the aforementioned embodiments of the present application, that is, the specific working processes of the following various products can refer to the corresponding processes in the aforementioned method embodiments.
[0237] An embodiment of the present application also provides another electronic device, including a sensor, a processor, and a memory.
[0238] Sensors are used to obtain temperatures, such as the case temperature of electronic equipment and the ambient temperature.
[0239] Memory is used to store computer programs that can be executed on the processor.
[0240] The processor is used to execute the processing steps in the file preloading method as described above.
[0241] The embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored; when the computer-readable storage medium is run on a file preloading device, the file preloading device executes the method as shown above. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that can be integrated with one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium, or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0242] The embodiment of the present application also provides a computer program product including computer instructions, which, when executed on a file preloading device, enables the file preloading device to execute the technical solution shown above.
[0243] Fig.10 It is a schematic diagram of the structure of a chip provided in an embodiment of the present application. Fig.10 The chip shown can be a general-purpose processor or a dedicated processor. The chip includes a processor 1001. The processor 1001 is used to support the file preloading device to execute the technical solution shown above.
[0244] Optionally, the chip further includes a transceiver 1002, and the transceiver 1002 is used to accept the control of the processor 1001 and to support the communication device to execute the technical solution shown above.
[0245] Optional, Fig.10 The chip shown may also include: a storage medium 1003 .
[0246] It should be noted that Fig.10The chip shown can be implemented using the following circuits or devices: one or more field programmable gate arrays (FPGAs), programmable logic devices (PLDs), controllers, state machines, gate logic, discrete hardware components, any other suitable circuits, or any combination of circuits that can perform the various functions described throughout this application.
[0247] The electronic device, file preloading device, computer storage medium, computer program product, and chip provided in the above-mentioned embodiments of the present application are all used to execute the method provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding beneficial effects of the method provided above, and will not be repeated here.
[0248] It should be understood that the above is only to help those skilled in the art to better understand the embodiments of the present application, rather than to limit the scope of the embodiments of the present application. According to the above examples given, those skilled in the art can obviously make various equivalent modifications or changes. For example, some steps in each embodiment of the above detection method may be unnecessary, or some steps may be newly added. Or a combination of any two or any multiple embodiments of the above. Such modifications, changes or combined schemes also fall within the scope of the embodiments of the present application.
[0249] It should also be understood that the above description of the embodiments of the present application focuses on emphasizing the differences between the various embodiments. The same or similar points that are not mentioned can be referenced to each other. For the sake of brevity, they will not be repeated here.
[0250] It should also be understood that the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0251] It should also be understood that in the embodiments of the present application, "pre-setting" and "pre-definition" can be achieved by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including an electronic device), and the present application does not limit its specific implementation method.
[0252] It should also be understood that the division of the methods, situations, categories and embodiments in the embodiments of the present application is only for the convenience of description and should not constitute a special limitation. The features of various methods, categories, situations and embodiments can be combined without contradiction.
[0253] It should also be understood that in the various embodiments of the present application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form new embodiments according to their internal logical relationships.
[0254] Finally, it should be noted that the above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A file preloading method, characterized in that: The method is applied to an electronic device, comprising: The target process responds to a first event, and obtains a file index corresponding to the first event through a first thread of the target process, wherein the file index includes a file name and an acquisition path of at least one file to be loaded, and the first event includes at least one process node, and the first event includes a photo taking event or a video recording event of a camera application; Preloading file data of the to-be-loaded file indicated by the file index into the memory through the first thread; Determine the file to be loaded corresponding to the current process node through the second thread of the target process; When it is determined that the file to be loaded in the memory is incomplete, preloading the missing file data of the file to be loaded from the storage to the memory through the second thread; updating, by the first thread, a file index corresponding to the first event according to the missing file to be loaded; The second thread obtains the file data of the file to be loaded from the memory and loads the file data to complete the first event, and the first thread and the second thread run in parallel.
2. The method according to claim 1, characterized in that The file index also includes a historical access record of the file to be loaded, where the historical access record is used to indicate the segments that have been loaded in the file to be loaded; Preloading file data of the to-be-loaded file indicated by the file index into the memory through the first thread of the target process includes: Determining, by the first thread, a to-be-loaded segment in the to-be-loaded file according to a historical access record of the file in the file index; Preload the to-be-loaded segment into the memory.
3. The method according to claim 1 or 2, characterized in that: The first event includes at least one process node; Before the target process responds to the first event and obtains the file index corresponding to the first event, the method further includes: The target process responds to the first event and determines, at each process node, the file to be loaded corresponding to the current process node through the second thread; Preloading the file data of the to-be-loaded file from the storage device to the memory through the second thread; Obtaining the file data from the memory and loading the file data through the second thread, thereby completing the first event; The file index corresponding to the first event is generated by the first thread according to the file data loaded into the memory.
4. A file preloading device, characterized in that: The device is applied to electronic equipment, including: an acquisition module, configured to respond to a first event, and acquire a file index corresponding to the first event through a first thread of a target process, wherein the file index includes a file name and an acquisition path of at least one file to be loaded, wherein the first event includes at least one process node, and wherein the first event includes a photo taking event or a video recording event of a camera application; A loading module, used for preloading file data of the file to be loaded indicated by the file index into the memory through the first thread; A processing module, configured to determine the file to be loaded corresponding to the current process node through the second thread of the target process; When it is determined that the file to be loaded in the memory is incomplete, preloading the missing file data of the file to be loaded from the storage to the memory through the second thread; An updating module, configured to update a file index corresponding to the first event according to the missing file to be loaded through the first thread; The second thread obtains the file data of the file to be loaded from the memory and loads the file data to complete the first event; the first thread and the second thread run in parallel.
5. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 3 when executing the computer program.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the file preloading method according to any one of claims 1 to 3.
7. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is executed by an electronic device, the electronic device executes the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Method and device for accelerating starting of computer operating system
CN103810009A
Application program starting method, mobile terminal and computer storage medium
CN108536481A
Data processing method and device, electronic equipment and readable storage medium
CN112434092A
Application starting method and electronic equipment
CN112527403A
Application program loading method and device, storage medium and terminal
CN113849195A
