Memory allocation method and device, electronic equipment and storage medium
By obtaining the switching state of the AOD function and allocating memory on demand in the off state, the problem of unnecessary memory consumption in heterogeneous AOD technology is solved, and more efficient memory management is achieved, and system stability and response speed are improved.
Patent Information
- Application Number
- CN202510384108.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-07-01
AI Technical Summary
When using heterogeneous AOD technology, electronic devices need to allocate memory for AOD before the kernel is started, resulting in the device still allocating memory even if the AOD function is not enabled, resulting in unnecessary memory consumption.
By obtaining the switch state of the AOD function, when the AOD function is in the off state, the memory allocation operation is performed on the AOD function according to the first memory amount, and the first memory amount is smaller than the second memory amount corresponding to the AOD function, thereby reducing the amount of memory allocated to the AOD.
When AOD is in the off state, reduce the amount of memory allocated for AOD, reduce the memory consumption of electronic devices, and improve the stability and response speed of the system.
Smart Images

Figure CN120234151A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of electronic devices, and particularly relates to a memory allocation method, apparatus, electronic device, and storage medium. Background Art
[0002] With the development of technology, electronic devices can display information such as time and battery power by activating some pixels on the screen during sleep, which is convenient for users to view. This technology is called the always on display (AOD) technology. In order to reduce the power consumption of the electronic device screen when AOD is turned on, the heterogeneous AOD technology has emerged. Heterogeneous AOD can use an auxiliary core with lower power consumption to implement the AOD function, so as to extend the battery life of the electronic device.
[0003] However, since the auxiliary core cannot dynamically map memory addresses, the electronic device needs to allocate memory for AOD before the kernel starts. This results in the situation that even when the AOD function is not turned on, the electronic device still allocates memory for AOD when using heterogeneous AOD, causing unnecessary memory consumption. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a memory allocation method, apparatus, electronic device, and storage medium, which can reduce the memory consumption in the electronic device.
[0005] In a first aspect, the embodiments of this application provide a memory allocation method, which includes: obtaining the switch state of the AOD function; when the AOD function is in the off state, performing a memory allocation operation on the AOD function according to a first memory amount; the first memory amount is less than a second memory amount corresponding to the AOD function.
[0006] In a second aspect, the embodiments of this application provide a memory allocation apparatus, which includes: an obtaining module and an executing module. The obtaining module is used to obtain the switch state of the AOD function; the executing module is used to perform a memory allocation operation on the AOD function according to a first memory amount; the first memory amount is less than a second memory amount corresponding to the AOD function.
[0007] In a third aspect, the embodiments of this application provide an electronic device, which includes a processor and a memory. The memory stores a program or instruction that can run on the processor. When the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.
[0008] In a fourth aspect, the embodiments of this application provide a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0009] Fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is configured to run programs or instructions to implement the method described in the first aspect.
[0010] Sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0011] In the embodiment of the present application, the switch state of the AOD function can be obtained. When the AOD function is in the off state, a memory allocation operation is performed on the AOD function according to the first memory amount, and the first memory amount is less than the second memory amount corresponding to the AOD function. In this way, when the AOD is in the off state, the electronic device can reduce the memory amount allocated for the AOD and reduce the memory consumption of the electronic device. Description of the Drawings
[0012] Figure 1A is a schematic diagram of the structure of a traditional heterogeneous AOD provided by an embodiment of the present application;
[0013] Figure 1B is a schematic diagram of the working process of a traditional heterogeneous AOD provided by an embodiment of the present application;
[0014] Figure 2 is a schematic diagram of the structure of a heterogeneous AOD provided by an embodiment of the present application;
[0015] Figure 3 is one of the flowcharts of the memory allocation method provided by an embodiment of the present application;
[0016] Figure 4 is another flowchart of the memory allocation method provided by an embodiment of the present application;
[0017] Figure 5 is a schematic diagram of the structure of the anti-stampede data format provided by an embodiment of the present application;
[0018] Figure 6 is a schematic diagram of the execution process of the memory allocation method provided by an embodiment of the present application;
[0019] Figure 7 is one of the schematic diagrams of the memory allocation device provided by an embodiment of the present application;
[0020] Figure 8 is a schematic diagram of the structure of the electronic device provided by an embodiment of the present application;
[0021] Figure 9It is a schematic diagram of the hardware structure of the electronic device provided by the embodiments of the present application. Detailed implementation manners
[0022] Next, the technical solutions in the embodiments of the present application will be clearly described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application belong to the scope of protection of the present application.
[0023] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same category, and do not limit the number of objects. For example, the first object can be one or more. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally means an "or" relationship between the associated objects before and after.
[0024] The terms "at least one (item)", "at least one of", etc. in the present application refer to any one, any two or more combinations of the objects it contains. For example, at least one (item) of a, b, and c can represent: "a", "b", "c", "a and b", "a and c", "b and c", and "a, b, and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" means two or more, and its meaning is similar to that of "at least one (item)".
[0025] Next, with reference to the accompanying drawings, the memory allocation method, device, electronic device, and storage medium provided by the embodiments of the present application will be described in detail through specific embodiments and their application scenarios.
[0026] The embodiments of the present application can be applied to the scenario where the electronic device performs memory allocation when the AOD is in the off state in the case of using heterogeneous AOD.
[0027] Taking some specific scenarios of the embodiments of the present application as examples, the memory allocation method provided by the embodiments of the present application will be exemplarily described below.
[0028] Scenario 1
[0029] Assume that the Always-on Display (AOD) of the mobile phone is in the off state. After the user turns on the mobile phone, during the startup process, the mobile phone can obtain the first information indicating the AOD switch state from the first partition, thereby learning that the AOD is in the off state. Then, the mobile phone can adjust the value of the size of the first memory area in the device tree file used to store AOD-related information to 0 and delete the node associated with the AOD driver. Moreover, the mobile phone can calculate, based on the size of the first memory area, the first memory size actually required for other functions in the system excluding the memory size required for the AOD, and then perform memory allocation according to this first memory size. In this way, when allocating memory, the memory size allocated for the AOD can be reduced, and mapping actual memory resources to the first memory area during kernel startup can be avoided, thereby saving memory space and improving the stability and response speed of the system.
[0030] Scenario 2
[0031] Assume that the user turns off the AOD function in the settings of the smartwatch. After the user turns on the smartwatch, during the startup process, the smartwatch can obtain the first information indicating the AOD switch state from the first partition, thereby learning that the AOD is in the off state. Then, the smartwatch can adjust the value of the size of the first memory area in the device tree file used to store AOD-related information to 0 and delete the node associated with the AOD driver. Moreover, the smartwatch can calculate, based on the size of the first memory area, the first memory size actually required for other functions in the system excluding the memory size required for the AOD, and then perform memory allocation according to this first memory size. In this way, when allocating memory, the memory size allocated for the AOD can be reduced, and mapping actual memory resources to the first memory area during kernel startup can be avoided, thereby saving memory space and improving the stability and response speed of the system.
[0032] It should be noted that the above Scenarios 1 to 2 only exemplarily list some scenarios where the embodiments of the present application may be applied. In actual implementation, the embodiments of the present application can also be applied to more scenarios where memory allocation is required arbitrarily. The embodiments of the present application are not limited herein.
[0033] Next, the structure of the heterogeneous AOD will be introduced.
[0034] As Figure 1AAs shown, the structure of a traditional heterogeneous AOD is presented. In the application of an electronic device, the heterogeneous AOD function involves the Application Processor (AP) core of the ARM64 architecture, the Sensor Control Hub (SCP) core of the Reduced Instruction Set Computer–V (RISC-V) architecture, and the Dynamic Random Access Memory (DRAM). Among them, the Picture Memory (PIC_M) and the Deburning Information Memory (DBI_M) are reserved memories allocated during the Little Kernel Bootloader (LK) phase. The display module includes a Display Processing Unit (DPU) or a Liquid Crystal Module (LCM). The System Bus connects each core and module to ensure efficient data transfer and communication between them.
[0035] Among them, the AP core is the core processor of the electronic device. The AP core usually adopts the ARM64 architecture and is used to run the Linux operating system to handle high-performance computing tasks. The auxiliary core usually adopts the RISC-V architecture and can run an open-source Real-Time Operating System (RTOS) or a customized small operating system by the manufacturer. It is used to perform some simple and continuous tasks, such as sensor data reading, low-power music playback, and other background tasks, with lower power consumption and can work even when the electronic device is in the sleep state. The AP core can offload some computing tasks to the auxiliary core to reduce its workload, or when the AP core is in a dormant state, some functions that need to be continuously online can also rely on the auxiliary core to be realized. Information sharing can be carried out between the two through heterogeneous communication. Heterogeneous communication refers to the communication process between processor units of different architectures. For example, between the AP core and the SCP core, the IPI communication is adopted between them, which includes a shared memory to exchange information and a series of interrupts to notify each other.
[0036] The AP core needs to handle a large number of flexible memory mapping requirements. Therefore, the AP core is designed more complexly and has a System Memory Management Unit (SMMU). Thus, it can map when using memory and unmaps when not using memory. Since the low-power auxiliary core is usually designed simply, the mapping relationship between the low-power core and memory is usually a fixed mapping, and once the mapping is established, it cannot be changed. So, the corresponding memory mapping can only be established during the initialization of the low-power core. If you want to use the dynamic mapping function in the auxiliary core, you need to add an SMMU to the chip by imitating the AP.
[0037] Figure 1B shows the working process of the traditional heterogeneous AOD, as Figure 1B shown, the working process of the traditional heterogeneous AOD is as follows:
[0038] 1. Application-side process:
[0039] (1) Modify the native always-on display alarm (AOD alarm): The electronic device can modify the native AOD alarm and set it to a non-wake-up alarm, so that when the system is in sleep, it does not need to wake up the entire system, but only activates the necessary components. The native AOD alarm is a periodic 1-minute wake-up source for updating the always-on display at the whole minute. In the heterogeneous AOD solution, the native AOD alarm is set to a non-wake-up alarm. When the low-power display is on, the low-power core drives the always-on display at the whole minute.
[0040] (2) Obtain the address of PIC_M: The electronic device can obtain the address of PIC_M and expose this address to the application layer through the Direct Memory Access Buffer (DMA_BUF)
[0041] mechanism. PIC_M is the memory area used to store the always-on display pictures.
[0042] (3) Store N pictures into PIC_M: After obtaining the address, the electronic device stores N always-on display pictures into the PIC_M memory area through the application layer.
[0043] (4) Hand over the display control right: The electronic device hands over the display control right to the system bottom layer driver through the application layer so that the bottom layer driver manages the display when the system is in sleep.
[0044] 2. Display driver process:
[0045] (1) Backup aging information to DBI_M: The display driver backs up the aging information of LCM pixels to DBI_M before the system goes into sleep. DBI_M is used to store aging compensation information to prevent display problems caused by screen aging.
[0046] 3. Procedures when the system is in sleep:
[0047] (1) Send an IPI message to notify SCP to turn on AOD: When the system enters the sleep state, in the suspend process of the AOD low-level driver, the electronic device can send an Inter-Processor Interrupt (IPI) message to the SCP (Sensor Control Hub) through the low-level driver to notify the Always-on Display (AOD) task in it to start working. Here, the suspend process is the sleep process of the AP. After suspend, the AP core will enter the sleep state and cannot process software procedures unless the AP is awakened by a wake source. The AOD task is the main thread in the SCP responsible for processing heterogeneous AOD.
[0048] (Sensor Control Hub), notify the Always-on Display task (AOD task) in it to start working. Here, the suspend process is the sleep process of the AP. After suspend, the AP core will enter the sleep state and cannot process software procedures unless the AP is awakened by a wake source. The AOD task is the main thread in the SCP responsible for processing heterogeneous AOD.
[0049] (2) AOD task procedures:
[0050] 1) The AOD task is awakened: The AOD task in the SCP is awakened.
[0051] 2) Select a picture from PIC_M according to the time: The electronic device can select the corresponding always-on display picture from PIC_M through the AOD task according to the current time.
[0052] 3) Update DBI_M and compensate for aging: The electronic device updates the aging information in DBI_M through the AOD task and performs aging compensation.
[0053] 4) Send to display: The electronic device sends the selected picture and the compensated aging information to the display module (DPU / LCM) through the AOD task for display.
[0054] 4. Procedures when the system resumes:
[0055] (1) Send an IPI message to notify SCP to turn off AOD: When the system resumes from the sleep state, the electronic device sends an IPI message through the low-level driver to notify the SCP to turn off the AOD task. Resume is the AP wake-up process, which can trigger the AP core to exit the sleep state.
[0056] (2) The AOD task enters the sleep state: After receiving the IPI message, the AOD task in the SCP enters the sleep state.
[0057] (3) Display control right is returned to the AP: The electronic device returns the display control right to the AP, and the system resumes normal operation.
[0058] As Figure 2 shown, the heterogeneous AOD architecture provided by the embodiment of the present application includes an AP core, an SCP core of the RISC-V architecture, a DRAM, a PIC_M, a DBI_M, a DPU / LCM, a System Bus, a Static Random-Access Memory (SRAM), and a Universal Flash Storage (UFS). Among them, the SRAM is the memory of the auxiliary core used in the embodiment of the present application, the UFS is the module related to the AOD_FLAG function introduced in the embodiment of the present application, and the descriptions of the AP core, the SCP core of the RISC-V architecture, the DRAM, the PIC_M, the DBI_M, the DPU / LCM, and the System Bus can be found in the descriptions in the above embodiments.
[0059] In the embodiment of the present application, when the electronic device uses the heterogeneous AOD, due to the inability of the low-power auxiliary core to dynamically map memory addresses, it causes inconvenience in the use of memory. To solve this problem, specific design can be carried out on the chip of the electronic device. For example, the memory address mapping and management can be achieved by integrating an additional SMMU in the chip. Among them, the main role of the SMMU is to manage and optimize the access to system memory, especially in a complex system including multiple hardware devices. The SMMU is very important in the modern System on Chip (SoC) architecture, especially in playing a key role in the memory access coordination among the Central Processing Unit (CPU), Graphics Processing Unit (GPU), Direct Memory Access (DMA) controller, and other peripherals.
[0060] The embodiment of the present application provides a memory allocation method, device, electronic device, and storage medium, which can obtain the on / off state of the AOD function. When the AOD function is in the off state, a memory allocation operation is performed on the AOD function according to the first memory amount, and the first memory amount is less than the second memory amount corresponding to the AOD function. In this way, when the AOD is in the off state, the electronic device can reduce the memory amount allocated for the AOD use and reduce the memory consumption of the electronic device.
[0061] The execution subject of the memory allocation method provided in the embodiments of this application can be a memory allocation device, which can be an electronic device, or a functional module or functional entity in an electronic device. Hereinafter, an electronic device is taken as an example to illustrate the technical solution provided in the embodiments of this application.
[0062] Figure 3 FIG. shows a flowchart of a memory allocation method provided in the embodiments of this application. As Figure 3 shown, the memory allocation method provided in the embodiments of this application may include the following steps 201 and 202.
[0063] Step 201: The electronic device obtains the switch state of the AOD function.
[0064] In the embodiments of this application, the above AOD is a screen display technology, which can display information such as time and battery power by activating some pixels on the screen when the screen of the electronic device is turned off, without manually turning on the screen, so as to facilitate the user to view.
[0065] Optionally, in the embodiments of this application, in combination with Figure 3 , as Figure 4 shown, the above step 201 can be specifically implemented by the following steps 201a and 201b.
[0066] Step 201a: The electronic device obtains the first information.
[0067] Step 201b: The electronic device determines the switch state of the AOD function according to the first information.
[0068] Optionally, in the embodiments of this application, the above first information is also referred to as AOD_FLAG. AOD_FLAG may include, but is not limited to, any of the following: a flag bit or flag value, a status variable, a key-value pair in a configuration file, the memory content of a memory address, etc.
[0069] For example, taking AOD_FLAG as a flag bit or flag value as an example, AOD_FLAG can use 1 or 0 to represent the state of AOD, where 1 represents that AOD is in the on state and 0 represents that AOD is in the off state.
[0070] For another example, taking AOD_FLAG as a status variable as an example, AOD_FLAG can use 0, 1, 2, or 3 to represent the state of AOD, where 0 represents that AOD is in the off state, 1 represents that AOD is in the on state, 2 represents that the user has turned on the always-on display function but only displays the time, and 3 represents that the user has turned on the always-on display function but only displays notification information.
[0071] For another example, taking AOD_FLAG as a key-value pair in a configuration file, AOD_FLAG can use true or false to represent the status of AOD, where true indicates that AOD is in the on state and false indicates that AOD is in the off state.
[0072] For another example, taking the memory content at a memory address as AOD_FLAG, AOD_FLAG can use 0x80000000 as the memory address for storing the user's settings for the always-on display function, and use 0x00 or 0x01 to represent the status of AOD, where 0x00 indicates that AOD is in the on state and 0x01 indicates that AOD is in the off state.
[0073] In the embodiments of the present application, the electronic device can obtain the first information from the first partition. The above-mentioned first partition is a UFS partition, and UFS is a high-performance storage technology used to store system and user data. In the embodiments of the present application, the first partition is used to store the first information representing the AOD switch state.
[0074] Optionally, in the embodiments of the present application, when the electronic device is started, the electronic device can read the first information, such as LK, from the first partition through the bootloader. The electronic device can access the address in the UFS partition used to store AOD_FLAG through the bootloader, read the first information stored therein, and determine the on / off state of the AOD function according to the first information.
[0075] Step 202, when the AOD function is in the off state, the electronic device performs a memory allocation operation on the AOD function according to the first memory amount; the first memory amount is less than the second memory amount corresponding to the AOD function.
[0076] In one embodiment, the method further includes: determining the first memory amount according to the information value of the second information.
[0077] In the embodiments of the present application, the above-mentioned second information is the information in the device tree for allocating reserved memory, and the above-mentioned information value is the value of the second information. In one embodiment, before determining the first memory amount according to the information value of the second information, the method further includes: when the AOD function is in the off state, updating the second information with the first information value; determining the first memory amount according to the information value of the second information includes: determining the first memory amount according to the first information value.
[0078] Among them, the second memory amount corresponding to the AOD function refers to the memory amount required for the AOD function. The first information value is a value used to update the second information and is related to the on / off state of the AOD function. When the AOD function is in the off state, the first information value can be the second information value, which is used to determine the first memory amount. The first information value is usually stored in the UFS partition and is read and used when the electronic device starts up to decide whether to allocate memory for the AOD function and how much memory to allocate.
[0079] In the embodiments of this application, the above-mentioned first memory amount is determined based on the value in the device tree of the electronic device.
[0080] It should be noted that the above-mentioned device tree, also known as the device tree file, is usually in the.dts format and is used to provide the hardware description of the platform, including device type, address, clock information, interrupt information, etc. The device tree organizes the hardware information in a tree structure and contains multiple nodes, and each node represents a hardware device or bus. The node contains a name and a set of properties, which are used to describe the specific characteristics of the device. The device tree file will be compiled into a device tree binary file, usually in the.dtb format. When the system starts up, the kernel can load and parse the device tree binary file to obtain device information and initialize and configure the hardware according to this information. In the embodiments of this application, the electronic device can modify the properties in the device tree file, that is, modify the second information, to achieve the adjustment of memory allocation. Among them, the kernel is the core part of the operating system in the electronic device, which is responsible for functions such as memory management, file system management, device management, and network management, and at the same time provides an interface for the application layer so that application programs can effectively interact with the hardware.
[0081] In the embodiments of this application, the above-mentioned second memory amount is the value of the reg property of the memory node. The memory node is used to describe the physical memory layout of the system and usually contains three properties: device_type, reg, and initial-mapped-area, where:
[0082] (1) device_type: It is used to represent the device type. For the memory node, its value is "memory".
[0083] (2) initial-mapped-area: It is used to specify the address and size of the initial mapped area, which consists of a valid address, a physical address, and a size.
[0084] (3) reg: It is used to define the address and size of the memory area. Each reg property contains multiple address and size pairs, and each pair consists of two 32-bit units, which respectively represent the address and the size.
[0085] Optionally, in the embodiments of the present application, the above electronic device may adjust the second memory size in the device tree of the electronic device to 0, that is, adjust the second memory size to a value representing a memory size of 0, where the second memory size may be any value representing a memory size, such as the number 0, or the second memory size may also be other values representing a memory size of 0, such as 0x0, indicating a size of 0, that is, this memory area is not used.
[0086] Optionally, in the embodiments of the present application, when the AOD function is in the off state, the electronic device may read the device tree file, then find the node in the device tree for describing AOD-related information, such as, and modify the value of its reg attribute (i.e., the second information), and adjust the value to a value representing 0, so as to change the size of the first memory area for storing AOD-related information to 0.
[0087] In the embodiments of the present application, the above memory is the storage capacity for storing data and programs, usually in gigabytes (GB), and megabytes (MB) can also be used as the unit. 1GB = 1024×1024×1024 = 1073741824 bytes, and 1MB = 1024×1024 = 1048576 bytes.
[0088] In the embodiments of the present application, the above first memory size is the remaining reserved memory size after subtracting the reserved memory size allocated for AOD from the total reserved memory size that the system needs to allocate.
[0089] In the embodiments of the present application, the above reserved memory is a part of the total system memory that is pre-allocated for specific purposes. For example, the memory of the electronic device is 12GB
[0090] Optionally, in the embodiments of the present application, the electronic device may subtract the memory size required for AOD, that is, the second information, from the reserved memory size that the system needs to allocate, so as to obtain the first memory size, and then the electronic device may perform memory allocation using the first memory size to allocate reserved memory for other functions in the system except the AOD function.
[0091] Exemplarily, assume that the total memory size of the electronic device is 12GB, the reserved memory size that the electronic device needs to allocate for various functions is 500MB, and assume that the memory size required for the AOD function is 100MB. Then the electronic device may subtract the memory size required for the AOD function from the total memory size that needs to be allocated for various functions to obtain the memory size required for other functions except the AOD function, that is, the first memory size, which is 500MB - 100MB = 400MB. Thus, the electronic device may use 400MB to perform the allocation of reserved memory, that is, allocate 400MB of memory for the system for use by other functions except the AOD function.
[0092] An embodiment of the present application provides a memory allocation method, which can obtain the on / off state of the AOD function. When the AOD function is in the off state, a memory allocation operation is performed on the AOD function according to a first memory amount, and the first memory amount is less than a second memory amount corresponding to the AOD function. In this way, when the AOD is in the off state, the electronic device can reduce the memory amount allocated for the AOD, thereby reducing the memory consumption of the electronic device.
[0093] Optionally, in an embodiment of the present application, the above second information is stored in the device tree of the electronic device. The memory allocation method provided by the embodiment of the present application further includes the following step 301.
[0094] Step 301: When the AOD function is in the off state, the electronic device removes the node associated with the driver of the AOD function from the device tree.
[0095] In an embodiment of the present application, the above driver of the AOD is a driver program for managing the functions of the AOD. It can obtain the configuration information of the device through the device tree node and initialize and configure the hardware. The node associated with the driver of the AOD in the above device tree describes the hardware resources required for the AOD function, such as memory areas, interrupts, etc. These information are used to initialize and configure the AOD function when the kernel starts.
[0096] Optionally, in an embodiment of the present application, the electronic device can remove the node associated with the driver of the AOD from the device tree, for example, by using the / delete-node / instruction in the device tree overlay file.
[0097] Optionally, in an embodiment of the present application, after removing the node associated with the AOD driver, the electronic device can add an exception handling mechanism to ensure that it can be recovered and processed in a timely manner when an abnormal situation occurs during the kernel startup process. For example, if the kernel attempts to access non-existent resources during startup, the exception can be captured and logged for subsequent troubleshooting and performance optimization.
[0098] In this way, the kernel of the electronic device does not need to load the driver program of the AOD when starting up, thereby preventing the kernel from attempting to access non-existent resources during startup and avoiding system stability problems caused by resource shortages, and improving the overall stability of the system.
[0099] Optionally, in an embodiment of the present application, before the above step 201b, the memory allocation method provided by the embodiment of the present application further includes the following step 401 and step 402, and the above step 201b can be implemented by the following step 403.
[0100] Step 401: The electronic device stores the first information in the second storage area corresponding to the auxiliary core.
[0101] In the embodiments of the present application, the above-mentioned auxiliary core is used to run the AOD function program.
[0102] It should be noted that the above-mentioned auxiliary core is also called a low-power core, which is a low-power processor dedicated to processing specific tasks, such as SCP. In the case of adopting heterogeneous AOD technology, the auxiliary core can be used to run AOD to reduce the power consumption of the main processor. The memory of the above-mentioned auxiliary core is also called SRAM, which is the storage unit inside the auxiliary core. In the embodiments of the present application, the electronic device can use the memory of the auxiliary core to store the first information so that the auxiliary core can quickly access the first information when starting up to determine the on / off state of AOD.
[0103] Step 402: The electronic device obtains the first information from the second storage area through the auxiliary core.
[0104] Step 403: The electronic device determines the on / off state of the AOD function according to the first information through the auxiliary core.
[0105] Optionally, in the embodiments of the present application, after the electronic device stores the first information in the memory of the auxiliary core, the electronic device can read the first information from the memory through the auxiliary core when the auxiliary core is initialized, thereby realizing heterogeneous communication between the main processor (AP) and the auxiliary core of the electronic device through the memory of the auxiliary core.
[0106] Optionally, in the embodiments of the present application, the electronic device can also realize heterogeneous communication between the main processor (AP) and the auxiliary core through shared memory.
[0107] It should be noted that the above-mentioned step 401 can be executed before the above-mentioned step 202, or the above-mentioned step 401 can be executed after the above-mentioned step 202, or the above-mentioned step 401 can be executed simultaneously with the above-mentioned step 202. The specific embodiments of the present application do not make any restrictions.
[0108] In this way, the electronic device can store the first information in the memory of the auxiliary core, so that the auxiliary core can quickly access the first information when starting up, thereby efficiently transmitting the off state of AOD to the auxiliary core and realizing heterogeneous communication.
[0109] Optionally, in the embodiments of the present application, the memory allocation method provided in the embodiments of the present application further includes the following step 501.
[0110] Step 501: The electronic device turns on or off the AOD function through the auxiliary core.
[0111] Optionally, in the embodiments of the present application, after the electronic device determines that the AOD is in the off state through the auxiliary core, the electronic device can stop displaying information such as time and notifications in the screen-off state through the auxiliary core, and stop reading pictures and data from the memory.
[0112] Optionally, in the embodiments of the present application, after the electronic device turns off the AOD function through the auxiliary core, the electronic device can remove the status information related to the AOD in the auxiliary core, such as the first information and other flag bits, to ensure the consistency of the system state.
[0113] Optionally, in the embodiments of the present application, after the electronic device determines that the AOD is in the off state through the auxiliary core, the electronic device can also turn off the Deburn in (DBI) function. DBI is a function to prevent screen aging, which can avoid the screen of the electronic device from aging due to long-term display of specific texts by changing the position and brightness of the displayed content.
[0114] In this way, when the AOD is in the off state, the electronic device can stop executing tasks related to the AOD through the auxiliary core, avoid unnecessary resource occupation, and improve system stability.
[0115] Optionally, in the embodiments of the present application, when the above AOD function is in the off state, the above first information is the second information value; the memory allocation method provided by the embodiments of the present application further includes the following step 601.
[0116] Step 601: When the AOD function is in the on state, update the first information with the third information value.
[0117] In the embodiments of the present application, the above third information value is used to represent that the AOD function is in the on state.
[0118] Optionally, in the embodiments of the present application, the electronic device can monitor the user's on / off operation of the AOD. When the user turns on the AOD function, the electronic device can set the third information value to 1, and when the user turns off the AOD function, the electronic device can set the third information value to 0.
[0119] Optionally, in the embodiments of the present application, when detecting a change in the on / off state of the AOD, the electronic device can update the value of the first file node to reflect the new on / off state of the AOD. For example, when detecting that the user turns on the AOD function, the electronic device can update the value in the AOD_FLAG device file to 1.
[0120] Optionally, in the embodiments of the present application, after the electronic device updates the value of the first file node, the electronic device can write the updated value into the first partition, that is, the UFS partition, to ensure the persistent storage of the AOD on / off state.
[0121] It should be noted that the above step 501 may be executed before the above step 403, or the above step 501 may be executed after the above step 403, or the above step 501 may be executed simultaneously with the above step 403. The specific embodiments of the present application do not limit this.
[0122] In this way, the electronic device can efficiently manage the state of the AOD function, ensuring that the on / off state of AOD can be reacquired even when the electronic device is restarted.
[0123] Optionally, in the embodiments of the present application, the memory allocation method provided in the embodiments of the present application further includes the following step 701.
[0124] Step 701: When the AOD function is in the on state, the electronic device updates the first file node by using the file reading and writing function of the kernel with the third information value.
[0125] Optionally, in the embodiments of the present application, the electronic device may create a first file node associated with the on / off state of AOD and monitor the on / off state of the AOD function.
[0126] In the embodiments of the present application, the above first file node is also referred to as the AOD_FLAG file node, which is used to store the on / off state of AOD, that is, to store the first information. The electronic device can create a file node for sharing the state information of AOD in the system.
[0127] Optionally, in the embodiments of the present application, the electronic device may create a device file as the first file node. For example, create a device file named AOD_FLAG in the / dev directory, and this file can be used to store the on / off state of AOD. Alternatively, the electronic device may also create a specific configuration file as the first file node. For example, create a file named AOD_FLAG in the / etc directory. This file may contain the on / off state of AOD and other related configuration information.
[0128] Optionally, in the embodiments of the present application, the electronic device may obtain the on / off state of AOD in real time by monitoring system settings or user input.
[0129] Optionally, in the embodiments of the present application, the electronic device may create a file node associated with the AOD switch when the kernel starts and monitor the user's on / off operation of AOD at the application layer (Framework). For example, when the user turns on or off the AOD function in the system settings, the application layer can immediately read the user input and notify this state change to the kernel or other relevant components.
[0130] In the embodiments of the present application, the above-mentioned file reading and writing functions of the kernel are interface functions provided by the kernel for reading and writing files in the kernel space. Common file reading and writing functions include read(), write(), etc.
[0131] It should be noted that the Generic Kernel Image (GKI) is a project initiated by Google to provide a common and portable kernel image for Android devices. Due to the limitations of GKI, the kernel interface functions cannot be directly used. In the embodiments of the present application, the electronic device can call the kernel's interface functions by obtaining the function addresses of the kernel. For example, the write() function can be used to write the third information value into the first partition.
[0132] Exemplarily, assume that the electronic device creates a device file named AOD_FLAG when the kernel starts and continuously monitors the user's AOD switch operation in the application layer. When the user turns on the AOD function in the system settings, the electronic device can read the user input through the application layer, notify the kernel of the status change, and then the electronic device can call the kernel's write() function by obtaining the function address of the kernel to write the third information value 1 into the UFS partition to ensure the persistent storage of the AOD switch state.
[0133] In this way, the electronic device can bypass the call restrictions of the kernel interface functions and achieve access to the kernel functions.
[0134] Optionally, in the embodiments of the present application, the above-mentioned first information is the AOD flag bit stored in the anti-trampling data format. The memory allocation method provided by the embodiments of the present application further includes the following step 801.
[0135] Step 801: When the data header or data tail of the first information is abnormal, update the first information with the fourth information value; the fourth information value is used to represent that the AOD function is in the off state.
[0136] In the embodiments of the present application, the above-mentioned anti-trampling data format is a data structure used to protect critical data from being accidentally modified or damaged. For example, AOD_FLAG can use the anti-trampling data format to protect it from being accidentally modified or damaged.
[0137] Optionally, in the embodiments of the present application, the electronic device can detect and prevent data tampering by adding specific identifiers and check values to the head and tail of the data.
[0138] In the embodiments of the present application, the above-mentioned anti-trampling data format consists of the following three parts:
[0139] (1) Header: It includes an identifier and a check value. Among them, the identifier is used to identify the start of the data, usually a fixed value or pattern, so that the starting position of the data can be quickly located when reading the data. The check value is used to verify the integrity of the data, which can be a simple checksum or a more complex hash value.
[0140] (2) Actual data area: It is used to store the actual AOD_FLAG.
[0141] (3) Tail: It includes an identifier and a check value. The identifier in the tail has a similar function to the identifier in the header. The identifier in the tail is used to identify the end of the data, so that the end position of the data can be quickly located when reading the data. The check value in the tail has the same function as the check value in the header.
[0142] Optionally, in the embodiments of the present application, the electronic device can use 0x0A0A0A0A0A0A0A0A as the header identifier and 0xA0A0A0A0A0A0A0A0 as the tail identifier. Then the structure of the anti-stampede data format is as Figure 5 shown.
[0143] Optionally, in the embodiments of the present application, when storing the AOD_FLAG using the anti-stampede data format, the electronic device can first write the header identifier 0x0A0A0A0A0A0A0A0A, then write the actual AOD_FLAG, and finally write the tail identifier 0xA0A0A0A0A0A0A0A0.
[0144] Optionally, in the embodiments of the present application, when reading the AOD_FLAG stored in the anti-stampede data format, the electronic device can first read the header identifier and verify whether it is 0x0A0A0A0A0A0A0A0A. If the header identifier is correct, continue to read the actual AOD_FLAG, and then read the tail identifier and verify whether it is 0xA0A0A0A0A0A0A0A0. If the tail identifier is correct, it is determined that the AOD_FLAG has not been tampered with or damaged.
[0145] Optionally, in the embodiments of the present application, the abnormality of the above identifier means that the header identifier or the tail identifier does not conform to the expected value, that is, the header identifier is not 0x0A0A0A0A0A0A0A0A or the tail identifier is not 0xA0A0A0A0A0A0A0A0, including but not limited to at least one of the following situations: the identifier is accidentally modified to other values, the identifier is cleared, and the identifier is set to a random value.
[0146] Exemplarily, taking the header identifier as an example, assume that the header identifier is accidentally modified to 0xBADBADBADBADBADB. Then, the electronic device can determine that the header identifier 0xBADBADBADBADBADB is different from the correct header identifier 0x0A0A0A0A0A0A0A0A, thereby determining that the data has been tampered with or damaged.
[0147] Also exemplarily, assume that the header identifier is 0xA0A0A0A0A0A0A0A, but the tail identifier is cleared to 0x0000000000000000. Then, the electronic device can determine that the header identifier 0x0A0A0A0A0A0A0A0A is the same as the correct header identifier 0x0A0A0A0A0A0A0A0A, and the tail identifier 0x0000000000000000 is different from the correct 0xA0A0A0A0A0A0A0A0. Thus, the electronic device can determine that the data has been tampered with or damaged.
[0148] Optionally, in the embodiments of the present application, when reading the AOD_FLAG stored in the anti-stampede data format, if the electronic device detects an abnormality in the header or tail identifier, it indicates that the data may have been tampered with or damaged. At this time, the electronic device can set the AOD_FLAG to the default value and update the abnormal identifier to the correct identifier. For example, the default value can be 0, indicating that AOD is in the off state, to prevent data errors caused by accidental overwriting or modification of critical data by other data or programs. Then, the electronic device can update the abnormal AOD_FLAG in the UFS partition to the modified AOD_FLAG, and use the modified AOD_FLAG as a basis to adjust the second information in the device tree to 0, and perform memory allocation based on the first memory size, that is, continue to execute step 202.
[0149] Exemplarily, assume that when reading the AOD_FLAG stored in the anti-stampede data format, the electronic device detects an abnormality in the header or tail identifier. The electronic device can determine that the data has been tampered with or damaged. Then, the electronic device can update the header identifier in the AOD_FLAG stored in the anti-stampede data format to the correct 0x0A0A0A0A0A0A0A0A, then write the default AOD_FLAG value, such as 0, and finally write the correct tail identifier 0xA0A0A0A0A0A0A0A0. Then, the electronic device can update the abnormal AOD_FLAG in the UFS partition to the modified AOD_FLAG and use the modified AOD_FLAG as a basis for subsequent steps.
[0150] In this way, the electronic device can effectively detect whether the data has been tampered with or damaged through the identifiers at the head and tail, ensuring the integrity of the data. Moreover, when the electronic device detects that the data has been tampered with or damaged, it can set the AOD_FLAG to the default value to avoid system instability or crashes caused by data errors.
[0151] Figure 6 It is a schematic diagram of the execution process of the memory allocation method provided by the embodiments of this application. As Figure 6 shown, the memory allocation method provided by the embodiments of this application may include the following steps 10 to 15. Among them, the following steps 10 to 14, step 16, step 17, and step 19 are executed in the underlying layer (i.e., the kernel); the following step 15 is executed through the auxiliary core; the following step 18 is executed in the application layer.
[0152] Step 10: The electronic device loads the device tree node, obtains the AOD_FLAG from the USF partition, and configures the device tree node according to the AOD_FLAG.
[0153] Optionally, in the embodiments of this application, the electronic device may load the SCP device tree node through LK, and read the value of the flag bit from the AOD_FLAG address defined in the UFS partition. Defining AOD_FLAG equal to 1 enables the always-on display, and equal to 0 means it is not enabled. When it is 0, the sizes of PIC_M and DBI_M in the device tree are set to 0 to avoid the kernel mapping two non-existent addresses, resulting in unpredictable consequences. Delete the AOD driver device tree node of the kernel to avoid stability problems caused by resource lack during access.
[0154] Step 11: The electronic device records the AOD_FLAG in the SRAM of the low-power core.
[0155] Optionally, in the embodiments of this application, the electronic device may use the SRAM of the SCP to synchronize the AOD_FLAG to the SCP (i.e., use the SRAM for heterogeneous communication), store the AOD_FLAG in the SRAM, so that the SCP can make a dynamic judgment during initialization.
[0156] Optionally, in the embodiments of this application, the electronic device may also use shared memory to synchronize the AOD_FLAG to the SCP. However, since PIC_M and DBI_M are not allocated, it is necessary to additionally enable shared memory, which makes the logic relatively complex, and it is more convenient to directly map the SRAM of the SCP to LK.
[0157] Step 12: The electronic device determines whether the AOD is in the enabled state based on the AOD_FLAG.
[0158] When AOD_FLAG indicates that AOD is in the on state, perform step 13 below; when AOD_FLAG indicates that AOD is in the off state, perform step 14 below.
[0159] Step 13: The electronic device retains the memory area related to the AOD function and the related driver nodes in the device tree.
[0160] Step 14: The electronic device sets the size of the memory area related to the AOD function in the device tree to 0, removes the related driver nodes, and does not allocate memory for AOD.
[0161] Step 15: The electronic device confirms through SCP that AOD_FLAG in SRAM is in the off state, and turns off AOD and DBI.
[0162] Step 16: The electronic device creates a kernel AOD_FLAG file node.
[0163] Step 17: The electronic device obtains the address of the file read and write function of the kernel.
[0164] Step 18: The electronic device listens to the on / off state of AOD through the application layer, sets 1 to the AOD_FLAG file node when AOD is detected to be turned on, and sets 0 to the AOD_FLAG file node when AOD is detected to be turned off.
[0165] Step 19: Write the value of AOD_FLAG to the UFS partition.
[0166] The memory allocation method provided by the embodiments of this application can optimize the memory size of heterogeneous AOD. When the user does not turn on the always-on display function, it can return PIC_M and DBI_M to the system. In actual applications, it optimizes approximately 83 mebibytes (MiB) of memory. The specific optimization effects are as follows:
[0167] Before optimization: The system reserved a memory area for AOD from address 0x000000008a000000 to address 0x000000008fe3ffff, with a total size of 96512 kibibytes (KiB).
[0168] After optimization: The memory area reserved by the system for the AOD function is reduced to from address 0x000000008f000000 to address 0x000000008fb1ffff, with a total size of 11392 KiB.
[0169] In addition, while optimizing the memory, this solution also achieves the effect of completely isolating heterogeneous AOD from the system, ensuring stability in different scenarios.
[0170] Each of the above method embodiments, or various possible implementation manners in each method embodiment, can be executed independently, or can be combined with any two or more of them. It can be specifically determined according to actual usage requirements, and the embodiments of the present application do not limit this.
[0171] For the memory allocation method provided by the embodiments of the present application, the execution subject can be a memory allocation device. In the embodiments of the present application, taking the memory allocation device executing the memory allocation method as an example, the memory allocation device provided by the embodiments of the present application is described.
[0172] Figure 7 A possible structural schematic diagram of the memory allocation device involved in some embodiments of the present application is shown. As Figure 7 shown, the memory allocation device 70 may include: an acquisition module 71 and an execution module 72.
[0173] The above acquisition module 71 is used to acquire the switch state of the AOD function.
[0174] The above execution module 72 is used to perform a memory allocation operation on the AOD function according to the first memory amount; the first memory amount is less than the second memory amount corresponding to the AOD function.
[0175] In a possible implementation manner, the memory allocation device 70 may further include: a determination module 73, and the determination module 73 is used to determine the first memory amount according to the information value of the second information.
[0176] In a possible implementation manner, the memory allocation device 70 may further include: an update module 74, and the update module 74 is used to: when the AOD function is in the off state, update the second information by using the first information value. The above determination module 73 is further used to: determine the first memory amount according to the first information value.
[0177] In a possible implementation manner, the above second information is stored in the device tree of the electronic device; the memory allocation device 70 may further include: a removal module 75, and the above removal module 75 is used to: when the AOD function is in the off state, remove the node associated with the driver of the AOD function in the device tree.
[0178] In a possible implementation manner, the above acquisition module 71 is further used to: acquire the first information; determine the switch state of the AOD function according to the first information.
[0179] In a possible implementation, the memory allocation device 70 may further include: a storage module 76, where the storage module 76 is configured to: store the first information in a second storage area corresponding to the auxiliary core; the auxiliary core is used to run the AOD function program; the obtaining module 71 is further configured to obtain the first information from the second storage area through the auxiliary core; the obtaining module 71 is further configured to determine the on / off state of the AOD function according to the first information through the auxiliary core.
[0180] In a possible implementation, the memory allocation device 70 may further include: a control module 77, where the control module 77 is configured to: turn on or off the AOD function through the auxiliary core.
[0181] In a possible implementation, when the AOD function is in the off state, the first information is a second information value; the memory allocation device 70 may further include: an update module 74. The update module 74 is configured to: when the AOD function is in the on state, update the first information with a third information value; the third information value is used to represent that the AOD function is in the on state.
[0182] In a possible implementation, the first information is a first file node. The update module 74 is further configured to: when the AOD function is in the on state, update the first file node with the third information value through the file reading and writing function of the kernel.
[0183] In a possible implementation, the first information is an AOD flag bit stored in an anti-trampling data format. The update module 74 is further configured to: when an abnormality occurs in the data header or data tail of the first information, update the first information with a fourth information value; the fourth information value is used to represent that the AOD function is in the off state.
[0184] In the embodiment of the present application, a memory allocation device is provided, which can obtain the on / off state of the AOD function. When the AOD function is in the off state, a memory allocation operation is performed on the AOD function according to the first memory amount, and the first memory amount is less than the second memory amount corresponding to the AOD function. In this way, the memory allocation device can reduce the memory amount allocated for the AOD when the AOD is in the off state, reducing the memory consumption of the electronic device.
[0185] The memory allocation device in the embodiments of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than terminals. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a Mobile Internet Device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. It can also be a server, a Network Attached Storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.
[0186] The memory allocation device in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.
[0187] The memory allocation device provided in the embodiments of the present application can implement each process implemented in the above method embodiments. To avoid repetition, details are not described here again.
[0188] Optionally, as Figure 8 shown, the embodiments of the present application further provide an electronic device 1000, including a processor 1001 and a memory 1002. A program or instruction that can run on the processor 1001 is stored on the memory 1002. When the program or instruction is executed by the processor 1001, it implements each step of the above memory allocation method embodiment and can achieve the same technical effect. To avoid repetition, details are not described here again.
[0189] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0190] Figure 9 A schematic diagram of the hardware structure of an electronic device for implementing the embodiments of the present application.
[0191] The electronic device 100 includes, but is not limited to: a radio frequency unit 101, a network module 102, an audio output unit 103, an input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, a processor 110, and other components.
[0192] Those skilled in the art can understand that the electronic device 100 may further include a power supply (such as a battery) for supplying power to each component. The power supply can be logically connected to the processor 110 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. Figure 9 The structure of the electronic device shown does not limit the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0193] Among them, the above-mentioned processor 110 is used to obtain the switch state of the AOD function.
[0194] The above-mentioned processor 110 is used to perform a memory allocation operation on the AOD function according to a first memory amount when the AOD function is in the off state; the first memory amount is less than a second memory amount corresponding to the AOD function.
[0195] Optionally, the above-mentioned processor 110 is further used for:
[0196] Determine the first memory amount according to the information value of the second information.
[0197] Optionally, the above-mentioned processor 110 is further used for:
[0198] Update the second information with a first information value when the AOD function is in the off state;
[0199] The above-mentioned determining the first memory amount according to the information value of the second information includes:
[0200] Determine the first memory amount according to the first information value.
[0201] Optionally, the above-mentioned second information is stored in the device tree of the electronic device;
[0202] The above-mentioned processor 110 is further used for:
[0203] Remove the node associated with the driver of the AOD function in the device tree when the AOD function is in the off state.
[0204] Optionally, the above-mentioned processor 110 is further used for:
[0205] Obtain the first information;
[0206] Determine the on / off state of the AOD function according to the first information.
[0207] Optionally, the above-mentioned processor 110 is further configured to:
[0208] Store the first information in the second storage area corresponding to the auxiliary core; the auxiliary core is used to run the AOD function program;
[0209] Obtain the first information from the second storage area through the auxiliary core;
[0210] Determine the on / off state of the AOD function according to the first information through the auxiliary core.
[0211] Optionally, the above-mentioned processor 110 is further configured to:
[0212] Turn on or off the AOD function through the auxiliary core.
[0213] Optionally, when the AOD function is in the off state, the above-mentioned first information is the second information value; the above-mentioned processor 110 is further configured to:
[0214] When the AOD function is in the on state, update the first information with the third information value; the third information value is used to represent that the AOD function is in the on state.
[0215] Optionally, the above-mentioned first information is the first file node;
[0216] The above-mentioned processor 110 is further configured to:
[0217] When the AOD function is in the on state, update the first file node with the third information value through the file reading and writing function of the kernel.
[0218] Optionally, the above-mentioned first information is the AOD flag bit stored in the anti-trampling data format;
[0219] The above-mentioned processor 110 is further configured to:
[0220] When an abnormality occurs in the data header or data tail of the first information, update the first information with the fourth information value; the fourth information value is used to represent that the AOD function is in the off state.
[0221] An embodiment of the present application provides an electronic device, which can obtain the on / off state of the AOD function. When the AOD function is in the off state, perform a memory allocation operation on the AOD function according to the first memory amount, and the first memory amount is less than the second memory amount corresponding to the AOD function. In this way, the electronic device can reduce the memory amount allocated for the AOD when the AOD is in the off state, and reduce the memory consumption of the electronic device.
[0222] The electronic device provided by the embodiment of the present application can implement each process implemented by the above method embodiment and achieve the same technical effect. To avoid repetition, it will not be described here again. For the beneficial effects of various implementation manners in this embodiment, reference may be specifically made to the beneficial effects of the corresponding implementation manners in the above method embodiment. To avoid repetition, it will not be described here again.
[0223] It should be understood that in the embodiment of the present application, the input unit 104 may include a Graphics Processing Unit (GPU) 1041 and a microphone 1042. The graphics processor 1041 processes the image data of the static pictures or videos obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. The other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, and a joystick, which will not be described here again.
[0224] The memory 109 can be used to store software programs and various data. The memory 109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data. Among them, the first storage area can store an operating system, application programs or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 109 can include a volatile memory or a non-volatile memory, or the memory 109 can include both a volatile memory and a non-volatile memory. Among them, the non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synch link DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM). The memory 109 in the embodiments of the present application includes, but is not limited to, these and any other suitable types of memories.
[0225] The processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor and a modem processor. Among them, the application processor mainly processes operations related to the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above modem processor may not be integrated into the processor 110 either.
[0226] The embodiments of the present application also provide a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements each process of the above embodiment of the memory allocation method and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0227] Among them, the processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media such as computer read-only memory ROM, random access memory RAM, magnetic disks, or optical discs, etc.
[0228] Another embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above embodiment of the memory allocation method, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0229] It should be understood that the chip mentioned in the embodiments of the present application may also be referred to as a system-on-chip, system chip, chip system, or system-on-chip, etc.
[0230] The embodiments of the present application provide a computer program product. The program product is stored in a storage medium and is executed by at least one processor to implement each process of the above embodiment of the memory allocation method, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0231] It should be noted that in this article, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device including that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the reverse order according to the functions involved. For example, the described method may be executed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, the features described with reference to certain examples may be combined in other examples.
[0232] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present application.
[0233] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative rather than restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.
Claims
1. A memory allocation method, characterized in that: include: Get the on / off status of the AOD function; When the AOD function is in a closed state, performing a memory allocation operation on the AOD function according to a first memory amount; The first memory amount is smaller than a second memory amount corresponding to the AOD function.
2. The method according to claim 1, characterized in that The method further comprises: The first memory amount is determined according to the information value of the second information.
3. The method according to claim 2, characterized in that Before determining the first memory amount according to the information value of the second information, the method further includes: When the AOD function is in an off state, updating the second information using the first information value; The determining the first memory amount according to the information value of the second information includes: The first memory amount is determined according to the first information value.
4. The method according to claim 1, characterized in that The second information is stored in a device tree of the electronic device; The method further comprises: When the AOD function is in a disabled state, a node associated with a driver of the AOD function in the device tree is removed.
5. The method according to claim 1, characterized in that The obtaining of the on / off state of the AOD function includes: Obtaining first information; The on / off state of the AOD function is determined according to the first information.
6. The method according to claim 5, characterized in that Before determining the on / off state of the AOD function according to the first information, the method further includes: storing the first information in a second storage area corresponding to the auxiliary core; the auxiliary core is used to run the AOD function program; acquiring the first information from the second storage area through the auxiliary core; The determining the on / off state of the AOD function according to the first information includes: The auxiliary core determines the on / off state of the AOD function according to the first information.
7. The method according to claim 6, characterized in that The method further comprises: The AOD function is enabled or disabled by the auxiliary core.
8. The method according to claim 5, characterized in that When the AOD function is in a turned-off state, the first information is a second information value; and the method further includes: When the AOD function is in an on state, the first information is updated using a third information value; the third information value is used to indicate that the AOD function is in an on state.
9. The method according to claim 8, characterized in that The first information is a first file node; The method further comprises: When the AOD function is turned on, the first file node is updated using the third information value through the file read and write function of the kernel.
10. The method according to claim 5, characterized in that The first information is an AOD flag bit stored in an anti-trampling data format; The method further comprises: In the case that the data header or the data tail of the first information is abnormal, the first information is updated using a fourth information value; the fourth information value is used to indicate that the AOD function is in a closed state.
11. A memory allocation device, characterized in that: include: Get module and execute module; The acquisition module is used to acquire the switch status of the AOD function; The execution module is used to perform a memory allocation operation on the AOD function according to a first memory amount; the first memory amount is smaller than a second memory amount corresponding to the AOD function.
12. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the memory allocation method as described in any one of claims 1 to 10 are implemented.
13. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the memory allocation method according to any one of claims 1 to 10 are implemented.
14. A computer program product, characterized in that The program product is stored in a storage medium, and the program product is executed by at least one processor to implement the memory allocation method according to any one of claims 1 to 10.