Information acquisition method, electronic device, and chip system

By introducing a caching mechanism into electronic devices, the problem of uninterruptible thread sleep caused by kernel memory lock contention is solved, achieving fast response and efficient CPU utilization, thus improving user experience and performance.

CN122285192APending Publication Date: 2026-06-26HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-12-26
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In electronic devices, contention for kernel memory locks can cause threads to enter an uninterruptible sleep state, resulting in sluggish response times and impacting user experience and performance.

Method used

By introducing a caching mechanism into electronic devices, threads can read memory usage information of critical processes without holding kernel memory locks, and instead use cached information to read the information, thus avoiding the stuttering and performance issues caused by holding kernel memory locks.

Benefits of technology

It improves the response speed of electronic devices during user interaction, avoids lag, makes full use of CPU computing power, and enhances user experience and device performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122285192A_ABST
    Figure CN122285192A_ABST
Patent Text Reader

Abstract

This application provides an information acquisition method, an electronic device, and a chip system, relating to the field of electronic device technology. This method can prevent lag in electronic devices and improve user experience. Specifically, the electronic device acquires a first request, which instructs a first thread to read the memory usage information of a first process. When the electronic device is in a user interaction scenario, and the first process is included in a set of first processes, and the memory usage information of the first process is not being read for the first time, the first thread reads the memory usage information of the first process from a first storage area of ​​the electronic device, so that the first thread obtains the memory usage information of the first process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic device technology, and in particular to an information acquisition method, electronic device, and chip system. Background Technology

[0002] During the execution of threads on an electronic device, contention for kernel memory locks can easily cause threads to enter an uninterruptible sleep state. Currently, multiple threads may simultaneously access the same kernel memory region on the electronic device, leading to inconsistencies or data loss among the accessed threads. Therefore, when one thread needs to access a kernel memory region, the operating system of the electronic device can allocate a kernel memory lock to that thread. The thread holding the kernel memory lock can then access that kernel memory region, preventing other threads from accessing it; in this state, the other threads are in an uninterruptible sleep.

[0003] However, threads that do not hold a kernel memory lock need to wait for a certain period of time until the thread holding the kernel memory lock releases it before they can continue executing their operations. When the operation involves interaction between the electronic device and the user, the electronic device also requires the user to wait a certain amount of time before it can respond, thus causing lag and making the user experience feel uneasy. Summary of the Invention

[0004] This application provides an information acquisition method, an electronic device, and a chip system, which can prevent electronic devices from lagging and improve user experience.

[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0006] Firstly, an information acquisition method is provided, applied to an electronic device. The electronic device receives a first request, which instructs a first thread to read the memory usage information of a first process. When the electronic device is in a user interaction scenario, and the first process is included in a first process set, and the memory usage information of the first process is not being read for the first time, the first thread reads the memory usage information of the first process from a first storage area of ​​the electronic device, so that the first thread obtains the memory usage information of the first process. The first storage area of ​​the electronic device stores the memory usage information of each process in a second process set. The first process set includes all processes required for the electronic device to display the first interface in the foreground. The memory usage information of each process in the second process set has been read for the first time, and the second process set is included in the first process set.

[0007] In the above scheme, after the electronic device receives the first request, if the electronic device is in a user interaction scenario, the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the first thread can read the memory usage information of the first process from the first cache area. During the process of reading the memory usage information of the first process, the first thread does not hold the kernel memory lock of the first process, thus preventing the second thread from being in an uninterruptible sleep state. The second thread is the thread within the first process that needs to read the memory usage information of the first process. That is, the process of the first thread reading the memory usage information of the first process does not affect the execution of the thread corresponding to the first process. Since the first process belongs to the first process set, meaning it is the process required for the electronic device to display the first interface in the foreground, the thread corresponding to the first process can continue to run even if the first thread reads the memory usage information of the first process during the display of the first interface and the response to user input on the first interface. This ensures that there is no lag during the display of the first interface and that the electronic device can respond to user input on the first interface promptly, preventing stuttering and improving the user experience. Furthermore, electronic devices can continue to run the thread corresponding to the first process on the CPU, making full use of the CPU's computing power and improving the operating efficiency of electronic devices.

[0008] In one possible implementation of the first aspect, if the identifier of the first process is included in the identifier set, the electronic device determines that the first process is included in the first process set, and that the memory usage information of the first process is not being read for the first time. Here, the identifiers in the identifier set are used to indicate that the memory usage information of the corresponding process has been read for the first time.

[0009] In the above scheme, the memory usage information of the first process is determined by the identifier set to determine whether it is not the first time it is read. This makes it easier for the first thread to obtain the memory usage information of the first process from the first storage area. As a result, the first thread will not hold the kernel memory lock of the first process when reading the memory usage information of the first process. The thread corresponding to the first process can also continue to run, and the electronic device will not experience lag, thus improving the user experience.

[0010] In another possible implementation of the first aspect, when the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the first thread reads the memory usage information of the first process from the first storage area of ​​the electronic device if the current time point is within the valid time period.

[0011] In the above scheme, the memory usage information of a process is subject to change. For example, threads on an electronic device can write to and modify memory usage information. Therefore, the memory usage information of a process is subject to change; that is, it has a time-sensitive nature, and the information will change significantly after a certain period. Electronic devices can ensure the timeliness of memory usage information by checking whether the current time point is within a valid time period.

[0012] In another possible implementation of the first aspect, when the electronic device is in a user interaction scenario, and the first process is included in a set of first processes, and the memory usage information of the first process is not being read for the first time, but the current time point is outside the valid time period, the first thread in the electronic device reads the memory usage information of the first process from the second storage area and holds the kernel memory lock of the first process. After completing the reading of the memory usage information of the first process, the first thread releases the kernel memory lock and stores the memory usage information of the first process it read into the first storage area. The electronic device then updates the memory usage information corresponding to the first process in the first storage area, and the electronic device also updates the valid time period of the first process.

[0013] In the above scheme, when the current time point is outside the valid time period, the first thread will read the memory usage information of the first process from the second storage area, thus ensuring the timeliness of the memory usage information of the first process.

[0014] In another possible implementation of the first aspect, when the electronic device is in a user interaction scenario and the first process is not included in the first process set, the electronic device reads the memory usage information of the first process from the second storage area, and the first thread holds the kernel memory lock so that the first thread can obtain the memory usage information of the first process.

[0015] In the above scheme, when the electronic device is in a user interaction scenario and the first process is not included in the first process set, the memory usage information stored in the first storage area does not include the memory usage information of the first process. The first thread on the electronic device can read the memory usage information of the first process from the second storage area. Furthermore, to prevent multiple threads from simultaneously accessing the memory usage information of the first process, which could lead to data inconsistency or data loss, the first thread will hold a memory kernel lock on the first process to ensure the accuracy of the data obtained by the first thread and avoid data inconsistency or data loss.

[0016] In another possible implementation of the first aspect, when the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is read for the first time, the electronic device reads the memory usage information of the first process from the second storage area. The first thread holds the kernel memory lock, and after the kernel memory lock is released, it stores the memory usage information of the first process in the first storage area of ​​the electronic device, and adds the identifier of the first process to the identifier set. The memory usage information of the first process is stored in the second storage area of ​​the electronic device.

[0017] In the above scheme, the second storage area stores the current memory usage information of all processes in the electronic device. In this case, if multiple threads simultaneously access the memory usage information of the first process on the electronic device, it can lead to inconsistencies in the first process's memory usage information, or even the loss of the accessed memory usage information. However, in this embodiment, when the first thread reads the first process's memory usage information from the second storage area, the first thread holds a kernel memory lock, preventing other threads from accessing this memory usage information and thus preventing data inconsistencies and the loss of memory usage information.

[0018] In another possible implementation of the first aspect, when the first interface is a user interface of a first application currently running in the foreground of the electronic device, the electronic device determines that it is currently in a user interaction scenario after receiving a first operation performed on the first interface. Alternatively, the electronic device determines that it is in a user interaction scenario when a second interface of the first application is displayed on the screen of the electronic device.

[0019] In the above scheme, the electronic device can accurately determine whether it is currently in a user interaction scenario by the first operation on the first interface and whether the electronic device displays the second interface, which makes it easier for the electronic device to subsequently determine the various processes required to display the first interface.

[0020] In another possible implementation of the first aspect, when the display screen of the electronic device shows the first interface of the first application, the electronic device records process information in a first process set, the first process set including the main process corresponding to the first application and the system processes corresponding to the first application supported by the operating system of the electronic device.

[0021] In the above scheme, the electronic device can determine the processes required to display the first interface through the first interface and record these processes so that when the memory usage information of the processes in the first process set is read for the first time, the electronic device can store the memory usage information into the first storage area.

[0022] In another possible implementation of the first aspect, where the first interface can be a user interface supported by the operating system of the electronic device, the electronic device determines that it is in a user interaction scenario after receiving the first operation performed on the first interface.

[0023] In the above scheme, the electronic device can accurately determine whether it is currently in a user interaction scenario through the first operation on the first interface, which makes it easier for the electronic device to subsequently determine the various processes required to display the first interface.

[0024] In another possible implementation of the first aspect, when the display screen of the electronic device shows a user interface supported by the operating system, the electronic device records process information in a first process set, the first process set including system processes corresponding to the first interface supported by the operating system of the electronic device.

[0025] In the above scheme, the electronic device can determine the processes required to display the first interface through the first interface and record these processes so that when the memory usage information of the processes in the first process set is read for the first time, the electronic device can store the memory usage information into the first storage area.

[0026] In a second aspect, this application provides an electronic device comprising: a memory and one or more processors, wherein when the processors execute one or more computer programs stored in the memory, the electronic device performs the method of the first aspect and any possible implementation thereof.

[0027] Thirdly, this application provides an electronic device comprising: a memory and one or more processors, the memory being coupled to the processors. The memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device performs the method described in the first aspect and any of its possible implementations.

[0028] Fourthly, this application provides a chip system applied to an electronic device including a memory and a display screen. The chip system includes a processor that, when executing computer instructions stored in the memory, causes the chip system to perform the method of the first aspect and any possible implementation thereof.

[0029] Fifthly, embodiments of this application provide a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in the first aspect and any possible implementation thereof.

[0030] Sixthly, embodiments of this application provide a computer program product that, when run on a computer, causes the computer to perform the method as described in the first aspect and any possible implementation thereof. The computer may be an electronic device as described in the second aspect and any possible implementation thereof, an electronic device as described in the third aspect and any possible implementation thereof, or a chip system as described in the fourth aspect and any possible implementation thereof.

[0031] Understandably, the beneficial effects achieved by the electronic device of the second aspect, the electronic device of the third aspect, the chip system of the fourth aspect, the computer-readable storage medium of the fifth aspect, and the computer program product of the sixth aspect provided above can be referred to the beneficial effects in the method of the first aspect and any possible implementation thereof, which will not be repeated here. Attached Figure Description

[0032] Figure 1 A schematic diagram of thread states provided in an embodiment of this application;

[0033] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0034] Figure 3 A schematic diagram of the software system architecture of an electronic device provided in an embodiment of this application;

[0035] Figure 4 A flowchart illustrating an information acquisition method provided in an embodiment of this application;

[0036] Figure 5 A schematic diagram of a process for a first thread to read memory usage information from a second storage area, provided in an embodiment of this application;

[0037] Figure 6 A flowchart illustrating another information acquisition method provided in an embodiment of this application;

[0038] Figure 7 A flowchart illustrating the process of determining a user interaction scenario using an electronic device, as provided in an embodiment of this application.

[0039] Figure 8 A schematic diagram of the evidence collection process for an information acquisition method provided in this application embodiment;

[0040] Figure 9 A flowchart illustrating another information acquisition method provided in an embodiment of this application;

[0041] Figure 10 A timing diagram of an information acquisition method provided in an embodiment of this application;

[0042] Figure 11 A timing diagram of another information acquisition method provided in an embodiment of this application. Detailed Implementation

[0043] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.

[0044] To facilitate understanding, the relevant terms will be explained below before introducing the method of this application.

[0045] A process is a running activity of a program or code on a certain set of data in an electronic device. The process is the basic unit for resource allocation and scheduling by the operating system. For example, after receiving a user's instruction to open application A, the operating system can create a process for application A. This process includes program code, system resources, other data, or files.

[0046] Processes can be divided into system processes and user processes.

[0047] System processes are processes that the operating system automatically creates and executes during startup and operation. System processes are responsible for managing and maintaining various basic system functions and are an indispensable part of the normal operation of the operating system. For example, user interface processes and resource management processes are system processes. These processes can run continuously from system startup, providing support for other processes, such as other system processes and / or user processes, as well as system services.

[0048] A user process is a process generated in the operating system based on user requests when an application is launched. User processes are the vehicles through which users interact with the operating system and complete various specific tasks, such as document processing, graphic design, web browsing, and video viewing. For example, after receiving a user's request to launch an office application, the operating system creates a user process for that application. This user process contains the code, data, and resource allocation information required for the application to run. This user process is primarily responsible for implementing word processing functions, such as document editing, formatting, and saving, to help the user complete document creation tasks.

[0049] A thread is a unit of execution within a process. It is the basic unit of scheduling and dispatching by the Central Processing Unit (CPU). A process can contain multiple threads, which share the process's resources, such as memory space and file descriptors. For example, in a process of application A, one thread might be responsible for rendering the page, another for handling user input, and yet another for communicating with the server to load the page content.

[0050] Kernel memory locks are synchronization mechanisms used to protect access to kernel memory regions. The kernel is the core of the operating system, managing various critical resources such as memory, CPU, and devices. Kernel memory stores many important data structures and information, such as the Process Control Block (PCB), which records process status and priority; device driver data structures used to communicate with hardware devices; and kernel global variables. Kernel memory locks ensure that only one execution unit, such as a thread or a process, can access the locked kernel memory region at any given time, preventing multiple execution units from simultaneously operating on that region and causing data inconsistencies or system errors.

[0051] A foreground application is an application currently running in the foreground of an electronic device. For example, when an electronic device responds to the touch of the application icon for application A, it displays the interface of application A; in this case, application A is the running foreground application. Foreground applications can be supported by a main process and child processes. The main process is the first process created and running when an application starts. Child processes are processes other than the main process.

[0052] Background applications are those that are not displayed on the screen but run in the background on an electronic device. For example, when an application button for application A is touched, the electronic device displays the interface of application A; application A is the foreground application and is running. Then, in response to a user's swipe to switch the foreground application to application B, the electronic device displays the interface of application B; application B is the foreground application and runs in the foreground. Application A, on the other hand, becomes the background application and runs in the background. Background applications can also be supported by a main process and child processes.

[0053] The method described in this application will be further detailed below.

[0054] Electronic devices can run multiple threads simultaneously. Multiple threads may need to access the same kernel memory region to obtain memory usage information for that region. This memory usage information is used to determine memory usage and can include information such as memory usage, available memory, and memory cache information. However, when multiple threads access the same kernel memory region, inconsistencies in the data accessed by each thread or data loss may occur.

[0055] To address this, electronic devices can introduce kernel memory locks. For example, a kernel memory lock could be mm->mmap_lock, allowing only the thread holding the kernel memory lock to access the kernel memory region, while other threads cannot perform access operations on that kernel memory region. In other words, other threads are in an uninterruptible sleep state.

[0056] When a thread enters an uninterruptible sleep state not due to input / output (I / O) operations, the primary cause is kernel memory locks. This is especially true when electronic devices are operating under heavy loads, making threads more prone to entering uninterruptible sleep states.

[0057] Among them, heavy load scenarios refer to scenarios where the central processing unit (CPU) on an electronic device cannot meet the computing power required by the current electronic device.

[0058] In some examples, such as Figure 1 As shown, a thread's state can include an uninterruptible sleep state and a running state. Both thread 1 and thread 2 need to access the same kernel memory region. When thread 2 holds the kernel memory lock corresponding to that kernel memory region, thread 1 will be in an uninterruptible sleep state. In this state, thread 1 cannot continue to execute related operations. Only after thread 2 releases the kernel memory lock can thread 1 continue to execute related operations; in this state, thread 1 is in the running state.

[0059] As can be seen, a thread holding a kernel memory lock can release the lock after it has finished accessing the kernel memory region. This causes threads that do not hold a kernel memory lock to wait for a certain period of time before performing related operations; that is, threads that do not hold a kernel memory lock are in an uninterruptible sleep state for a certain period of time.

[0060] When the relevant operation involves interaction between the electronic device and the user, and the user needs to wait a certain amount of time before the operation can be performed, the user will experience lag, which will negatively impact the user experience.

[0061] Furthermore, when a thread is in an uninterruptible sleep state, it cannot run on the CPU, thus failing to fully utilize the CPU's computing power, affecting the performance of electronic devices, and reducing the operating efficiency of electronic devices.

[0062] In particular, when the rendering thread and other threads associated with the interaction between the electronic device and the user are in an uninterruptible sleep state, the electronic device cannot respond to the user's interaction in a timely manner, making the user more likely to feel that the electronic device is lagging.

[0063] The following examples will provide a detailed explanation of why electronic devices are prone to lag.

[0064] For example, thread 1 can use a software development kit (SDK) to call relevant interfaces, allowing it to obtain memory usage information of process 1 from the kernel memory region. For instance, thread 1 can obtain this information from a preset node, such as ` / proc / pid / smaps`. During this access, thread 1 holds a kernel memory lock on process 1. If thread 2 also needs to access this kernel memory region, it will enter an uninterruptible sleep state. Thread 2 could be a thread on process 1 that also needs to access this memory usage information.

[0065] Because the kernel memory region stores a large amount of memory usage information for process 1, such as over 100,000 lines of information in the default node, thread 1 takes a long time to access this information. Consequently, thread 1 holds the kernel memory lock for an extended period, causing thread 2 to remain in an uninterruptible sleep state for a considerable time.

[0066] If thread 2 is waiting to execute an interaction between the electronic device and the user, and thread 2 cannot execute this operation within a certain time, the electronic device will not be able to respond to the user's interaction in a timely manner. This will cause the user to experience lag in the electronic device within a perceptible period, affecting the user experience. Furthermore, when thread 2 is in an uninterruptible sleep state, thread 2 cannot run on the CPU, and the CPU's computing power cannot be fully utilized, which will also affect the performance of the electronic device.

[0067] In this context, threads on electronic devices can access kernel memory regions in various ways, such as reading memory usage information from kernel memory regions or writing data to kernel memory regions.

[0068] In some embodiments, during the process of a thread reading memory usage information in the kernel memory region, the electronic device can employ various methods to address the aforementioned stuttering and performance issues of the electronic device.

[0069] As an example, an electronic device can add at least one kernel memory lock. When a thread meets a preset lock-holding condition, the thread will hold the newly added kernel memory lock. The preset lock-holding condition may be that the thread has only read part of the memory usage information corresponding to the newly added kernel memory lock.

[0070] The scope of the newly added kernel memory locks is smaller than that of the original kernel memory locks. Specifically, the scope of the original kernel memory locks covered all memory usage information for a process, while the scope of the newly added kernel memory locks is smaller. This means that an electronic device can set multiple new kernel memory locks simultaneously, with each kernel memory lock covering a portion of the memory usage information for a process.

[0071] For example, electronic devices divide the entire memory usage information corresponding to a process into multiple partial memory usage information, namely, partial memory usage information 1, partial memory usage information 2, ..., partial memory usage information N. Each partial memory usage information corresponds to a newly added kernel memory lock, namely, kernel memory lock 1, kernel memory lock 2, ..., kernel memory lock N.

[0072] During the process of a thread reading memory usage information corresponding to a process, the thread only acquires a newly added kernel memory lock if preset locking conditions are met. For example, if a thread only reads a portion of memory usage information 1, then the thread can acquire kernel memory lock 1. This kernel memory lock 1 can restrict other threads from reading a portion of memory usage information 1, but it does not affect other threads reading other memory usage information. The scope of the newly added kernel memory lock can be locked in units of virtual memory addresses; that is, the scope of the newly added kernel memory lock can be the range of memory usage information corresponding to one or more virtual memory addresses.

[0073] However, in one example, a thread must meet preset lock-holding conditions to acquire a newly added kernel memory lock. If the thread does not meet the preset lock-holding conditions, it retains its original kernel memory lock. For instance, if a thread needs to access both partial memory usage information 1 and partial memory usage information 2, it can only hold the original kernel memory lock; that is, the thread can only hold the kernel memory lock corresponding to all memory usage information. With the thread still holding the kernel memory lock corresponding to all memory usage information, the resulting lag and performance issues with electronic devices remain unresolved.

[0074] In a second example, if a thread in an electronic device only needs to obtain the total memory usage information corresponding to a process, the electronic device can store the total memory usage information in a newly added node (such as the `smaps_rollups` node) and add a new kernel memory lock based on the new node. When a thread reads the total memory usage information, the thread will hold this newly added kernel memory lock. The total memory usage information is relatively small, so the thread's reading time is short. However, the total memory usage information corresponding to a process is much larger, so the thread's reading time is longer. Therefore, the time a thread holds the newly added kernel memory lock is much shorter than the time it holds the original kernel memory lock (the one held when the thread reads the total memory usage information).

[0075] However, in the second example, when the thread reads all memory usage information corresponding to the process, the thread still holds the kernel memory lock corresponding to all memory usage information. The lag problem and performance problem of electronic devices caused by this kernel memory lock still cannot be solved.

[0076] In view of the above problems, this application provides an information acquisition method, by way of example. The electronic device caches memory usage information corresponding to key processes, so that when the memory usage information of the key process is not read by a thread for the first time, the thread can read the cached memory usage information without holding a kernel memory lock. Specifically, by reading the cached memory usage information of the key process, the thread does not hold a kernel memory lock during the process of reading the memory usage information, reducing the holding of kernel memory locks and avoiding the stuttering and performance problems caused by threads holding kernel memory locks.

[0077] Among these, a critical process can be the process required for the electronic device to display its first interface in the foreground. For example, the main process of the foreground application is used to support the electronic device in displaying the user interface of the foreground application. When the first interface displayed by the electronic device is the user interface of the foreground application, the critical process can be the main process of the foreground application.

[0078] For example, the aforementioned electronic device may be a mobile phone, tablet computer, smart remote control, wearable device (such as smart bracelet, smartwatch, or smart glasses), PDA, or augmented reality (AR) / virtual reality (VR) device. Alternatively, the mobile phone 500 may also be a portable multimedia player (PMP), media player, or other types of electronic device. This application embodiment does not impose any limitations on the specific type of electronic device.

[0079] Figure 2 A schematic diagram of the structure of the electronic device 200 is shown.

[0080] Electronic device 200 may include processor 210, external memory interface 220, internal memory 221, universal serial bus (USB) interface 230, charging management module 240, power management module 241, battery 242, antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, audio module 270, sensor module 280, camera 293, and display screen 294.

[0081] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 200. In other embodiments of this application, the electronic device 200 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0082] Processor 210 may include one or more processing units, such as application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0083] The controller can be the nerve center and command center of the electronic device 200. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0084] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

[0085] In some embodiments, the processor 210 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0086] The wireless communication function of electronic device 200 can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor.

[0087] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 200 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.

[0088] Display screen 294 is used to display images, videos, etc. Display screen 294 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 200 may include one or N displays 294, where N is a positive integer greater than 1.

[0089] Video codecs are used to compress or decompress digital video. Electronic device 200 may support one or more video codecs. Thus, electronic device 200 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0090] An NPU (Neural Processing Unit) is a neural network (NN) computing processor that, by borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, rapidly processes input information and can continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.

[0091] The external storage interface 220 can be used to connect an external memory card, such as a MicroSD card, to expand the storage capacity of the electronic device 200. The external memory card communicates with the processor 210 through the external storage interface 220 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0092] Internal memory 221 can be used to store computer executable program code, which includes instructions. Processor 210 executes various functional applications and data processing of electronic device 200 by running the instructions stored in internal memory 221. Internal memory 221 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 200 (such as audio data, phonebook, etc.). Furthermore, internal memory 221 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0093] Figure 3 This is a schematic diagram of the software system architecture of an electronic device provided in an embodiment of this application.

[0094] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to illustrate the software structure of an electronic device.

[0095] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom: the application layer, the application framework layer, the system service layer, the native service layer, and the kernel layer.

[0096] The application layer can include a series of application packages.

[0097] like Figure 3 As shown, the application layer can include: foreground applications, background applications, process management applications, etc. It should be understood that it can also include: camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, and other applications, not all of which are shown in the diagram.

[0098] Process management applications can manage the reading of process memory usage information. Process management applications include: an activity monitoring module, a process marking module, a performance-sensitive scenario identification module, an interaction scenario identification module, and a caching strategy management module.

[0099] The activity monitoring module can determine the foreground application currently displayed on the screen by monitoring whether the foreground application is switched.

[0100] The process tagging module is used to record process information in the first process set, which consists of all the processes required by the electronic device for the latest foreground display interface.

[0101] The performance-sensitive scene recognition module is used to identify whether the interface currently displayed by the electronic device is a performance-sensitive scene interface.

[0102] The interaction scene recognition module is used to identify whether the current situation is a user interaction scene.

[0103] The caching policy management module is used to determine whether the memory usage information of the first process should be cached, and to set the valid time period for the memory usage information of the first process.

[0104] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes a set of predefined functions.

[0105] like Figure 3As shown, the application framework layer may include: a memory usage information cache management module, a debug module, an activity thread module, and an activity manager module. The application framework layer may also include: a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc., not all of which are shown in the diagram.

[0106] The memory usage information cache management module caches the memory usage information of the first process to the debugging module.

[0107] The debug module is used to store memory usage information of the first process.

[0108] The Activity Threads module manages the lifecycle of all activities in the application, meaning it is responsible for creating new processes and threads to run the application.

[0109] The activity management module is responsible for monitoring and managing the application's lifecycle.

[0110] The system service layer provides basic services such as operating system functions, network communication services, and management services, offering necessary support and guarantees for upper-layer applications. The system service layer includes modules such as memory acquisition and monitoring. Specifically, threads use the memory acquisition and monitoring module to determine whether the process's memory usage information has been acquired.

[0111] The local service layer refers to the collection of services running on the local computer or device. This layer includes modules such as performance analysis modules. Performance analysis modules help users analyze application performance; for example, they can use the `android.os.debug` class to obtain memory usage information for the application's process and determine the application's memory usage.

[0112] The local services layer also includes components of the Android runtime.

[0113] The kernel layer is the layer between hardware and software. It includes memory drivers, which manage operations related to memory (such as hard drives and SSDs). Memory drivers provide a series of interfaces that enable electronic devices to access data in memory. These interfaces include data reading and writing, device initialization, and device control. For example, an electronic device can use a memory driver to read memory usage information of a process stored in memory.

[0114] The method for obtaining information in this application will be explained in detail below with reference to the accompanying drawings.

[0115] Figure 4 This is a flowchart illustrating an information acquisition method provided in an embodiment of this application, such as... Figure 4As shown, the information acquisition method in this application embodiment may include:

[0116] Step 401: The electronic device obtains a first request, which indicates that the first thread needs to read the memory usage information of the first process.

[0117] The first request is sent by the first thread when it needs to read the memory usage information of the first process. The electronic device determines that the first thread needs to read the memory usage information of the first process by receiving the first request.

[0118] The first thread can be any thread in the electronic device, and this application embodiment does not limit the type of the first thread. For example, the first thread can be: a thread corresponding to the process of a foreground application, a thread corresponding to a system process, or a thread corresponding to a background application, etc., without limitation. The first process can include one or more processes in the electronic device, and this application embodiment does not limit the type of the first process. For example, the first process can be the main process of a foreground application, or a system process, etc.

[0119] There can be a relationship between the first thread and the first process, meaning the first thread can be any thread within the first process. Conversely, there can also be no relationship between the first thread and the first process, meaning the first thread does not belong to the first process.

[0120] The memory usage information of the first process is used to determine its memory usage. This information can include: memory usage, available memory, and cached memory. The electronic device reads this information to determine the first process's memory usage, facilitating the release of memory used by the first process and preventing excessive memory consumption that could negatively impact the device's operation.

[0121] In some examples, the first thread can be the thread corresponding to the main process of the foreground application, and the first process can be the main process of the foreground application. The foreground application uses the first thread to read its own memory usage information to determine its own memory usage. This memory usage information can include memory usage details, memory storage locations, and other information.

[0122] In other examples, the first thread can be a thread corresponding to a system process, and the first process can be the main process of the foreground application. The operating system of the electronic device uses the first thread to read the memory usage information of the foreground application to determine the memory usage of the foreground application.

[0123] Step 402: When the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the first thread reads the memory usage information of the first process from the first storage area of ​​the electronic device, so that the first thread obtains the memory usage information of the first process.

[0124] User interaction scenarios refer to situations where electronic devices and users interact. For example, an electronic device receives a user's touch input and responds to it; in this case, the electronic device is currently in a user interaction scenario. Alternatively, the electronic device may be displaying a video playback interface; in this case, the electronic device is currently in a user interaction scenario. Or, the electronic device may be displaying a navigation interface; in this case, the electronic device is currently in a user interaction scenario. In the embodiments of this application, no excessive limitations are placed on user interaction scenarios.

[0125] The first process set includes all the processes required for the electronic device to display the first interface in the foreground. For example, if the electronic device needs multiple processes to support the display of the first interface, the first process set can be the processes that support the display of the first interface. Alternatively, after the electronic device displays the first interface, it receives user input on the first interface. The electronic device can respond to the user's input, and the processes used in responding to the user's input are the processes in the first process set. In other words, the processes in the first process set are the processes related to the current interaction between the electronic device and the user. The input can be touch input, voice input, etc.

[0126] The first interface can be a user interface in a foreground application or a user interface supported by the operating system of an electronic device. In this embodiment, the first interface is not subject to too many limitations.

[0127] The first screen currently displayed on the foreground of an electronic device refers to the screen currently displayed on the device's display. For example, when an electronic device responds to the touch of the application icon of application A, it opens application A and displays its interface. At this time, the interface of application A is the first screen currently displayed on the foreground of the electronic device.

[0128] When an electronic device displays the interface of application A, it requires support from the main process of application A, as well as from image rendering-related processes within the system. In this case, the first set of processes can include: the main process of application A and the image rendering-related processes. When the first process is included in the first set of processes, the first process can be the main process of application A, the first process can be an image rendering-related process, or the first process can be both the main process of application A and image rendering-related processes.

[0129] The term "not the first time the memory usage information of the first process is read" means that the memory usage information of the first process has been read before, and the electronic device can store the memory usage information of the first process into the first storage area when the memory usage information of the first process is read for the first time.

[0130] The first storage area of ​​the electronic device stores the memory usage information of each process in the second process set. The second process set includes some or all of the processes in the first process set; that is, the second process set consists of the processes whose memory usage information in the first process set has been read for the first time. In other words, the electronic device can store the memory usage information that has been read for the first time from the first process set into the first storage area. The first storage area may refer to the aforementioned... Figure 3 The debugging module allows the electronic device to store the memory usage of each process in the second process set in the first storage area.

[0131] In summary, in this embodiment, after the electronic device receives the first request, if the electronic device is in a user interaction scenario, the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the first thread can read the memory usage information of the first process from the first cache area. During the process of reading the memory usage information of the first process, the first thread does not hold the kernel memory lock of the first process, thus preventing the second thread from being in an uninterruptible sleep state. The second thread is the thread within the first process that needs to read the memory usage information of the first process. That is, the process of the first thread reading the memory usage information of the first process does not affect the operation of the thread corresponding to the first process. Since the first process belongs to the first process set, meaning it is the process required for the electronic device to display the first interface in the foreground, even if the first thread reads the memory usage information of the first process, the thread corresponding to the first process can continue to run during the display of the first interface and the response to user input on the first interface. This ensures that there is no lag during the display of the first interface and that the electronic device can respond to user input on the first interface promptly, preventing stuttering and improving the user experience. Furthermore, electronic devices can continue to run the thread corresponding to the first process on the CPU, making full use of the CPU's computing power and improving the operating efficiency of electronic devices.

[0132] Based on the above embodiments, the first thread can only read the memory usage information of the first process from the first storage area if the memory usage information of the first process is not being read for the first time. The following is a detailed description of how the electronic device determines whether the memory usage information of the first process is not being read for the first time.

[0133] For any given process, if the electronic device cannot find the process's identifier in the identifier set when its memory usage information is read for the first time, it can store the process's identifier in the identifier set to indicate that the process's memory usage information has been read for the first time. The identifiers in the identifier set can be at least one of process ID, number, name, etc. It is understandable that since the memory usage information of the processes in the second process set has been read for the first time, the identifiers corresponding to the processes in the second process set all belong to this identifier set.

[0134] In some embodiments, the first request includes an identifier of a first process. The electronic device may determine whether the identifier of the first process is included in an identifier set.

[0135] If the identifier of the first process is not included in the identifier set, the electronic device can determine that the memory usage information of the first process has been read for the first time. In this way, the electronic device can store the identifier of the first process in the identifier set to indicate that the memory usage information of the first process has been read for the first time.

[0136] If the identifier of the first process is included in the identifier set, the electronic device can determine that the memory usage information of the first process is not being read for the first time.

[0137] In some embodiments, the process corresponding to the identifier stored in the identifier set can also be a process whose memory usage information has not been read for the first time, and which is included in the first process set. That is, if the identifier of the first process is included in the identifier set, the electronic device determines that the first process is included in the first process set, and that the memory usage information of the first process has not been read for the first time.

[0138] By identifying whether the memory usage information of the first process is not being read for the first time by using a set of identifiers, it is easier for the first thread to obtain the memory usage information of the first process from the first storage area. This ensures that the first thread does not hold the kernel memory lock of the first process while reading the memory usage information of the first process, and the thread corresponding to the first process can continue to run. Electronic devices will not experience lag, thus improving the user experience.

[0139] However, process memory usage information is subject to change. For example, threads on an electronic device can write to and modify memory usage information. This demonstrates that process memory usage information is time-sensitive; the information will change significantly after a certain period. Electronic devices can ensure the timeliness of memory usage information by checking if the current time point is within a valid time frame.

[0140] When an electronic device is in a user interaction scenario, and the first process is included in a set of first processes, the electronic device needs to determine whether the memory usage information of the first process is not being read for the first time, and it also needs to determine whether the current time point is within a valid time period. The order of these two determinations is not important; they can be executed simultaneously or sequentially, and this application embodiment does not limit this. To simplify the description, this application embodiment uses the example of first determining whether the memory usage information of the first process is not being read for the first time, and then determining whether the current time point is within a valid time period, for illustration and description.

[0141] In some embodiments, when the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the first thread reads the memory usage information of the first process from the first storage area of ​​the electronic device if the current time point is within the valid time period.

[0142] Here, the current time point refers to the time point when the first thread requests to read the memory usage information of the first process, and the effective time period refers to the time during which the first thread can read the memory usage information of the first process from the first storage area.

[0143] Understandably, in this embodiment, the electronic device ensures the timeliness of memory usage information by determining whether the current time point is within a valid time period.

[0144] In some embodiments, different threads read the memory usage information corresponding to the first process, and the effective time periods corresponding to the memory usage information are different.

[0145] Let's take the main process of the foreground application as an example. For instance, if the first thread is the thread corresponding to the foreground application, the effective timeframe for the first thread to read the memory usage information of the first process is relatively short. This is because the first thread adjusts the memory usage of the foreground application in real time by reading the memory usage information of the first process. Therefore, the first thread has a high requirement for the timeliness of memory usage information, resulting in a short effective timeframe for the first thread to read the memory usage information of the first process.

[0146] Specifically, when the first thread is the thread corresponding to the foreground application, the effective time period is 1 when the first thread reads the memory usage information of the foreground application. When the first thread is the thread corresponding to another application, such as the thread corresponding to the system application, the effective time period is 2 when the first thread reads the memory usage information of the foreground application. In this case, the effective time period 2 will be longer than the effective time period 1.

[0147] In some embodiments, if the current time point is not within a valid time period, the first thread will read the memory usage information of the first process from the second storage area. The second storage area can also be the storage area under the aforementioned / proc / pid / smaps path.

[0148] In other words, when the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, but the current time point is outside the valid time period, the first thread in the electronic device reads the memory usage information of the first process from the second storage area and holds the kernel memory lock of the first process. Only after the first thread has finished reading the memory usage information of the first process will it release the kernel memory lock, and the first thread will store the memory usage information of the first process it read into the first storage area. The electronic device then updates the memory usage information corresponding to the first process in the first storage area, and the electronic device also updates the valid time period of the first process.

[0149] Understandably, in this embodiment, when the current time point is outside the valid time period, the first thread will read the memory usage information of the first process from the second storage area, thus ensuring the timeliness of the memory usage information of the first process.

[0150] The following section provides a detailed explanation of how the first thread reads memory usage information from the second storage area.

[0151] The first thread can read the memory usage information of the first process in the preset node through the android.os.Debug class. For example... Figure 5 As shown, the first thread calls the `android.os.Debug.getDirtyPages` function in the local service layer through the `android.os.Debug.getDirtyPages` function in the framework layer. The `android.os.Debug.getDirtyPages` function then calls the `android.os.Debug.getDirtyPagesPid` function, which in turn accesses a preset node in the kernel layer by calling `ExtraAndroidHeapStats`. After the preset node is accessed, specified memory usage information is generated and returned to the first thread sequentially through `ExtraAndroidHeapStats`, `android.os.Debug.getDirtyPagesPid`, `android.os.Debug.getDirtyPages`, and `android.os.Debug.getMeminfo` functions.

[0152] The following flowchart will further illustrate the information acquisition method of this application.

[0153] Specifically, Figure 6 A flowchart illustrating another information acquisition method provided in this application embodiment is shown below. Figure 6 As shown, the method in this application embodiment may include:

[0154] Step 601: The electronic device determines whether it is in a user interaction scenario.

[0155] In some embodiments, when the electronic device is in a user interaction scenario, the electronic device performs step 602. When the electronic device is not in a user interaction scenario, the electronic device performs step 606.

[0156] In some embodiments, when the electronic device is not in a user-interactive scenario, the first thread can read memory usage information of any process from the second storage area. The electronic device not being in a user-interactive scenario can mean that the electronic device is in a screen-off state, etc.

[0157] Step 602: The electronic device determines whether the first process is included in the first process set.

[0158] In some embodiments, if the first process is included in the first process set, the electronic device performs step 603. If the first process is not included in the first process set, the electronic device performs step 606.

[0159] In some embodiments, when the electronic device is in a user interaction scenario and the first process is not included in the first process set, the electronic device reads the memory usage information of the first process from the second storage area, and the first thread holds a kernel memory lock so that the first thread can obtain the memory usage information of the first process.

[0160] In this embodiment, the memory usage information stored in the first storage area of ​​the electronic device is the memory usage information of processes belonging to the first process set, after which their memory usage information has been read for the first time. This is because the processes in the first process set are all the processes required by the electronic device to display the first interface in the foreground. That is, the processes in the first process set are the processes related to the current interaction between the electronic device and the user. These processes will consume more CPU resources and are more likely to reduce CPU efficiency. Furthermore, the storage space of the first storage area is limited. Therefore, the electronic device prioritizes storing the memory usage information of processes in the first process set in the first storage area.

[0161] Understandably, when an electronic device is in a user interaction scenario and the first process is not included in the first process set, the memory usage information stored in the first storage area does not include the memory usage information of the first process. The first thread on the electronic device can read the memory usage information of the first process from the second storage area. Furthermore, to prevent multiple threads from simultaneously accessing the memory usage information of the first process, which could lead to data inconsistency or data loss, the first thread will hold a memory kernel lock on the first process to ensure the accuracy of the data obtained by the first thread and avoid data inconsistency or data loss.

[0162] Step 603: The electronic device determines whether the memory usage information of the first process is not being read for the first time.

[0163] In some embodiments, if the memory usage information of the first process is not being read for the first time, the electronic device executes step 604. If the memory usage information of the first process is being read for the first time, the electronic device executes step 606.

[0164] In some embodiments, when the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is read for the first time, the electronic device reads the memory usage information of the first process from the second storage area. The first thread holds the kernel memory lock, and after the kernel memory lock is released, it stores the memory usage information of the first process in the first storage area of ​​the electronic device, and adds the identifier of the first process to the identifier set. The second storage area of ​​the electronic device stores the memory usage information of the first process.

[0165] Understandably, the second storage area stores the current memory usage information of all processes in the electronic device. In this scenario, multiple threads simultaneously accessing the memory usage information of the first process on the electronic device could lead to inconsistencies or loss of the accessed memory usage information. However, in this embodiment, while the first thread is reading the memory usage information of the first process from the second storage area, the first thread holds a kernel memory lock, preventing other threads from accessing this memory usage information and thus preventing data inconsistencies and loss of memory usage information.

[0166] Step 604: The electronic device determines whether the current time point is within the valid time period.

[0167] In some embodiments, if the current time point is within a valid time period, the electronic device performs step 605. If the current time point is not within a valid time period, the electronic device performs step 606.

[0168] Step 605: The first thread in the electronic device reads the memory usage information of the first process from the first storage area.

[0169] Step 606: The first thread in the electronic device reads the memory usage information of the first process from the second storage area.

[0170] As can be seen from the above embodiments, the embodiments of this application are based on the premise that the electronic device is in a user interaction scenario. The determination of the user interaction scenario will be explained in more detail below.

[0171] In some embodiments, the latest interface displayed on the foreground of the electronic device is the first interface. When the electronic device is in a user interaction scenario, it can interact with the user through the first interface. The first interface can be a user interface of the first application currently running on the foreground of the electronic device, or a user interface supported by the operating system of the electronic device, etc. In the embodiments of this application, no limitation is placed on the first interface.

[0172] Below, we will take the first interface, which is the user interface of the first application running in the foreground of the electronic device, as an example for a detailed explanation.

[0173] Here, the first application can refer to the front-end application, and the user interface is the interface in the front-end application that interacts with the user.

[0174] In some embodiments, after the electronic device receives a first operation performed on the first interface, the electronic device determines that it is currently in a user interaction scenario. For example, if the first operation is a touch input, the electronic device receives and responds to the user's touch, and at this time, the electronic device is in a user interaction scenario.

[0175] In this embodiment, the first operation can be any input such as touch input or voice input, and there are no restrictions in this application embodiment.

[0176] In other embodiments, when the second interface of the first application is displayed on the screen of the electronic device, the electronic device is determined to be in a user interaction scenario. The second interface can be a user interface within the first application, and may include: an interface for switching videos by swiping, an interface for watching videos, an interface for browsing information by swiping, an interface for playing audio, an interface for displaying navigation, an interface for displaying games, etc. The screen of the electronic device can display the second interface of the first application by receiving a second user operation. The second operation can be touch input, voice input, etc., and is not limited thereto. User input operations, such as touch input and voice input, can also be received on the second interface of the electronic device, and are not limited thereto.

[0177] The second interface can also be a pre-defined interface in the first application under a pre-defined performance-sensitive scenario. A performance-sensitive scenario refers to a situation where, if the interaction-related threads are in an uninterruptible sleep state, the user can clearly perceive lag in the interaction process.

[0178] In some embodiments, performance-sensitive scenarios can be determined using performance sentiment data and standard regression coefficient issue data (or Beta issue data). Performance sentiment data refers to user evaluations and feedback on the performance of a product or service, while Beta issue data refers to the impact of interaction-related threads on stuttering when they are in an uninterruptible sleep state.

[0179] Understandably, through the above embodiments, electronic devices can accurately determine whether they are currently in a user interaction scenario, which facilitates the electronic devices in subsequently determining the various processes required to display the first interface.

[0180] Once the electronic device determines that it is currently in a user interaction scenario, it can also determine the various processes required to display the first interface. The specific process is as follows.

[0181] In some embodiments, when the display screen of the electronic device shows the first interface of the first application, the electronic device records process information in a first process set, the first process set including the main process corresponding to the first application and the system processes corresponding to the first application supported by the operating system of the electronic device.

[0182] Process information is used to identify processes and may include at least one of the following: process ID, process name, etc. The first process set stores the process information of each process required for the electronic device to display the first interface in the foreground. For example, if the first application is a foreground application, the first interface is the user interface of the foreground application. In order to display the user interface of the foreground application, the electronic device needs the support of user processes and system processes. The user process can be the main process of the foreground application; therefore, the first process set may include the main process corresponding to the foreground application and the system processes.

[0183] The following example, which uses a user interface supported by the operating system of an electronic device as the first interface, will be used for further explanation.

[0184] In some embodiments, after receiving a first operation performed on a first interface, the electronic device determines that it is in a user interaction scenario.

[0185] The first interface is a user interface supported by the operating system, which can be the negative one screen of an electronic device, the main menu interface of an electronic device, the control panel interface of an electronic device, etc., and is not limited in the embodiments of this application. The first operation can be any operation such as touch operation or input operation, and is not limited in the embodiments of this application.

[0186] In the embodiments of this application, the electronic device can accurately determine whether it is currently in a user interaction scenario through the above embodiments, which also facilitates the electronic device to subsequently determine the various processes required to display the first interface.

[0187] Once the electronic device determines that it is currently in a user interaction scenario, it can also determine the various processes required to display the first interface. The specific process is as follows.

[0188] In some embodiments, when the display screen of the electronic device shows a user interface supported by the operating system, the electronic device records process information in a first process set, the first process set including system processes corresponding to the first interface supported by the operating system of the electronic device.

[0189] In this embodiment, the first interface currently displayed by the electronic device is a user interface supported by the operating system. In order to display the user interface supported by the operating system, the electronic device needs the support of system processes. Therefore, the first set of processes may include system processes.

[0190] The following example provides a more detailed explanation of how to determine the interaction scenario.

[0191] Figure 7 This is a flowchart illustrating how an electronic device determines a user interaction scenario, as provided in an embodiment of this application. Figure 7 As shown, the specific steps are as follows.

[0192] Step 701: The electronic device determines whether no input has been received within a preset time.

[0193] In some embodiments, if the electronic device does not receive input within a preset time, the electronic device executes step 702; if the electronic device receives input within the preset time, the electronic device is currently in a user interaction scenario. Here, input can refer to any type of input, such as touch input or signal input.

[0194] Step 702: The electronic device determines whether sound is being played.

[0195] In some embodiments, if the electronic device is not playing sound, the electronic device performs step 703; if the electronic device is playing sound, the electronic device is currently in a user interaction scenario.

[0196] Step 703: The electronic device determines whether a video is playing.

[0197] In some embodiments, if the electronic device is not playing a video, the electronic device performs step 704; if the electronic device is playing a video, the electronic device is currently in a user interaction scenario.

[0198] Step 704: The electronic device determines whether to provide navigation services.

[0199] In some embodiments, if the electronic device does not provide navigation services, the electronic device performs step 705; if the electronic device provides navigation services, the electronic device is currently in a user interaction scenario.

[0200] Step 705: The electronic device determines whether to display the interface of the game application.

[0201] In some embodiments, if the interface displayed on the electronic device is not the interface of a game application, then the electronic device is not currently in a user interaction scenario; if the interface displayed on the electronic device is the interface of a game application, then the electronic device is currently in a user interaction scenario.

[0202] Based on the above embodiments, the memory usage information of the first process read by the electronic device each time is consistent. That is, the memory usage information of the first process read by the electronic device for the first time is the same as the memory usage information of the first process read by the electronic device for the second time.

[0203] The following is a specific embodiment as an example. If the electronic device uses the various functions or steps in the above method embodiments, then as follows: Figure 8 As shown, Figure 8 This is a schematic diagram of the evidence collection process for an information acquisition method provided in an embodiment of this application. Taking a mobile phone as an example, Figure 8 The specific steps are as follows.

[0204] Step 801: The phone performs permission verification.

[0205] In this embodiment, after the mobile phone is connected to the computer, the computer uses the Android Debug Bridge (ADB) command to verify the phone's permissions. If the permission verification is successful, the phone proceeds to step 802. If the permission verification fails, the operation ends.

[0206] Step 802: The mobile phone obtains the memory usage information of the system processes through preset instructions.

[0207] In some embodiments, the default command may be adb shell dumpsys meminfo system_server.

[0208] Step 803: The mobile phone then obtains the memory usage information of the system processes through preset instructions.

[0209] Step 804: Compare the memory usage information of the system processes obtained by the phone on the two occasions with the computer connected to the phone to see if they are the same.

[0210] In some embodiments, if the memory usage information of the system process obtained by the mobile phone in two separate transactions is the same, it indicates that the mobile phone has used the various functions or steps in the above method embodiments.

[0211] In other embodiments, the electronic device can also capture the call stack using a first tool. If the `Debug.getMemoryInfo` function indicates that the electronic device can obtain process memory usage information through a debugging module, it can be determined whether the electronic device has used the various functions or steps described in the above method embodiments. Here, the call stack is the stack corresponding to the process continuously collecting its own memory usage, and the first tool can be a Profiler tool.

[0212] Let's combine the above... Figure 3 The software modules in this application will be described in more detail to illustrate the execution process of the embodiments. Figure 9 A flowchart illustrating another information acquisition method provided in this application embodiment is shown below. Figure 9 As shown, the specific steps are as follows:

[0213] Step 901: The activity listening module notifies the activity management module to register the activity change listener.

[0214] In some embodiments, an activity is a component of an application used to present the user interface and handle user interactions. Activities switch when the interface changes. Electronic devices determine their currently displayed interface by listening to activities.

[0215] Step 902: The activity management module determines the latest first screen to be displayed by listening to the activity.

[0216] Step 903: The activity monitoring module receives the activity monitoring results and determines that the first interface is the user interface of the foreground application.

[0217] Step 904: The process tagging module records the process information in the first process set.

[0218] In some embodiments, when the first interface is the user interface of a foreground application, the first process set includes: the main process of the foreground application and the system process.

[0219] Step 905: The first thread requests to read the memory usage information of the processes in the first process set.

[0220] Step 906: The memory usage information cache management module notifies the performance-sensitive scenario identification module to determine whether the first interface is an interface under a performance-sensitive scenario.

[0221] In some embodiments, if the performance-sensitive scene identification module determines that the first interface is an interface under a performance-sensitive scene, the electronic device executes step 907.

[0222] Step 907: The performance-sensitive scene recognition module notifies the interaction scene recognition module to determine whether the electronic device is in a user interaction scene.

[0223] In some embodiments, when the interaction scene recognition module determines that the electronic device is in a user interaction scene, the electronic device executes step 908.

[0224] Step 908: The interaction scene recognition module notifies the cache strategy management module to determine whether the process's memory usage information is being read for the first time and whether the current time point is within the valid time period.

[0225] If the cache policy management module determines that the process's memory usage information is not being read for the first time, and the current time point is within the valid time period, the electronic device executes step 909.

[0226] Step 909: The memory usage information cache management module returns the storage address of the debug module to the first thread.

[0227] Step 910: The first thread reads the memory usage information of the process in the debug module through the storage address.

[0228] The information acquisition method of this application will be explained in more detail below using a sequence diagram.

[0229] Specifically, the interaction sequence diagram when a thread reads the memory usage information of a system process can be shown as follows: Figure 10 As shown, the memory usage information of the system process has been read for the first time. The interaction sequence diagram when the thread reads the memory usage information of the main process of the foreground application can be seen as follows: Figure 11 As shown, the memory usage information of the main process of the foreground application has been read for the first time.

[0230] The following section will first explain in detail how a thread reads the memory usage information of a system process. Specifically, as follows... Figure 10 As shown. The process management application includes a cache policy management module, an activity monitoring module, and a performance-sensitive scenario identification module. The system processes include: an activity management module, a memory usage information cache management module, a memory acquisition and monitoring module, and a debugging module.

[0231] Step 1001: The cache strategy management module registers an activity change listener through the activity management module.

[0232] In this embodiment, an activity change listener is used to determine whether an activity has switched, thereby determining the interface currently displayed on the screen.

[0233] Step 1002: The activity management module detects the activity switch.

[0234] Step 1003: The activity management module notifies the activity listening module that an activity switch has occurred.

[0235] Step 1004: The activity monitoring module notifies the performance-sensitive scenario identification module to identify whether the current interface is an interface under a performance-sensitive scenario.

[0236] Step 1005: The performance-sensitive scenario identification module notifies the cache strategy management module that the current interface is the interface under the performance-sensitive scenario.

[0237] In this embodiment, if the electronic device detects that the current interface is an interface in a performance-sensitive scenario, then the electronic device is in a user interaction scenario.

[0238] Step 1006: The cache policy management module sets the process's memory usage information caching policy through the memory usage information cache management module.

[0239] In some embodiments, the memory usage information caching policy is used to set which processes' memory usage information is cached, and the corresponding valid time period.

[0240] Step 1007: After the process's memory usage information has been read for the first time, the memory acquisition and monitoring module obtains the process's memory usage information from the debugging module.

[0241] Step 1008: The debugging module obtains the memory usage information caching policy from the memory usage information caching management module and generates memory usage information according to the memory usage information caching policy.

[0242] In some embodiments, if the time when a thread requests to read the process's memory usage information falls within the valid cache period of the process's memory usage information, the debugging module generates memory usage information and then sends the memory usage information to the thread.

[0243] Step 1009: The debugging module returns the process's memory usage information to the memory acquisition and monitoring module.

[0244] The following section will further explain how a thread reads the memory usage information of the main process of the foreground application. Specifically... Figure 11As shown. The process management application includes a cache policy management module, an activity monitoring module, and a performance-sensitive scenario identification module. The system process includes an activity management module, and the main process of the foreground application includes a memory usage information cache management module, a memory acquisition and monitoring module, and a debugging module.

[0245] Step 1101: The cache strategy management module registers an activity change listener through the activity management module.

[0246] Step 1102: The activity management module detects the activity switch.

[0247] Step 1103: The activity management module notifies the activity listening module that an activity switch has occurred.

[0248] Step 1104: The activity monitoring module notifies the performance-sensitive scenario identification module to identify whether the current interface is an interface under a performance-sensitive scenario.

[0249] Step 1105: The performance-sensitive scenario identification module notifies the cache strategy management module that the current interface is the interface under the performance-sensitive scenario.

[0250] Step 1106: The cache policy management module sets the process's memory usage information caching policy through the memory usage information caching management module.

[0251] Step 1107: After the process's memory usage information has been read for the first time, the memory acquisition and monitoring module obtains the process's memory usage information from the debugging module.

[0252] Step 1108: The debugging module obtains the memory usage information caching policy from the memory usage information caching management module and generates memory usage information according to the memory usage information caching policy.

[0253] Step 1109: The debugging module returns the process's memory usage information to the memory acquisition and monitoring module.

[0254] In summary, in the embodiments of this application, the electronic device caches the memory usage information corresponding to the processes in the first process set, so that when the memory usage information corresponding to the processes in the first process set is not read by the thread for the first time, the thread can read the cached memory usage information from the first storage area. Moreover, the thread does not need to hold the kernel memory lock of the process during the process of reading the memory usage information in the first storage area, thereby reducing the holding of the kernel memory lock of the process.

[0255] Other embodiments of this application provide an electronic device that may include a memory and one or more processors. When the processors execute one or more computer programs stored in the memory, the electronic device performs the various functions or steps described in the method embodiments above. The structure of this electronic device can be referred to... Figure 2and Figure 3 The structure of the electronic device 200 shown.

[0256] Other embodiments of this application provide an electronic device that may include a memory and one or more processors coupled together. The memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device performs the various functions or steps described in the above method embodiments. The structure of this electronic device can be referred to... Figure 2 and Figure 3 The structure of the electronic device 200 shown.

[0257] Other embodiments of this application provide a chip system applied to an electronic device including a memory and a display screen. The chip system includes a processor. When the processor executes computer instructions stored in the memory, it causes the chip system to perform the various functions or steps described in the above method embodiments. The structure of the electronic device can be referred to... Figure 2 and Figure 3 The structure of the electronic device 200 shown.

[0258] This application also provides a computer storage medium that includes computer instructions. When the computer instructions are executed on the electronic device, the electronic device performs various functions or steps performed by the electronic device in the above method embodiments.

[0259] This application also provides a computer program product that, when run on a computer, causes the computer to perform various functions or steps performed by the electronic device in the above method embodiments.

[0260] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0261] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0262] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0263] Furthermore, the functional units in the various embodiments of this application 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 integrated unit can be implemented in hardware or as a software functional unit.

[0264] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0265] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0266] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

[0267] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. An information acquisition method, characterized in that, Applied to electronic devices, the method includes: Obtain a first request, which indicates that the first thread needs to read the memory usage information of the first process; When the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the memory usage information of the first process is read from the first storage area of ​​the electronic device so that the first thread obtains the memory usage information of the first process. The first storage area of ​​the electronic device stores the memory usage of each process in the second process set. The first process set includes each process required by the electronic device to display the first interface in the foreground. The memory usage information of each process in the second process set has been read for the first time. The second process set is included in the first process set.

2. The method according to claim 1, characterized in that, The first request includes the identifier of the first process, and the method further includes: If the identifier of the first process is included in the identifier set, it is determined that the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time. The identifiers in the identifier set are used to indicate that the memory usage information of the corresponding process has been read for the first time.

3. The method according to claim 1 or 2, characterized in that, The method further includes: When the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the memory usage information of the first process is read from the first storage area of ​​the electronic device at the current time point within the valid time period.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: When the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is read for the first time, the memory usage information of the first process is read from the second storage area of ​​the electronic device. The first thread holds the kernel memory lock, and after the kernel memory lock is released, the memory usage information of the first process is stored in the first storage area of ​​the electronic device, and the identifier of the first process is added to the identifier set. The second storage area of ​​the electronic device stores the memory usage information of the first process, and the identifiers in the identifier set are used to indicate that the memory usage information of the corresponding process has been read for the first time.

5. The method according to any one of claims 1-3, characterized in that, The method further includes: When the electronic device is in a user interaction scenario, and the first process is included in the first process set, and the memory usage information of the first process is not being read for the first time, the memory usage information of the first process is read from the second storage area of ​​the electronic device when the current time point is outside the effective time period. The first thread holds the kernel memory lock, and after the kernel memory lock is released, the memory usage information of the first process is stored in the first storage area of ​​the electronic device, and the identifier of the first process is added to the identifier set. The second storage area of ​​the electronic device stores the memory usage information of the first process, and the identifiers in the identifier set are used to indicate that the memory usage information of the corresponding process has been read for the first time.

6. The method according to any one of claims 1-5, characterized in that, The method further includes: When the electronic device is in a user interaction scenario and the first process is not included in the first process set, the memory usage information of the first process is read from the second storage area of ​​the electronic device, and the first thread holds a kernel memory lock so that the first thread can obtain the memory usage information of the first process; The second storage area of ​​the electronic device stores the memory usage information of the first process.

7. The method according to any one of claims 1-6, characterized in that, The first interface is a user interface of the first application currently running in the foreground of the electronic device, and the method further includes: After receiving the first operation performed on the first interface, it is determined that the electronic device is in a user interaction scenario; And / or, displaying a second interface of the first application on the screen of the electronic device, the second interface being a user interface in the first application, to determine that the electronic device is in the user interaction scenario.

8. The method according to claim 7, characterized in that, The method further includes: The first interface of the first application is displayed on the screen of the electronic device; Record the process information of the first process set, which includes the main process corresponding to the first application and the system process corresponding to the first application supported by the operating system of the electronic device.

9. The method according to any one of claims 1-6, characterized in that, The first interface is a user interface supported by the operating system of the electronic device, and the method further includes: After receiving the first operation performed on the first interface, it is determined that the electronic device is in a user interaction scenario.

10. The method according to claim 9, characterized in that, The method further includes: The first interface is displayed on the screen of the electronic device; Record the process information of the first process set, which includes the system processes corresponding to the first interface supported by the operating system of the electronic device.

11. An electronic device, characterized in that, The electronic device includes: one or more processors; when the processors execute one or more computer programs stored in a memory, the electronic device performs the method as described in any one of claims 1-10.

12. An electronic device, characterized in that, The electronic device includes: one or more processors; a memory; wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-10.

13. A chip system, characterized in that, The chip system is applied to an electronic device including a memory and a display screen; the chip system includes a processor; when the processor executes computer instructions stored in the memory, the chip system performs the method as described in any one of claims 1-10.

14. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1-10.

15. A computer program product containing instructions, characterized in that, When the computer program product is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1-10.