Memory suspending methods, devices, electronic equipment and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-26
- Publication Date
- 2026-08-14
AI Technical Summary
但是上述方法中,电子设备进入暂停工作的状态后仍然会消耗电能
[0009]本申请实施例提供的内存挂起方法、装置、电子设备及存储介质,将内存数据存储于存储器后,将待移出内存段中存储的内存数据转移至待移入内存段中,由于此时内存数据均存储于待移入内存段中,待移出内存段中未存储内存数据,因此将待移出内存段断电,不会对内存数据造成影响,存储器仍然能够完成对内存数据的存储工作,从而在保证存储器正常工作的同时,节约了一部分内存段所消耗的电能。
Smart Images

Figure CN115408063B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a memory suspending method, apparatus, electronic device, and storage medium. Background Technology
[0002] For electronic devices, energy consumption is one of the key factors affecting system performance, and researching how to save energy in electronic devices is of great significance.
[0003] In related technologies, the method of suspending memory (STR, Suspend to RAM) is used to reduce the power consumption of electronic devices. Suspending memory refers to disconnecting power to all components in an electronic device except for RAM (Random Access Memory) when it is not in use, thus putting the electronic device into a suspended state. However, even in this suspended state, the electronic device still consumes power. Summary of the Invention
[0004] This application provides a memory suspending method, apparatus, electronic device, and storage medium, which can achieve the effect of saving power. The technical solution is as follows: According to one aspect of the embodiments of this application, a memory suspension method is provided, the method comprising: In response to a memory suspend instruction, memory data stored in a memory segment to be moved out is transferred to a memory segment to be moved in, wherein the memory segment to be moved out and the memory segment to be moved in are different memory segments in the memory, and the memory data includes data being run by the electronic device when the memory suspend instruction is received; Power off the memory segment to be moved out.
[0005] According to another aspect of the embodiments of this application, a memory suspending device is provided, the device comprising: A data transfer module is used to transfer memory data stored in a memory segment to be moved out to a memory segment to be moved in in response to a memory suspend command, wherein the memory segment to be moved out and the memory segment to be moved in are different memory segments in the memory, and the memory data includes the data that the electronic device was running when the memory suspend command was received; The power-off module is used to power off the memory segment to be moved out.
[0006] According to another aspect of the embodiments of this application, an electronic device is provided, the electronic device including a processor, a controller and a memory; the memory stores at least one instruction, the at least one instruction being executed by the processor and the controller to implement the memory suspension method as described above.
[0007] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, the storage medium storing at least one instruction, the at least one instruction being executed by a processor and controller in an electronic device to implement the memory suspension method as described above.
[0008] According to another aspect of the embodiments of this application, a computer program product is provided, which stores at least one piece of program code, said at least one piece of program code being loaded and executed by a processor and controller in an electronic device to implement the memory suspension method described above.
[0009] The memory suspending method, apparatus, electronic device, and storage medium provided in this application store memory data in a memory storage device. Then, the memory data stored in the memory segment to be moved out is transferred to the memory segment to be moved in. Since the memory data is stored in the memory segment to be moved in and no memory data is stored in the memory segment to be moved out, turning off the power to the memory segment to be moved out will not affect the memory data. The memory storage device can still complete the storage of memory data, thereby saving some of the power consumed by the memory segment while ensuring the normal operation of the memory storage device. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 A flowchart illustrating a memory suspension method provided in an exemplary embodiment of this application is shown; Figure 2 A flowchart illustrating a memory suspension method provided in an exemplary embodiment of this application is shown; Figure 3 A schematic diagram illustrating a memory data transfer process provided in an exemplary embodiment of this application is shown; Figure 4 A schematic diagram of a memory segment provided in an exemplary embodiment of this application is shown; Figure 5 This application illustrates a system architecture diagram of a memory suspension method provided in an exemplary embodiment. Figure 6 A flowchart illustrating a memory suspension method provided in an exemplary embodiment of this application is shown; Figure 7 This application illustrates a system architecture diagram of a memory suspension method provided in an exemplary embodiment. Figure 8 This illustration shows a structural block diagram of a memory suspending device provided in an exemplary embodiment of this application; Figure 9 This illustration shows a structural block diagram of a memory suspending device provided in an exemplary embodiment of this application; Figure 10 The diagram shows a structural block diagram of a terminal provided in an exemplary embodiment of this application. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0013] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0014] Before providing a detailed description of the embodiments of this application, the concepts involved are explained as follows: (1) Bitmap: A data storage format that stores data bit by bit. A Bitmap consists of multiple bytes, each of which can be used to store a certain state of an object.
[0015] (2) Suspend state: Suspend state refers to a sleep state of electronic devices. In this state, electronic devices enter a low power state and only the memory is retained for self-refresh. The data that the electronic device runs when it enters the Suspend state is stored in the memory, and other devices except the memory are powered off.
[0016] This application provides a memory suspension method, the execution subject of which is an electronic device, such as a mobile phone, desktop computer, laptop computer, tablet computer, smart TV, smart speaker, vehicle terminal, smart robot and other types of electronic devices.
[0017] The memory suspension method provided in this application embodiment can be applied to any scenario where state switching is required.
[0018] For example, when an electronic device enters the Suspend state, it stores the currently running data in the memory and powers off all other components except for that memory. The state management system determines the occupancy status of each memory block in the memory and, based on this status, identifies the memory segments to be moved out and the memory segments to be moved in. It then notifies the controller of the occupancy status of each memory block and the corresponding memory segments to be moved out and moved in. The controller transfers the memory data from the occupied memory blocks in the memory segment to be moved out to the unoccupied memory blocks in the memory segment to be moved in, thus clearing the memory segment to be moved out. Since there is no data stored in the memory segment at this point, it can be powered off, which does not affect the normal operation of the memory and saves some energy.
[0019] Figure 1 A flowchart illustrating a memory suspending method provided in an exemplary embodiment of this application is shown below. Figure 1 This method is applied in electronic devices, and the method includes: Step 101: In response to the memory suspend instruction, transfer the memory data stored in the memory segment to be moved out to the memory segment to be moved in.
[0020] The electronic device includes a memory, and the memory suspend instruction is an instruction that instructs the electronic device to enter the suspend state. The memory suspend instruction can be triggered in various ways. For example, if the user does not need to use the electronic device temporarily, a screen lock operation is performed on the electronic device, and the electronic device generates a memory suspend instruction in response to the screen lock operation.
[0021] In response to a memory suspend command, the electronic device determines the memory segment to be moved out and the memory segment to be moved in, and transfers the memory data stored in the memory segment to be moved out to the memory segment to be moved in. The memory segment to be moved out and the memory segment to be moved in are different memory segments in the memory. The memory segment to be moved out refers to the memory segment from which stored memory data needs to be moved out, and the memory segment to be moved in refers to the memory segment from which memory data stored in other memory segments needs to be moved in. This memory data includes data being processed by the electronic device at the time the memory suspend command is received; for example, the memory data may include data being processed by one or more applications currently running on the electronic device.
[0022] Step 102: Power off the memory segment to be moved out.
[0023] After transferring the memory data from the memory segment to be moved out to the memory segment to be moved in, the electronic device disconnects the power to the memory segment to be moved out, that is, it does not power on the memory segment to be moved out.
[0024] This application provides a memory suspending method. In response to a memory suspending command, memory data stored in the memory segment to be moved out is transferred to the memory segment to be moved in. Since the memory data is stored in the memory segment to be moved in at this time, and no memory data is stored in the memory segment to be moved out, powering off the memory segment to be moved out will not affect the memory data. The memory can still complete the storage of memory data, thereby saving some of the power consumed by the memory segment while ensuring the normal operation of the memory.
[0025] Figure 2 A flowchart illustrating a memory suspending method provided in an exemplary embodiment of this application is shown below. Figure 2 This method is applied in electronic devices, and the method includes: Step 201: In response to the memory suspend command, obtain memory block occupancy information and memory segment indication information.
[0026] Electronic devices include memory, which can be of various types, such as RAM (Random Access Memory), which includes DRAM (Dynamic Random Access Memory) and SRAM (Static Random Access Memory). Memory comprises multiple memory segments, each containing multiple memory blocks. The current memory data of the electronic device includes the data being processed when a memory suspend instruction is received.
[0027] This memory block occupancy information indicates the status of memory blocks. A memory system comprises multiple memory blocks. Some memory blocks store data, meaning they are occupied; others do not store data, meaning they are unoccupied. This memory block occupancy information indicates which memory blocks are occupied and which are unoccupied.
[0028] This memory segment indication information identifies memory segments to be moved out and memory segments to be moved in. A memory segment to be moved out refers to a memory segment from which stored data needs to be moved out, while a memory segment to be moved in refers to a memory segment from which data stored in other memory segments needs to be moved in. The memory consists of multiple memory segments, each containing multiple contiguous memory blocks. This memory segment indication information indicates which memory segments in the memory belong to the memory segment to be moved out and which belong to the memory segment to be moved in.
[0029] In some embodiments, in response to a memory suspend instruction, the electronic device stores the data it is currently running in memory. For example, the data being run by the electronic device includes multiple sub-data items, and the electronic device stores the multiple sub-data items in multiple memory blocks of the memory according to a pre-set storage path, or the electronic device randomly stores the multiple sub-data items in multiple memory blocks of the memory.
[0030] In some embodiments, the memory suspend instruction is also used to instruct the electronic device to power off other devices besides the memory. In response to the memory suspend instruction, the electronic device powers off other devices besides the memory. At this time, the electronic device suspends operation and is in a low-power state.
[0031] In some embodiments, the memory block occupancy information includes memory information corresponding to each memory block in the memory, and the memory information corresponding to each memory block stores a first mark or a second mark, wherein the first mark indicates that the memory block is occupied, and the second mark indicates that the memory block is not occupied.
[0032] In this process, for any memory block in the memory, the electronic device determines whether the memory block is occupied. If the memory block is occupied, meaning it stores memory data, a first flag is stored in the memory information corresponding to that memory block. This first flag indicates that the memory block corresponding to the memory information storing the first flag is occupied. If the memory block is not occupied, meaning it does not store memory data, a second flag is stored in the memory information corresponding to that memory block. This second flag indicates that the memory block corresponding to the memory information storing the second flag is not occupied. Therefore, the electronic device indicates whether the corresponding memory block is occupied by storing the first and second flags in the memory information. The first and second flags are different; for example, the first flag might be a first character, and the second flag might be a second character, where the first character is 1 and the second character is 0.
[0033] In some embodiments, memory block occupancy information consists of multiple consecutive memory information entries, with one memory information entry corresponding to one memory block. The correspondence between memory information entries and memory blocks is determined based on their arrangement order. For example, if the total number of memory information entries is the same as the total number of memory blocks, then the i-th memory information entry corresponds to the i-th memory block, where i is a positive integer not greater than the total number. Alternatively, the memory block occupancy information could be a memory block occupancy bitmap, where one memory information entry represents one byte within the bitmap. If multiple consecutive memory information entries are numbered sequentially starting from 0, then the sequence number of the i-th memory information entry is i-1.
[0034] In some embodiments, the process of generating memory segment indication information includes: determining the memory segment to be moved out and the memory segment to be moved in in the memory; adding the identifier corresponding to the memory segment to be moved out to a first identifier group; adding the identifier corresponding to the memory segment to be moved in to a second identifier group; and combining the first identifier group and the second identifier group to constitute the memory segment indication information.
[0035] The memory comprises multiple contiguous memory blocks. These contiguous memory blocks are segmented to obtain multiple contiguous memory segments, each of which includes at least one memory block. For example, an electronic device determines a target quantity, and then sequentially identifies the target quantity of memory blocks as a memory segment, thus obtaining multiple memory segments. Within these multiple memory segments, the electronic device identifies the memory segments from which stored memory data needs to be moved out, and the memory segments from which memory data stored in other memory segments needs to be moved in, and uses memory segment indication information to represent these identified memory segments. This memory segment indication information includes a first identifier group and a second identifier group. The first identifier group includes the identifier of the memory segment to be moved out, and the second identifier group includes the identifier of the memory segment to be moved in. Therefore, the first identifier group determines which memory segments are to be moved out, and the second identifier group determines which memory segments are to be moved in.
[0036] In some embodiments, the electronic device determines memory segments to be removed and memory segments to be moved into the memory, including: determining power-off memory segments in the memory, and determining memory segments to be removed and memory segments to be moved into within the power-off memory segments. The memory includes power-off memory segments and non-power-off memory segments. Power-off memory segments are those whose normal operation is not affected by a power outage, while non-power-off memory segments are those whose normal operation is affected by a power outage. Therefore, to ensure the normal operation of the memory, the electronic device determines memory segments to be removed and memory segments to be moved into within the power-off memory segments. For example, non-power-off memory segments include memory segments storing memory block occupancy information or memory segments storing memory segment indication information. For example, power-off memory segments include memory segments in the power-down region of SRAM or memory segments in the PASR (Partial Array Self-Refresh) region of DRAM.
[0037] In some embodiments, the electronic device determines a memory segment to be moved out and a memory segment to be moved in within a power-off memory segment, including: for any power-off memory segment, determining a first quantity and a second quantity, the first quantity being the number of occupied memory blocks in the memory segment and the second quantity being the number of unoccupied memory blocks in the memory segment; in response to the first quantity being less than the second quantity, determining the memory segment as a memory segment to be moved out; and in response to the first quantity being not less than the second quantity, determining the memory segment as a memory segment to be moved in.
[0038] If the first quantity is less than the second quantity, it means that the number of occupied memory blocks in this memory segment is less than the number of unoccupied memory blocks. Since the utilization rate of this memory segment is relatively low, we can consider transferring the memory data stored in this memory segment to other memory segments, that is, we determine this memory segment as the memory segment to be moved out. If the first quantity is not less than the second quantity, it means that the number of occupied memory blocks in this memory segment is not less than the number of unoccupied memory blocks. Since the utilization rate of this memory segment is relatively high, we can consider transferring the memory data stored in other memory segments to this memory segment, that is, we determine this memory segment as the memory segment to be moved in.
[0039] In some embodiments, the electronic device determines a memory segment to be moved out and a memory segment to be moved in within a power-off memory segment, including: determining an initial memory segment to be moved out and an initial memory segment to be moved in within the power-off memory segment; determining a third quantity and a fourth quantity, wherein the third quantity is the total number of occupied memory blocks in the initial memory segment to be moved out, and the fourth quantity is the total number of unoccupied memory blocks in the initial memory segment to be moved in; and in response to a third quantity being greater than a fourth quantity, changing at least one memory segment to be moved out to a memory segment to be moved in, such that the changed third quantity is not greater than the changed fourth quantity.
[0040] The electronic device determines the initial memory segment to be moved out and the initial memory segment to be moved in, for example, by using the method described above based on the first and second quantities. Then, the electronic device determines the third and fourth quantities. If the third quantity is greater than the fourth quantity, it means that the number of occupied memory blocks in the memory segment to be moved out is greater than the number of unoccupied memory blocks in the memory segment to be moved in. Therefore, it is impossible to transfer all the memory data stored in the memory segment to be moved out to the memory segment to be moved in. The number of occupied memory blocks in the memory segment to be moved out needs to be no greater than the number of unoccupied memory blocks in the memory segment to be moved in. Thus, the electronic device can change at least one memory segment belonging to the memory segment to be moved out to belong to the memory segment to be moved in. At this point, the number of memory segments to be moved out decreases, and the number of occupied memory blocks in the memory segment to be moved out also decreases. Conversely, the number of memory segments to be moved in increases, and the number of unoccupied memory blocks in the memory segment to be moved in also increases. For example, an electronic device first changes a memory segment that belongs to the memory segment to be moved out to the memory segment to be moved in. If the third number after the change is not greater than the fourth number after the change, the electronic device completes the classification of the memory segment to be moved out and the memory segment to be moved in. If the third number after the change is still greater than the fourth number after the change, the electronic device continues to change a memory segment that belongs to the memory segment to be moved out to the memory segment to be moved in, until the third number after the change is not greater than the fourth number after the change.
[0041] In some embodiments, the memory block occupancy information includes memory information corresponding to each memory block in the memory. Each memory block's memory information stores a first marker or a second marker. The first marker indicates that the memory block is occupied, and the second marker indicates that the memory block is not occupied. Therefore, the electronic device can determine the number of occupied and unoccupied memory blocks based on the number of first and second markers in the memory block occupancy information. Specifically, for any power-off memory segment, the electronic device acquires memory information corresponding to multiple memory blocks in that memory segment, determines the number of first markers stored in the acquired memory information as a first quantity, which is the number of occupied memory blocks in that memory segment, and determines the number of second markers stored in the acquired memory information as a second quantity, which is the number of unoccupied memory blocks in that memory segment.
[0042] In some embodiments, since there is a one-to-one correspondence between memory blocks and memory information, after dividing the multiple memory blocks into multiple memory segments, the multiple memory information can be further divided into multiple memory information sets according to the segmentation method of the multiple memory blocks. Then, the memory segments and memory information sets correspond one-to-one. Therefore, the electronic device can use the identifier of the memory information set as the identifier of the memory segment. The subsequent electronic device can determine the memory information set based on this identifier, and then determine the memory segment corresponding to the memory information set. In some embodiments, since the memory information set includes multiple consecutive memory information, the sequence number of the memory information in the memory information set is used as the identifier of the memory information set. The sequence number of the memory information indicates the order of the memory information among the multiple memory information. For example, the identifier of the memory information set is the sequence number of the first memory information and the sequence number of the last memory information in the memory information set. For example, if the sequence number of the i-th memory information is i-1, and the identifier of the memory information set is [0, 8], then the memory information set includes multiple memory information from the first memory information to the ninth memory information.
[0043] In some embodiments, the electronic device obtains first address information of memory block occupancy information and second address information of memory segment indication information. Based on the first address information, it queries the memory block occupancy information, and based on the second address information, it queries the memory segment indication information. The first address information is the address information of the memory segment storing the memory block occupancy information, and the second address information is the address information of the memory segment indication information.
[0044] For example, the first address information includes a first starting address and a first length corresponding to the memory segment storing the memory block occupancy information, and the second address information includes a second starting address and a second length corresponding to the memory segment storing the memory segment indication information. The electronic device determines the memory segment corresponding to the first starting address and the first length, and obtains the memory block occupancy information from the determined memory segment. The electronic device also determines the memory segment corresponding to the second starting address and the second length, and obtains the memory segment indication information from the determined memory segment.
[0045] Step 202: Based on memory block occupancy information and memory segment indication information, identify the memory blocks that are occupied in the memory segment to be moved out as memory blocks to be moved out, identify the memory blocks that are not occupied in the memory segment to be moved in as memory blocks to be moved in, and transfer the memory data stored in the memory blocks to be moved out to the memory blocks to be moved in.
[0046] Since memory block occupancy information indicates the status of memory block usage, and memory segment indication information indicates the memory segments to be moved out and moved in, electronic devices can determine the memory segments to be moved out and moved in based on the memory segment indication information. Then, based on the memory block occupancy information, they can determine whether the memory blocks in the memory segments to be moved out and moved in are occupied. Therefore, they can identify the memory blocks to be moved out and moved in within the memory segments. Here, the memory block to be moved out refers to the memory block from which memory data needs to be transferred out, and the memory block to be moved in refers to the memory block from which memory data needs to be transferred in.
[0047] In some embodiments, the memory block occupancy information includes memory information corresponding to each memory block in the memory. Each memory block's memory information stores a first marker or a second marker. The first marker indicates that the memory block is occupied, and the second marker indicates that the memory block is not occupied. Then, based on the memory segment indication information, the electronic device determines the memory segment to be moved out and the memory segment to be moved in. In the memory segment to be moved out, the memory block corresponding to the memory information storing the first marker is identified as the memory block to be moved out; in the memory segment to be moved in, the memory block corresponding to the memory information storing the second marker is identified as the memory block to be moved in.
[0048] In some embodiments, the memory segment indication information includes a first identifier group and a second identifier group. The first identifier group includes identifiers corresponding to the memory segment to be moved out, and the second identifier group includes identifiers corresponding to the memory segment to be moved in. The electronic device determines the memory segment to be moved out corresponding to the identifiers in the first identifier group, determines the memory segment to be moved in corresponding to the identifiers in the second identifier group, and then, based on memory block occupancy information, determines the occupied memory blocks in the memory segment to be moved out as the memory blocks to be moved out, and determines the unoccupied memory blocks in the memory segment to be moved in as the memory blocks to be moved in.
[0049] In some embodiments, memory block occupancy information represents the address of each occupied memory block and the address of each unoccupied memory block in the memory. Based on the memory block occupancy information and memory segment indication information, the electronic device determines the address of the occupied memory block in the memory segment to be moved out as the source address, the address of the unoccupied memory block in the memory segment to be moved in as the destination address, the memory block indicated by the source address as the memory block to be moved out, and the memory block indicated by the destination address as the memory block to be moved in. Therefore, after determining the source and destination addresses, the electronic device transfers the memory data stored in the memory block to be moved out indicated by the source address to the memory block to be moved in indicated by the destination address, thereby completing the transfer of memory data based on the source and destination addresses.
[0050] In this process, the electronic device can determine the memory segment to be moved out and the memory segment to be moved in based on the memory segment indication information. Then, it needs to determine the memory block to be moved out in the memory segment to be moved out, and the memory block to be moved in in the memory segment to be moved in. The memory block to be moved out is the occupied memory block, and the memory block to be moved in is the unoccupied memory block. Based on the memory block occupancy information, the addresses of the occupied memory blocks in the memory segment to be moved out and the addresses of the unoccupied memory blocks in the memory segment to be moved in can be determined. Therefore, the address of the occupied memory block in the memory segment to be moved out is determined as the source address, and the memory block indicated by the source address is the memory block to be moved out. The address of the unoccupied memory block in the memory segment to be moved in is determined as the destination address, and the memory block indicated by the destination address is the memory block to be moved in.
[0051] In some embodiments, the memory block occupancy information includes memory information corresponding to each memory block in the memory. Each memory block's corresponding memory information stores a first marker or a second marker. The first marker indicates that the memory block is occupied, and the second marker indicates that the memory block is not occupied. The multiple memory information sets in the memory block occupancy information are divided into multiple memory information sets, and the multiple memory blocks in the memory are divided into multiple memory segments. Each memory information set corresponds one-to-one with a memory segment. The memory segment indication information includes a first identifier group and a second identifier group. The first identifier group includes the identifier corresponding to the memory segment to be moved out, and the second identifier group includes the identifier corresponding to the memory segment to be moved in. Furthermore, the identifier corresponding to the memory segment is the identifier of the memory information set corresponding to the memory segment. Therefore, the corresponding memory information set can be determined based on the identifier in the first identifier group or the second identifier group. The process of determining the source address includes: determining the memory information storing the first marker from the memory information set corresponding to the identifier in the first identifier group, and determining the address of the memory block corresponding to that memory information as the source address. The process of determining the destination address includes: determining the memory information storing the second marker from the memory information set corresponding to the identifier in the second identifier group, and determining the address of the memory block corresponding to that memory information as the destination address.
[0052] In this system, the identifiers in the first identifier group correspond to the memory segment to be moved out. Since the first marker indicates that the memory block corresponding to the memory information is occupied, to find the occupied memory block in the memory segment to be moved out, it is only necessary to search for the memory information in the memory information set that stores the first marker. The address of the memory block corresponding to this memory information is the source address, and the memory block indicated by the source address is the memory block to be moved out. For example, the electronic device obtains the unit length of the memory block and the starting address of the memory block corresponding to the memory information, and determines the starting address and unit length as the source address. The region of unit length starting from the starting position indicated by the starting address is the memory block to be moved out indicated by the source address.
[0053] In this system, the identifiers in the second identifier group correspond to the memory segment to be moved in. Since the second marker indicates that the memory block corresponding to the memory information is not occupied, to find the unoccupied memory block in the memory segment to be moved in, it is only necessary to search for the memory information that stores the second marker in the memory information set. The address of the memory block corresponding to this memory information is the destination address, and the memory block indicated by the destination address is the memory block to be moved in. For example, the electronic device obtains the unit length of the memory block and the starting address of the memory block corresponding to the memory information, and determines the starting address and unit length as the destination address. The region of unit length starting from the starting position indicated by the starting address is the memory block to be moved in indicated by the destination address.
[0054] In some embodiments, the process of an electronic device determining the starting address of a memory block includes: the electronic device obtaining the starting address of the memory, determining the interval length by multiplying the unit length and the sequence number of the memory information, where the sequence number indicates the order of the memory information among multiple memory information, and then determining the address obtained by passing the starting address of the memory through the interval length as the starting address of the memory block.
[0055] Since memory blocks in the memory are all of unit length, the starting address of the memory is also the starting address of multiple memory blocks. Therefore, the starting address of a memory block can be determined based on its order within the multiple memory blocks and the starting addresses of those multiple memory blocks. There is a one-to-one correspondence between memory blocks and memory information; the sequence number of any memory block within the multiple memory blocks is equal to the sequence number of the corresponding memory information within the multiple memory information. Therefore, the product of the unit length and the sequence number of the memory information is the interval length between the starting position of the memory block corresponding to that memory information and the starting positions of the multiple memory blocks. The address obtained after passing through this interval length from the starting address is the starting address of that memory block.
[0056] In some embodiments, the electronic device determines the address of the kth occupied memory block in the memory segment to be moved out as the kth source address and the address of the kth unoccupied memory block in the memory segment to be moved in as the kth destination address, based on memory block occupancy information and memory segment indication information, thus obtaining the kth set of address information, until n sets of address information are obtained, where n is the number of occupied memory blocks in the memory segment to be moved out, and k is a positive integer not greater than n. Therefore, after determining n sets of address information, for each set of address information, the electronic device transfers the memory data stored in the memory block to be moved out indicated by the source address in that set of address information to the memory block to be moved in indicated by the destination address in that set of address information, thereby completing n memory data transfers sequentially according to the n sets of address information.
[0057] The memory segment to be moved out includes multiple memory blocks, and the memory segment to be moved in includes multiple memory blocks. The electronic device first determines the address of the first occupied memory block in the memory segment to be moved out as the first source address, and then determines the address of the first unoccupied memory block in the memory segment to be moved in as the first destination address. The first source address and the first destination address form the first set of address information. Then, the address of the second occupied memory block in the memory segment to be moved out is determined as the second source address, and the address of the second unoccupied memory block in the memory segment to be moved in is determined as the second destination address. The second source address and the second destination address form the second set of address information, and so on, until n sets of address information are obtained. Each set of address information includes a pair of source address and destination address.
[0058] It should be noted that the memory segment to be moved out in this embodiment can be one or more memory segments to be moved out, and the memory segment to be moved in can also be one or more memory segments to be moved in. This embodiment does not limit the number of memory segments to be moved out and to be moved in. Specifically, the memory segment to be moved out in this embodiment can include one or more memory blocks to be moved out, and the memory segment to be moved in can include one or more memory blocks to be moved in. This embodiment does not limit the number of memory blocks to be moved out and to be moved in, but the memory blocks to be moved out and to be moved in are in one-to-one correspondence; that is, the total number of memory blocks to be moved out is the same as the total number of memory blocks to be moved in.
[0059] Figure 3 The diagram illustrates a memory data transfer process provided in an exemplary embodiment of this application, as shown below. Figure 3 As shown, memory information corresponds one-to-one with memory blocks in the order they are arranged. Each memory information entry stores either 0 or 1; 0 indicates that the corresponding memory block is unused, while 1 indicates that the corresponding memory block is occupied. Figure 3Memory blocks including shaded areas are occupied memory blocks, while those not including shaded areas are unoccupied memory blocks. The memory information is divided into memory information sets [0, 7], [8, 15], and [16, 23]. Memory information set [0, 7] corresponds to the memory segment to be moved in, while memory information sets [8, 15] and [16, 23] correspond to the memory segments to be moved out.
[0060] The electronic device identifies the memory block corresponding to the memory information storing 1 from memory information sets [8, 15] and [16, 23] as the memory block to be moved out, and identifies the memory block corresponding to the memory information storing 0 from memory information set [0, 7] as the memory block to be moved in, and transfers the memory data stored in the memory block to be moved out to the memory block to be moved in. For example... Figure 3 As shown, the first, second, third, and fourth memory blocks to be moved out can be determined sequentially according to the order of memory information in memory information sets [8,15] and [16,23]. Similarly, the first, second, third, and fourth memory blocks to be moved in can be determined sequentially according to the order of memory information in memory information set [0,7]. Then, the memory data stored in the memory blocks to be moved out can be transferred to the corresponding memory blocks to be moved in.
[0061] Figure 4 The diagram illustrates a memory segment according to an exemplary embodiment of this application. The memory includes multiple memory blocks. Figure 4 The left side shows the memory block usage in the storage before the memory data was transferred. Figure 4 The right side shows the memory block usage in the storage after the data was transferred. Figure 4 The shaded memory blocks contain memory data, while the unshaded memory blocks do not. It can be seen that before the memory data is transferred, each memory segment in the memory contains memory blocks that store memory data; therefore, these memory segments are all occupied memory segments. After the memory data is transferred, the memory data is concentrated in some memory segments. Since memory segments that do not store memory data can be powered off, and since there are both occupied and unoccupied memory segments in the memory, powering off the unoccupied memory segments can save some power.
[0062] Step 203: Power off the memory segment to be moved out.
[0063] After the memory data to be moved out of the memory segment is transferred to the memory segment to be moved in, since the memory data is now stored in the memory segment to be moved in and no memory data is stored in the memory segment to be moved out, turning off the power to the memory segment to be moved out will not affect the memory data. The memory can still complete the storage of memory data, thereby saving some of the power consumed by the memory segment while ensuring the normal operation of the memory.
[0064] Step 204: In response to the memory suspension termination instruction, power on the memory segment to be moved out, and restore the memory data transferred to the memory segment to be moved in to the memory segment to be moved out.
[0065] When the memory segment to be moved out is powered off, if a memory suspend end command is detected, the memory segment to be moved out is powered back on, and the memory data previously transferred to the memory segment to be moved in is restored to the memory segment to be moved out. The triggering methods for this memory suspend end command can be varied. For example, the electronic device may generate a memory suspend command in response to a screen lock operation, and then transfer the memory data accordingly. If the user subsequently wants to continue using the electronic device, an unlock operation is performed, and the electronic device generates a memory suspend end command in response to this unlock operation.
[0066] In some embodiments, in step 201 above, in response to a memory suspend instruction, the electronic device also powers off other devices besides the memory, at which point the electronic device enters a Suspend state. When the electronic device detects any instruction in the Suspend state, it determines the type of the instruction. If the instruction is a memory suspend end instruction, it powers on the memory segment to be moved out, restores the memory data transferred to the memory segment to be moved in to the memory segment to be moved out, and then powers on all other devices except the memory again, allowing the electronic device to resume normal operation.
[0067] In some embodiments, the electronic device restores the memory data transferred to the memory block to be moved into the memory segment to be moved into the memory block to be moved out, which corresponds to the memory block to be moved into.
[0068] In steps 201-202 above, the electronic device transfers the memory data stored in the memory block to be moved out to the memory block to be moved in. During the process of restoring the memory data, the electronic device needs to restore the memory data transferred to the memory block to be moved in to the memory segment to the memory block to be moved out corresponding to the memory block to be moved in.
[0069] In some embodiments, the electronic device acquires n sets of address information, each set including a source address and a destination address. The source address in the k-th set of address information is the address of the k-th occupied memory block in the memory segment to be moved out, and the destination address in the k-th set of address information is the address of the k-th unoccupied memory block in the memory segment to be moved in. n is the number of occupied memory blocks in the memory segment to be moved out, and k is a positive integer not greater than n. For each set of address information, the memory block to be moved in indicated by the destination address and the memory block to be moved out indicated by the source address are determined, and the memory data in the memory block to be moved in is transferred to the memory block to be moved out. These n sets of address information are the same as the n sets of address information in step 202 above.
[0070] This application provides a memory suspending method. In response to a memory suspending command, memory data stored in the memory segment to be moved out is transferred to the memory segment to be moved in. Since the memory data is stored in the memory segment to be moved in at this time, and no memory data is stored in the memory segment to be moved out, powering off the memory segment to be moved out will not affect the memory data. The memory can still complete the storage of memory data, thereby saving some of the power consumed by the memory segment while ensuring the normal operation of the memory.
[0071] Furthermore, in scenarios where electronic devices enter the Suspend state, the method provided in this application embodiment can reduce the standby power of electronic devices and extend the standby time of electronic devices. For electronic devices that require high performance and long battery life, the power saving effect is even more significant.
[0072] In some embodiments, such as Figure 5 As shown, the electronic device includes a memory 501, a controller 502, and a processor 503, with the processor 503 running a state management system 513.
[0073] The memory 501 stores memory data and includes multiple memory segments, each containing multiple contiguous memory blocks. These memory segments include segments to be moved out and segments to be moved in. The controller 502 is a hardware circuit in the electronic device and can directly access the memory 501. The state management system 503 is software running on the processor 503. The memory 501 stores instructions corresponding to the state management system, and the processor 503 executes these instructions to run the state management system 503. The state management system 503 manages the states of the devices in the electronic device.
[0074] In this embodiment, the state management system 513 generates memory block occupancy information and memory segment indication information based on the memory block occupancy status in the memory 501, and notifies the controller 502 of the memory block occupancy information and memory segment indication information. Then, based on the memory block occupancy information and memory segment indication information, the controller 502 transfers the memory data stored in the memory segment to be moved out of the memory 501 to the memory segment to be moved in. After the memory data transfer is completed, the state management system 513 de-energizes the memory segment to be moved out.
[0075] The memory suspending method provided in this application embodiment is applied to, for example, Figure 5 In the electronic devices shown, see [reference needed]. Figure 6 , Figure 6 The flowchart of a memory suspending method provided in an exemplary embodiment of this application is shown. The method includes: Step 601: In response to the memory suspend instruction, obtain memory block occupancy information and memory segment indication information through the status management system.
[0076] This state management system is used to manage the state of electronic devices and the memory data in the memory. It can determine the memory usage in the memory and, based on this, generate memory block usage information and memory segment indication information. For example, this state management system can be a subsystem of the operating system in an electronic device, running on the processor within the device.
[0077] The process of step 601 is the same as that of step 201, and will not be described in detail here. The difference is that, in this embodiment, the steps of obtaining memory block occupancy information and memory segment indication information are performed by the state management system in the electronic device.
[0078] Step 602: Through the status management system, notify the controller of memory block occupancy information and memory segment indication information.
[0079] In this embodiment, the state management system and the controller can transmit data. The memory block occupancy information and memory segment indication information obtained by the state management system are used to guide the transfer of memory data. In this embodiment, the controller performs the transfer of memory data in the memory. Therefore, the state management system notifies the controller of the memory block occupancy information and memory segment indication information.
[0080] In some embodiments, the state management system stores the generated memory block occupancy information and memory segment indication information in the memory segment of the memory, then obtains the first address information of the memory block occupancy information and the second address information of the memory segment indication information, and sends the first address information and the second address information to the controller so that the controller can query the memory block occupancy information according to the first address information and query the memory segment indication information according to the second address information.
[0081] Step 603: Using the controller, based on memory block occupancy information and memory segment indication information, generate source address and destination address, and transfer the memory data stored in the memory block to be moved out indicated by the source address to the memory block to be moved in indicated by the destination address.
[0082] This controller can directly access the memory in the electronic device. Therefore, it acquires memory block occupancy information and memory segment indication information, and determines the source and destination addresses based on these information. The source address indicates the memory block to be removed, and the destination address indicates the memory segment to be removed from the memory block to be moved into. Thus, the controller can transfer memory data stored in the memory block to be removed (indicated by the source address) to the memory block to be moved into (indicated by the destination address). For example, this controller is a DMA (Direct Memory Access) controller.
[0083] In some embodiments, the memory segment storing memory block occupancy information and memory segment indication information is a non-power-off memory segment. In this case, the controller uses a hardware compression algorithm to compress the memory block occupancy information and memory segment indication information to reduce the memory segment occupied by the memory block occupancy information and memory segment indication information, thereby reducing the non-power-off memory segment, which is equivalent to increasing the power-off memory segment. Subsequently, the power-off memory segment can be powered off to further achieve the purpose of saving power.
[0084] In addition to the above explanation, the process of transferring memory data in step 603 is the same as the process of transferring memory data in step 202. The difference is that, in this embodiment, the step of transferring memory data is performed by the controller in the electronic device.
[0085] Step 604: Send a notification message to the status management system via the controller.
[0086] After transferring the memory data stored in the memory segment to be moved out to the memory segment to be moved in, the controller sends a notification message to the state management system, indicating that the transfer of memory data has been completed.
[0087] Step 605: In response to the notification message received by the state management system, power off the memory segment to be removed.
[0088] The state management system receives a notification message indicating that the memory data stored in the memory segment to be moved out has been transferred to the memory segment to be moved in. Since all memory data is currently stored in the memory segment to be moved in, and the memory segment to be moved out does not store any memory data, switching the memory segment to be moved out to a power-off state will not affect the memory data; the memory can still complete the storage of memory data. Therefore, by powering off the memory segment to be moved out through the state management system, the normal operation of the memory is ensured while saving the power consumed by the memory segment to be moved out.
[0089] It should be noted that after powering off the memory segment to be moved out, it is possible to power it back on and restore the memory data to the memory segment to be moved out. For example, in response to a memory suspend end command, the electronic device powers on the memory segment to be moved out through the state management system and notifies the controller that the memory segment to be moved out has been powered on. Then, the controller restores the memory data transferred to the memory segment to be moved in back to the memory segment to be moved out.
[0090] Figure 7 The diagram illustrates a system architecture diagram of a memory suspending method provided in an exemplary embodiment of this application. During the process of switching an electronic device to a suspend state, memory data transfer and power-off of the memory segment to be moved out are required. Figure 7 As shown, the electronic device includes a software component and a hardware circuit component. The software component is the operating system, which includes a state management system. The hardware circuit component includes a DMA controller. This solution allows configuration of non-power-disconnectable memory segments within the storage device to ensure that power is not interrupted. For example, this non-power-disconnectable memory segment is used to maintain the operation of the software component and to store the memory block-occupied Bitmap.
[0091] Among them, such as Figure 7 As shown, when an electronic device detects a memory suspend instruction, it stores the currently running data of the electronic device in memory. The state management system hooks (a type of data tracking) and monitors the operating system's memory management system to determine the memory usage in memory and generates memory block usage information, known as a memory block usage Bitmap. A memory block usage Bitmap contains N bits, each bit representing the usage status of a memory block, i.e., whether it is occupied or not. The state management system determines memory segment indication information based on the memory block usage Bitmap.
[0092] like Figure 7As shown, the state management system sends the starting address and length of the memory block occupancy bitmap, the starting address and length of the memory segment indication information, the starting address of the memory, and the unit length of the memory block to the DMA controller. The DMA controller uses this information to obtain the memory block occupancy bitmap and memory segment indication information, and generates multiple sets of address information required for transferring memory data. Based on these multiple sets of address information, it uses DMA to transfer the memory data. Furthermore, during or after the transfer, the controller can also respond to a memory suspension termination command to restore the memory data transferred to the memory block to be moved into to the memory block to be moved out.
[0093] This application provides a memory suspending method. In response to a memory suspending command, memory data stored in the memory segment to be moved out is transferred to the memory segment to be moved in. Since the memory data is stored in the memory segment to be moved in at this time, and no memory data is stored in the memory segment to be moved out, powering off the memory segment to be moved out will not affect the memory data. The memory can still complete the storage of memory data, thereby saving some of the power consumed by the memory segment while ensuring the normal operation of the memory.
[0094] Furthermore, the state management system is software running in the electronic device, while the controller is hardware circuitry within the device. Through the collaborative operation of the software and hardware circuitry, the power consumption of a portion of the memory segment is reduced. Since this solution does not involve modifications to the software's business logic, the transfer of memory data can be accomplished with minimal overhead by adding hardware circuitry, making the solution easy to implement.
[0095] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0096] Please refer to Figure 8 This illustration shows a structural block diagram of a memory suspending device provided in an exemplary embodiment of this application. The memory suspending device is applied to an electronic device and includes: The data transfer module 801 is used to transfer memory data stored in the memory segment to be moved out to the memory segment to be moved in in response to a memory suspend command. The memory segment to be moved out and the memory segment to be moved in are different memory segments in the memory. The memory data includes the data that the electronic device is running when the memory suspend command is received. The power-off module 802 is used to power off the memory segment to be moved out.
[0097] The apparatus provided in this application embodiment, in response to a memory suspend instruction, transfers the memory data stored in the memory segment to be moved out to the memory segment to be moved in. Since the memory data is stored in the memory segment to be moved in at this time, and no memory data is stored in the memory segment to be moved out, powering off the memory segment to be moved out will not affect the memory data. The memory can still complete the storage of memory data, thereby saving some of the power consumed by the memory segment while ensuring the normal operation of the memory.
[0098] In some embodiments, see Figure 9 The data transfer module 801 includes: The information acquisition unit 811 is used to acquire memory block occupancy information and memory segment indication information. The memory block occupancy information is information indicating the occupancy status of memory blocks, and the memory segment indication information is information indicating memory segments to be moved out and memory segments to be moved in. The memory block determination unit 821 is used to determine the occupied memory blocks in the memory segment to be moved out as memory blocks to be moved out, and the unoccupied memory blocks in the memory segment to be moved in as memory blocks to be moved in, based on memory block occupancy information and memory segment indication information. The data transfer unit 831 is used to transfer memory data stored in the memory block to be moved out to the memory block to be moved in.
[0099] In some embodiments, the memory block occupancy information includes memory information corresponding to each memory block in the memory. The memory information corresponding to each memory block stores a first tag or a second tag. The first tag indicates that the memory block is occupied, and the second tag indicates that the memory block is not occupied.
[0100] In some embodiments, see Figure 9 Information acquisition unit 811, used for: Determine the memory segment to be moved out and the memory segment to be moved into in the memory; Add the identifier corresponding to the memory segment to be moved out to the first identifier group; Add the identifier corresponding to the memory segment to be moved into the second identifier group; The first identifier group and the second identifier group constitute the memory segment indication information.
[0101] In some embodiments, see Figure 9 Information acquisition unit 811, used for: Identify power-off memory segments within the memory; Within a power-off memory segment, identify the memory segment to be moved out and the memory segment to be moved in.
[0102] In some embodiments, see Figure 9 Information acquisition unit 811, used for: For any power-off memory segment, determine a first quantity and a second quantity, where the first quantity is the number of memory blocks occupied in the memory segment and the second quantity is the number of memory blocks not occupied in the memory segment. In response to the first quantity being less than the second quantity, the memory segment is determined to be the memory segment to be moved out. In response to the first quantity being no less than the second quantity, the memory segment is determined as the memory segment to be moved into.
[0103] In some embodiments, see Figure 9 Information acquisition unit 811, used for: Within a power-off memory segment, determine the initial memory segment to be moved out and the initial memory segment to be moved in; Determine the third and fourth quantities. The third quantity is the total number of occupied memory blocks in the initial memory segment to be moved out, and the fourth quantity is the total number of unoccupied memory blocks in the initial memory segment to be moved in. In response to the third quantity being greater than the fourth quantity, at least one memory segment to be moved out is changed to a memory segment to be moved in, such that the changed third quantity is not greater than the changed fourth quantity.
[0104] In some embodiments, see Figure 9 The electronic device is equipped with a state management system and includes a controller. The information acquisition unit 811 is used to acquire memory block occupancy information and memory segment indication information through the state management system. The device also includes: The information sending module 803 is used to notify the controller of memory block occupancy information and memory segment indication information through the status management system; The memory block determination unit 821 is used to generate a source address and a destination address based on memory block occupancy information and memory segment indication information through the controller. The source address indicates the memory block to be moved out, and the destination address indicates the memory block to be moved in. The data transfer unit 831 is used to transfer memory data stored in the memory block to be moved out, indicated by the source address, to the memory block to be moved in, indicated by the destination address, through the controller.
[0105] In some embodiments, see Figure 9 The device also includes: The message sending module 804 is used to send a notification message to the state management system through the controller. The notification message indicates that the transfer of memory data has been completed. The power-off module 802 is used to power off the memory segment to be moved out in response to a notification message received by the state management system.
[0106] In some embodiments, see Figure 9 The device also includes: The power-on module 805 is also used to power on the memory segment to be moved out in response to a memory suspension termination command; The data transfer module 801 is also used to restore the memory data transferred to the memory segment to be moved into to the memory segment to be moved out.
[0107] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the electronic device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0108] This application provides an electronic device including a processor, a controller, and a memory; the memory stores at least one instruction, which is executed by the processor and the controller to implement the memory suspension method provided in the above-described method embodiments.
[0109] In some embodiments, the electronic device is a terminal; please refer to [reference needed]. Figure 10 This diagram illustrates a structural block diagram of a terminal provided in an exemplary embodiment of this application. In some embodiments, the terminal 1000 is a smartphone, tablet, wearable device, or other terminal capable of accessing a wireless local area network as a wireless station. The terminal 1000 in this application includes at least one or more of the following components: a processor 1010, a controller 1020, a memory 1030, and at least two wireless links 1040.
[0110] In some embodiments, the processor 1010 includes one or more processing cores. The processor 1010 connects to various parts within the terminal 1000 using various interfaces and lines, and performs various functions and processes data of the terminal 1000 by running or executing program code stored in the memory 1020 and calling data stored in the memory 1020. In some embodiments, the processor 1010 is implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 1010 can integrate one or more of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Neural-network Processing Unit (NPU), and modem. Specifically, the CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; the NPU is used to implement Artificial Intelligence (AI) functions; and the modem is used to handle wireless communication. It is understandable that the aforementioned modem could also be implemented as a separate chip without being integrated into the processor 1010.
[0111] In some embodiments, the processor 1010 is used to control the operating status of at least two wireless links 1030. Accordingly, the processor 1010 is a processor integrating a Wireless Fidelity (Wi-Fi) chip. This Wi-Fi chip is a chip with dual Wi-Fi processing capabilities. For example, the Wi-Fi chip is a dual-band dual-concurrent (DBDC) chip, or a dual-band simultaneous (DBS) chip, etc.
[0112] In some embodiments, controller 1020 is a DMA (Direct Memory Access) controller, which is capable of directly accessing memory 1030.
[0113] In some embodiments, the memory 1030 includes random access memory (RAM), and in some embodiments, the memory 1030 includes read-only memory (ROM). In some embodiments, the memory 1030 includes non-transitory computer-readable storage medium. The memory 1030 can be used to store program code. The memory 1030 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described below, etc.; the data storage area may store data (such as audio data, phonebook, etc.) created according to the use of the terminal 1000.
[0114] In some embodiments, the memory 1030 stores reception schemes for different wireless links 1040 receiving beacon frames, as well as identifiers of access nodes connected to different wireless links 1040, identifiers of wireless links 1040, etc.
[0115] The at least two wireless links 1040 are used to connect different access points (APs) and receive downlink data from the APs. These different access points can be access points within the same router or access points within different routers.
[0116] In some embodiments, the terminal 1000 further includes a display screen. The display screen is a display component used to display a user interface. In some embodiments, the display screen is a touch-enabled display screen, allowing users to perform touch operations on the display screen using fingers, styluses, or any suitable object. In some embodiments, the display screen is typically located on the front panel of the terminal 1000. In some embodiments, the display screen is designed as a full-screen, curved screen, irregularly shaped screen, dual-sided screen, or foldable screen. In some embodiments, the display screen is also designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen, etc., which are not limited in this embodiment.
[0117] In addition, those skilled in the art will understand that the structure of the terminal 1000 shown in the above figures does not constitute a limitation on the terminal 1000. The terminal 1000 may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the terminal 1000 may also include components such as a microphone, speaker, input unit, sensor, audio circuit, module, power supply, and Bluetooth module, which will not be described in detail here.
[0118] This application also provides a computer-readable medium storing at least one instruction that is loaded and executed by a processor and controller in an electronic device to implement the memory suspension method shown in the above embodiments.
[0119] This application also provides a computer program product that stores at least one instruction, which is loaded and executed by a processor and controller in an electronic device to implement the memory suspension method shown in the above embodiments.
[0120] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0121] Those skilled in the art will understand that all or part of the steps in the memory suspending method of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. The above descriptions are merely preferred embodiments of this application and are not intended to limit the application. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A memory suspending method, characterized in that, Applied to electronic devices, the method includes: In response to a memory suspend instruction, memory data stored in a memory segment to be moved out is transferred to a memory segment to be moved in, wherein the memory segment to be moved out and the memory segment to be moved in are different memory segments in a memory, the memory includes a plurality of consecutive memory blocks, the memory segment is obtained by segmenting the plurality of consecutive memory blocks, and the memory segment includes at least one of the memory blocks, and the memory data includes the data being run by the electronic device when the memory suspend instruction is received; Power off the memory segment to be moved out.
2. The method according to claim 1, characterized in that, The step of transferring memory data stored in the memory segment to be moved out to the memory segment to be moved in includes: Obtain memory block occupancy information and memory segment indication information. The memory block occupancy information indicates the occupancy status of memory blocks, and the memory segment indication information indicates the memory segment to be moved out and the memory segment to be moved in. Based on the memory block occupancy information and the memory segment indication information, the memory blocks occupied in the memory segment to be moved out are determined as memory blocks to be moved out, and the memory blocks not occupied in the memory segment to be moved in are determined as memory blocks to be moved in. The memory data stored in the memory block to be moved out is transferred to the memory block to be moved in.
3. The method according to claim 2, characterized in that, The memory block occupancy information includes memory information corresponding to each memory block in the memory. The memory information corresponding to each memory block stores a first mark or a second mark. The first mark indicates that the memory block is occupied, and the second mark indicates that the memory block is not occupied.
4. The method according to claim 2, characterized in that, The acquisition of memory block occupancy information and memory segment indication information includes: Determine the memory segment to be moved out and the memory segment to be moved in in the memory; Add the identifier corresponding to the memory segment to be removed to the first identifier group; Add the identifier corresponding to the memory segment to be moved into the second identifier group; The first identifier group and the second identifier group constitute the memory segment indication information.
5. The method according to claim 4, characterized in that, Determining the memory segment to be moved out and the memory segment to be moved into in the memory includes: Identify a power-off memory segment within the memory; Within the power-off memory segment, the memory segment to be moved out and the memory segment to be moved in are determined.
6. The method according to claim 5, characterized in that, The step of determining the memory segment to be moved out and the memory segment to be moved in within the power-off memory segment includes: For any of the power-off memory segments, a first quantity and a second quantity are determined, where the first quantity is the number of memory blocks occupied in the memory segment and the second quantity is the number of memory blocks not occupied in the memory segment. In response to the first quantity being less than the second quantity, the memory segment is determined to be the memory segment to be moved out; In response to the first quantity being not less than the second quantity, the memory segment is determined to be the memory segment to be moved in.
7. The method according to claim 5, characterized in that, The step of determining the memory segment to be moved out and the memory segment to be moved in within the power-off memory segment includes: Within the power-off memory segment, the initial memory segment to be moved out and the initial memory segment to be moved in are determined; A third quantity and a fourth quantity are determined, wherein the third quantity is the total number of occupied memory blocks in the initial memory segment to be moved out, and the fourth quantity is the total number of unoccupied memory blocks in the initial memory segment to be moved in; In response to the third quantity being greater than the fourth quantity, at least one of the memory segments to be moved out is changed to the memory segment to be moved in, such that the changed third quantity is not greater than the changed fourth quantity.
8. The method according to claim 2, characterized in that, The electronic device runs a state management system, and the electronic device includes a controller. The acquisition of memory block occupancy information and memory segment indication information includes: The memory block occupancy information and the memory segment indication information are obtained through the status management system. The method further includes: The state management system notifies the controller of the memory block occupancy information and the memory segment indication information. The step of determining the occupied memory blocks in the memory segment to be moved out as memory blocks to be moved out, and the unoccupied memory blocks in the memory segment to be moved in as memory blocks to be moved in, based on the memory block occupancy information and the memory segment indication information, includes: The controller generates a source address and a destination address based on the memory block occupancy information and the memory segment indication information. The source address indicates the memory block to be moved out, and the destination address indicates the memory block to be moved in. The step of transferring the memory data stored in the memory block to be moved out to the memory block to be moved in includes: The controller transfers the memory data stored in the memory block to be moved out, as indicated by the source address, to the memory block to be moved in, as indicated by the destination address.
9. The method according to claim 8, characterized in that, After transferring the memory data stored in the memory block to be moved out indicated by the source address to the memory block to be moved in indicated by the destination address via the controller, the method further includes: The controller sends a notification message to the state management system, the notification message indicating that the transfer of the memory data has been completed. Switching the memory segment to be moved out to a power-off state includes: In response to the state management system receiving the notification message, the memory segment to be moved out is switched to the power-off state.
10. The method according to any one of claims 1-9, characterized in that, After switching the memory segment to be moved out to a power-off state, the method further includes: In response to a memory suspension termination command, power is applied to the memory segment to be removed; The memory data transferred to the memory segment to be moved in is restored to the memory segment to be moved out.
11. A memory suspending device, characterized in that, Applied to electronic devices, the device includes: A data transfer module is used to transfer memory data stored in a memory segment to be moved out to a memory segment to be moved in in response to a memory suspend instruction. The memory segment to be moved out and the memory segment to be moved in are different memory segments in a memory. The memory includes a plurality of consecutive memory blocks. The memory segment is obtained by segmenting the plurality of consecutive memory blocks. The memory segment includes at least one of the memory blocks. The memory data includes the data that the electronic device was running when the memory suspend instruction was received. The power-off module is used to power off the memory segment to be moved out.
12. An electronic device, characterized in that, The electronic device includes a processor, a controller, and a memory; the memory stores at least one instruction, which is executed by the processor and the controller to implement the memory suspend method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction, which is executed by a processor and controller in an electronic device to implement the memory suspension method as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Reducing power consumption of volatile memory via use of non-volatile memory
CN104885034A
Data storage method and storage equipment
CN105205015A
Electricity saving control method and device of server, and energy-saving control device of electronic equipment
CN105549723A