A method for managing memory and an electronic device

By using multiple inactive linked lists and active linked lists in the operating system to manage physical pages and setting different scanning cycles according to the access frequency, the problem of frequent access pages being unnecessary recycled is solved, and the read and write performance and memory cache hit rate of the operating system are improved.

CN114730288BActive Publication Date: 2025-07-04HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202080079353.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-11-15
Filing Date
2020-11-02
Publication Date
2025-07-04
Estimated Expiration
2040-11-02

AI Technical Summary

Technical Problem

In the prior art, the operating system fails to effectively consider the frequent access of the physical page when recycling physical pages, resulting in the frequently accessed shared pages being unnecessarily recycled, affecting the read and write performance of the operating system.

Method used

The physical page is managed by a combination of multiple inactive linked lists and active linked lists. According to the number and access frequency of the page being mapped by the application process, different scanning cycles and recycling inspection cycles are set to reduce the recycling inspection of frequently accessed pages and extend their survival time.

Benefits of technology

Improves the operating system memory cache hit rate, reduces unnecessary recycling checks, and improves the operating system's read and write performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114730288B_ABST
    Figure CN114730288B_ABST
Patent Text Reader

Abstract

A method for managing memory and an electronic device, relating to the technical field of electronic devices, which is beneficial to avoiding multiple unnecessary reclaim checks on frequently accessed physical pages, accelerating the reclaim efficiency of physical pages by the operating system, and improving the performance of the operating system. The method specifically includes: the electronic device uses multiple inactive lists and one active list for each memory area to implement the function of reclaiming physical pages. Or, one inactive list and multiple active lists are used for each memory area to implement the function of reclaiming physical pages. Or, multiple inactive lists and multiple active lists are used for each memory area to implement the function of reclaiming physical pages.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims the priority of a Chinese patent application with the application number 201911118935.9 and the application title "A Memory Management Method and an Electronic Device", which was filed with the National Intellectual Property Administration on November 15, 2019. The entire content of the Chinese patent application is incorporated herein by reference. Technical Field

[0002] This application relates to the technical field of electronic devices, and in particular, to a memory management method and an electronic device. Background Art

[0003] Virtual memory is a technology for memory management in an electronic device operating system and is an abstraction of memory (also known as physical memory) provided by the operating system. The implementation of virtual memory is completed by the combination of operating system software and hardware. Virtual memory can be unrestricted by the size of memory and provides a larger private address space for application programs. That is to say, each application program process independently allocates its own virtual memory space. The operating system then allocates physical memory space (i.e., physical pages) for the virtual memory space of the application program, that is, maps the virtual memory space allocated to the application program process to physical pages.

[0004] When an application program reads and writes files, the operating system uses physical pages as caches for files stored in external memory to improve the read and write performance of the operating system. Since the physical pages of an electronic device are limited, when an application program process runs for a long time and does not actively release physical pages, or when a large number of application program processes apply for physical pages, the number of free physical pages will become fewer and fewer. Therefore, when the free physical pages cannot meet memory allocation or are below a certain threshold, the operating system will recycle the least recently used physical pages according to a certain algorithm (such as the least recently used (LRU) algorithm).

[0005] Taking Linux as an example, the operating system uses a pair of LRU lists to maintain the physical pages of memory. The LRU lists include an active list (active_list) and an inactive list (inactive_list). Frequently accessed active physical pages are placed in the active_list, and infrequently accessed physical pages are placed in the inactive_list. When the operating system reclaims physical pages, it starts scanning from the tail of the inactive_list and checks whether each physical page has been recently used. If it has been used, the physical page is placed at the head of the active_list. If it has not been used, the physical page is reclaimed. That is to say, when a physical page moves from the head of the active_list to the tail of the inactive_list and has not been accessed all the time, it will be reclaimed by the operating system.

[0006] It can be noted that in the existing physical page reclaiming method, only whether the physical page has been recently used is considered, but the actual number of times the physical page has been used is not considered, which will affect the read and write performance of the operating system. For example: some shared physical pages will actually be frequently accessed by multiple application processes, but the access period of the shared physical pages may be longer than the time duration for the shared physical pages to move from the head of the active_list to the tail of the inactive_list. In this case, when the operating system reclaims physical pages, the shared physical pages will still be reclaimed. And when the application process accesses the shared physical pages again, the operating system will reallocate physical pages. It can be seen that for these shared physical pages, the operating system will keep reclaiming and reallocating repeatedly, seriously affecting the read and write performance of the operating system. Summary of the Invention

[0007] A memory management method and an electronic device provided by this application are beneficial to avoiding multiple unnecessary reclaim checks on frequently accessed physical pages, accelerating the reclaim efficiency of the operating system for physical pages, and improving the performance of the operating system.

[0008] To achieve the above object, the embodiments of this application provide the following technical solutions:

[0009] First aspect: A memory management method is provided, which is applied to an electronic device. The memory of the electronic device includes one or more memory regions, and each of the one or more memory regions corresponds to n inactive lists and m active lists, where n is an integer greater than 1, and m is an integer greater than or equal to 1. The method includes: The electronic device places the allocated inactive physical pages in the corresponding inactive list among the n inactive lists according to the number of times the inactive physical pages are mapped by application processes; during the process of the electronic device reclaiming physical pages of the memory, the electronic device scans each of the n inactive lists and performs a reclaim check on the physical pages in each scanned inactive list; among them, the greater the number of times the physical pages in the inactive list are mapped by application processes, the longer the scanning period corresponding to the inactive list; if it is detected that the physical pages in the n inactive lists have not been accessed in the most recent preset time period, the electronic device reclaims the physical pages; if it is detected that the physical pages in the n inactive lists have been accessed in the most recent preset time period, the electronic device moves the physical pages to the m active lists.

[0010] Exemplarily, the electronic device can place different inactive_lists according to the value of the mapcount of the physical page. Among them, the mapcount of the physical page is used to represent the number of times the physical page is mapped by application processes, that is, how many application process page tables (page table entries, PTEs) the physical page is mapped to, that is, how many application processes share it. We can consider that when a physical page is shared by more application processes, the probability that the physical page is frequently accessed is higher.

[0011] In this way, on the one hand, reducing the reclaim check of frequently accessed physical pages reduces the probability that the physical page is reclaimed, extends the survival time of frequently accessed physical pages, and thus improves the memory cache hit rate of the operating system. On the other hand, using a larger period for the reclaim check of frequently accessed physical pages is conducive to detecting that the physical page has been accessed in the most recent first preset time period during the reclaim check, so as to move the physical page from the inactive_list to the active_list, which also extends the survival time of frequently accessed physical pages and improves the memory cache hit rate of the operating system.

[0012] In a possible implementation, the electronic device scans each of the n inactive linked lists, including: the electronic device sorts the n inactive linked lists according to the number of physical pages mapped by the application process; during the process of the electronic device reclaiming the physical pages of the memory, the electronic device performs P rounds of scans on the n inactive linked lists, where P is an integer greater than or equal to 2; during each round of scan in the P rounds of scans, the electronic device starts scanning from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different. Thus, a method for scanning each of the n inactive linked lists with different periods is provided.

[0013] In a possible implementation, during each round of scan in the P rounds of scans, the electronic device starts scanning from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different. Specifically, during each round of scan in the P rounds of scans, the electronic device starts scanning from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is increased by a preset number compared to the number of inactive linked lists scanned in the previous round.

[0014] In a possible implementation, the method further includes: when m = 1, during the process of the electronic device reclaiming the physical pages of the memory, the electronic device starts scanning from one side of the active linked list and performs a reclaim check on the scanned physical pages; if it is detected that the physical page in the active linked list has not been accessed in the most recent first preset time period, the electronic device puts the physical page into the inactive linked list corresponding to the number of physical pages mapped by the application process; if it is detected that the physical page in the active linked list has been accessed in the most recent first preset time period, the electronic device moves the physical page to the other side of the active linked list. Thus, a method for processing the physical pages after scanning the inactive linked list is provided.

[0015] In a possible implementation, the method further includes: when m > 1, the electronic device puts the active physical pages with allocated memory into the corresponding active linked list among the m active linked lists according to the number of times the physical pages are accessed.

[0016] Exemplarily, the electronic device can determine whether a physical page has been accessed in the most recent first preset time period according to the PG_referenced flag bit of each physical page, and combine the identifier of the active_list where each physical page is located (used to identify different active_lists) to determine the frequency of access to the physical page.

[0017] According to the locality principle, when the CPU accesses memory, whether it is accessing instructions or data, the accessed storage units tend to be concentrated in a relatively small continuous area. That is to say, the physical pages that are frequently accessed are usually accessed again. Repeatedly performing reclaim checks on frequently accessed physical pages is meaningless and wastes resources. However, in this application, a longer period is used to perform reclaim checks on frequently accessed physical pages, which can avoid unnecessary reclaim checks of the operating system processes and improve the read and write performance of the operating system.

[0018] In a possible implementation, if it is detected that a physical page in the n inactive linked lists has been accessed within a recent preset time period, the electronic device moves the physical page to one of the m active linked lists. Specifically, if it is detected that a physical page in the n inactive linked lists has been accessed within a recent preset time period, the electronic device moves the physical page to the active linked list with the smallest number of access times among the m active linked lists. Thus, another processing method for the physical pages in the inactive linked lists after scanning is provided.

[0019] In a possible implementation, the method further includes: during the process of the electronic device reclaiming the physical pages of the memory, the electronic device scans the m active linked lists and performs reclaim checks on the physical pages scanned in the m active linked lists; if it is detected that a physical page in the m active linked lists has not been accessed within a recent preset time period, the electronic device puts the physical page into the inactive linked list corresponding to the number of times the physical page is mapped by the application process; if it is detected that a physical page in the first active linked list among the m active linked lists has been accessed within a recent preset time period, the electronic device moves the physical page to the second active linked list among the m active linked lists, and the number of access times of the physical pages in the second active linked list is greater than that of the physical pages in the first active linked list. Thus, a processing method for the physical pages in the active linked lists after scanning is provided.

[0020] In a possible implementation, the electronic device scans the m active linked lists, including: during the process of the electronic device reclaiming the physical pages of the memory, the electronic device performs Q rounds of scanning on the m active linked lists, where Q is an integer greater than or equal to 2; in each round of scanning among the Q rounds of scanning, the electronic device starts scanning from the active linked list where the physical page with the smallest number of access times is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different. Thus, a method for scanning each of the m active linked lists with different periods is provided.

[0021] In a possible implementation, during each round of scanning in the Q-round scanning, the electronic device scans starting from the active list where the physical page with the smallest number of accesses is located, according to the sorting of the m active lists. Moreover, the number of active lists scanned in each round is different. Specifically, during each round of scanning in the Q-round scanning, the electronic device scans starting from the active list where the physical page with the smallest number of accesses is located, according to the sorting of the m active lists, and the number of active lists scanned in each round increases by a preset number compared to the number of active lists scanned in the previous round.

[0022] In a second aspect, a memory management method is provided, which is applied to an electronic device. The memory of the electronic device includes one or more memory regions, and each memory region in the one or more memory regions corresponds to an inactive list and m active lists, where m is an integer greater than 1. The method includes: the electronic device places the allocated and active physical pages in the corresponding active list among the m active lists according to the number of times the physical pages are accessed; during the process of the electronic device reclaiming physical pages of the memory, the electronic device scans each of the m active lists and performs a reclaim check on the physical pages in each of the m active lists scanned; among them, the greater the number of times the physical pages in the active list are accessed, the longer the scanning period corresponding to the active list; if it is detected that the physical pages in the m active lists have not been accessed in the most recent preset time period, the electronic device places the physical pages on one side of the inactive list; if it is detected that the physical pages in the first active list among the m active lists have been accessed in the most recent preset time period, the electronic device moves the physical pages to the second active list among the m active lists, and the number of times the physical pages in the second active list are accessed is greater than the number of times the physical pages in the first active list are accessed.

[0023] It can be seen that the physical pages that are frequently accessed are usually accessed again, and it is meaningless and resource-wasting to repeatedly perform reclaim checks on the frequently accessed physical pages. However, in this application, a longer period is used to perform reclaim checks on the frequently accessed physical pages, which can avoid unnecessary reclaim checks of the operating system processes and improve the read / write performance of the operating system.

[0024] In a possible implementation, the electronic device scans each of the m active lists, including: during the process of the electronic device reclaiming physical pages of the memory, the electronic device performs Q rounds of scanning on the m active lists, where Q is an integer greater than or equal to 2; during each round of scanning in the Q-round scanning, the electronic device scans starting from the active list where the physical page with the smallest number of accesses is located, according to the sorting of the m active lists, and the number of active lists scanned in each round is different.

[0025] In a possible implementation, during each round of scanning in the Q-round scanning, the electronic device scans starting from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists. Moreover, the number of active lists scanned in each round is different. Specifically, during each round of scanning in the Q-round scanning, the electronic device scans starting from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is increased by a preset number compared to the number of active lists scanned in the previous round.

[0026] In a possible implementation, the method further includes: during the process of the electronic device reclaiming physical pages of the memory, the electronic device starts scanning from the other side of the inactive list and performs reclaiming checks on the scanned physical pages; if it is checked that the physical page in the inactive list has not been accessed in the most recent preset time period, the electronic device reclaims the physical page; if it is checked that the physical page in the inactive list has been accessed in the most recent preset time period, the electronic device moves the physical page to the active list with the smallest number of accesses among the m active lists.

[0027] In a third aspect, there is provided an electronic device, including: a processor, a memory, and a touch screen. The memory and the touch screen are coupled to the processor. The memory includes one or more memory areas, and each of the one or more memory areas corresponds to n inactive lists and m active lists, where n is an integer greater than 1, and m is an integer greater than or equal to 1. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor reads the computer instructions from the memory, the electronic device is caused to perform the following operations: place the allocated inactive physical pages of the electronic device into the corresponding inactive lists among the n inactive lists according to the number of times the inactive physical pages are mapped by application processes; during the process of the electronic device reclaiming physical pages, scan each of the n inactive lists and perform reclaiming checks on the physical pages in each scanned inactive list; where the greater the number of times the physical pages in the inactive list are mapped by application processes, the longer the scanning period corresponding to the inactive list; if it is checked that the physical pages in the n inactive lists have not been accessed in the most recent preset time period, reclaim the physical pages; if it is checked that the physical pages in the n inactive lists have been accessed in the most recent preset time period, move the physical pages to the m active lists.

[0028] In a possible implementation, each of the n inactive linked lists is scanned, including: sorting the n inactive linked lists according to the number of times the physical pages are mapped by the application process; during the process of the electronic device reclaiming physical pages, P rounds of scans are performed on the n inactive linked lists, where P is an integer greater than or equal to 2; during each round of scan in the P rounds of scans, starting from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different.

[0029] In a possible implementation, during each round of scan in the P rounds of scans, starting from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different. Specifically, during each round of scan in the P rounds of scans, starting from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, the number of inactive linked lists scanned in each round is increased by a preset number compared to the number of inactive linked lists scanned in the previous round.

[0030] In a possible implementation, the electronic device also performs the following operations: when m = 1, during the process of the electronic device reclaiming physical pages, starting from one side of the active linked list for scanning and performing reclaim checks on the scanned physical pages; if it is checked that the physical page in the active linked list has not been accessed in the most recent preset time period, then move the physical page to the inactive linked list corresponding to the number of times the physical page is mapped by the application process; if it is checked that the physical page in the active linked list has been accessed in the most recent preset time period, then move the physical page to the other side of the active linked list.

[0031] In a possible implementation, the electronic device also performs the following operations: when m > 1, place the allocated active physical pages of the electronic device into the corresponding active linked list among the m active linked lists according to the number of times the physical pages are accessed.

[0032] In a possible implementation, if it is checked that the physical page in the n inactive linked lists has been accessed in the most recent preset time period, then move the physical page to the m active linked lists. Specifically, if it is checked that the physical page in the n inactive linked lists has been accessed in the most recent preset time period, then move the physical page to the active linked list with the smallest number of access times among the m active linked lists.

[0033] In a possible implementation, the electronic device further performs the following operations: During the process of the electronic device reclaiming physical pages, the electronic device scans m active lists and checks for reclaiming the physical pages in the m active lists scanned; if it is checked that the physical pages in the m active lists have not been accessed within a recent preset time period, the physical pages are placed into the inactive list corresponding to the number of physical pages mapped by the application process; if it is checked that the physical pages in the first active list among the m active lists have been accessed within a recent preset time period, the physical pages are moved to the second active list among the m active lists, and the number of accesses to the physical pages in the second active list is greater than that of the physical pages in the first active list.

[0034] In a possible implementation, scanning m active lists includes: During the process of the electronic device reclaiming physical pages, the m active lists are scanned Q rounds in total, where Q is an integer greater than or equal to 2; during each round of scanning in the Q rounds of scanning, starting from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is different.

[0035] In a possible implementation, during each round of scanning in the Q rounds of scanning, starting from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is different. Specifically, during each round of scanning in the Q rounds of scanning, starting from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, the number of active lists scanned in each round is increased by a preset number compared to the number of active lists scanned in the previous round.

[0036] Fourth aspect, an electronic device, comprising: a processor, a memory, and a touch screen, the memory and the touch screen being coupled to the processor, the memory including one or more memory regions, each of the one or more memory regions corresponding to an inactive linked list and m active linked lists, m being an integer greater than 1, the memory being used to store computer program code, the computer program code including computer instructions, when the processor reads the computer instructions from the memory so that the electronic device performs the following operations: according to the number of times the physical page is accessed, put the active physical pages allocated by the electronic device into the corresponding active linked list among the m active linked lists; during the process of the electronic device recycling physical pages, scan each of the m active linked lists, and perform recycling checks on the physical pages in each of the m active linked lists scanned; wherein, the greater the number of times the physical page in the active linked list is accessed, the longer the scanning period corresponding to the active linked list; if it is checked that the physical page in the m active linked lists has not been accessed in the most recent preset time period, put the physical page on one side of the inactive linked list; if it is checked that the physical page in the first active linked list among the m active linked lists has been accessed in the most recent preset time period, move the physical page to the second active linked list among the m active linked lists, and the number of times the physical page in the second active linked list is accessed is greater than the number of times the physical page in the first active linked list is accessed.

[0037] In a possible implementation, scanning each of the m active linked lists includes: during the process of the electronic device recycling physical pages, performing Q rounds of scanning on the m active linked lists, where Q is an integer greater than or equal to 2; during each round of scanning in the Q rounds of scanning, starting from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different.

[0038] In a possible implementation, during each round of scanning in the Q rounds of scanning, starting from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different, specifically: during each round of scanning in the Q rounds of scanning, starting from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, the number of active linked lists scanned in each round is increased by a preset number compared to the number of active linked lists scanned in the previous round.

[0039] In a possible implementation, the electronic device further performs the following operations: During the process of the electronic device reclaiming physical pages, it starts scanning from the other side of the inactive linked list and checks the reclaimed physical pages; if it is detected that the physical pages in the inactive linked list have not been accessed within the most recent preset time period, the physical pages are reclaimed; if it is detected that the physical pages in the inactive linked list have been accessed within the most recent preset time period, the physical pages are moved to the active linked list with the smallest number of access times among the m active linked lists.

[0040] In a fifth aspect, a device is provided. The device is included in an electronic device and has the function of implementing the behavior of the electronic device in any of the methods in the above aspects and possible implementations. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the above function. For example, an allocation module or unit, a scanning module or unit, a reclaiming module or unit, a moving module or unit, and a storage module or unit, etc.

[0041] In a sixth aspect, a computer-readable storage medium is provided, including computer instructions. When the computer instructions run on a terminal, the terminal is caused to execute the method described in the above aspects and any of the possible implementations thereof.

[0042] In a seventh aspect, a computer program product is provided. When the computer program product runs on a computer, the computer is caused to execute the method described in the above aspects and any of the possible implementations thereof.

[0043] In an eighth aspect, a chip system is provided, including a processor. When the processor executes instructions, the processor executes the method described in the above aspects and any of the possible implementations thereof. Description of the Drawings

[0044] Figure 1 Structural schematic diagram of an electronic device provided by an embodiment of the present application Figure 1 ;

[0045] Figure 2 Structural schematic diagram of an electronic device provided by an embodiment of the present application Figure 2 ;

[0046] Figure 3 Schematic diagram of the process of reclaiming physical pages in the prior art;

[0047] Figure 4 Schematic diagram of the process of a memory management method provided by an embodiment of the present application;

[0048] Figure 5 Schematic diagram of the process of another memory management method provided by an embodiment of the present application;

[0049] Figure 6 It is a schematic process diagram of another memory management method provided by an embodiment of the present application;

[0050] Figure 7 It is a schematic structural diagram of a chip system provided by an embodiment of the present application. Specific embodiments

[0051] In the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B may mean A or B; herein, "and / or" is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B may mean: A exists alone, A and B exist simultaneously, and B exists alone.

[0052] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present application, unless otherwise specified, the meaning of "plurality" is two or more.

[0053] In the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner.

[0054] Generally, the operating system of an electronic device divides the memory into multiple memory zones and manages the memory in units of memory zones. In the prior art, the operating system uses an inactive_list and an active_list for each memory zone to implement the management function of physical pages in the memory zone, such as implementing the function of reclaiming physical pages. In the embodiments of the present application, the operating system can use multiple inactive_lists and one active_list for each memory zone to implement the function of reclaiming physical pages. Or, the operating system can use one inactive_list and multiple active_lists for each memory zone to implement the function of reclaiming physical pages. Or, the operating system can use multiple inactive_lists and multiple active_lists for each memory zone to implement the function of reclaiming physical pages.

[0055] Specifically, in some embodiments, the electronic device can place inactive physical pages into different inactive_lists according to the frequency of their access. When reclaiming physical pages, different inactive_lists are checked for reclamation at different intervals. That is, different inactive_lists perform reclamation checks a different number of times within the same time period. Generally speaking, the more times a physical page is accessed, the longer the reclamation check period is, and the lower the number of reclamation checks performed within the same time period. The reclamation check refers to checking whether the physical page has been accessed recently (within the first preset time period), so as to perform corresponding operations according to the check results later.

[0056] In this way, on the one hand, reducing the reclamation check for frequently accessed physical pages reduces the probability of the physical page being reclaimed, extends the survival time of frequently accessed physical pages, and thus improves the memory cache hit rate of the operating system. On the other hand, using a longer period for the reclamation check of frequently accessed physical pages is conducive to checking that the physical page has been accessed within the first preset time period during the reclamation check, so as to move the physical page from the inactive_list to the active_list, which also extends the survival time of frequently accessed physical pages and improves the memory cache hit rate of the operating system.

[0057] In a specific implementation, the electronic device can place physical pages into different inactive_lists according to the value of the mapcount of the physical page. Among them, the mapcount of the physical page is used to represent the number of application processes mapped to the physical page, that is, how many application process page tables (page table entries, PTEs) the physical page is mapped to, or how many application processes it is shared by. We can consider that when a physical page is shared by more application processes, the probability of the physical page being frequently accessed is higher. Then, in the embodiments of the present application, extending the reclamation check period of the shared physical page is equivalent to extending the survival duration of the shared physical page. If the shared physical page is accessed during the extended survival time, the electronic device does not reclaim the shared physical page; if it is not accessed, the electronic device reclaims the shared physical page. It can be seen that, compared with the prior art, the method provided in the embodiments of the present application is conducive to reducing the chance of the shared physical page being reclaimed.

[0058] In some other embodiments, the electronic device can also place active physical pages into different active_lists according to the frequency of their access. Similarly, when reclaiming physical pages, different active_lists are checked for reclamation according to different periods. That is, different active_lists perform different numbers of reclamation checks within the same time period. Generally speaking, the more times a physical page is accessed, the longer the period for the reclamation check, and the lower the number of reclamation checks performed within the same time period. The reclamation check refers to checking whether a physical page has been accessed within the most recent first preset time period, so as to perform corresponding operations according to the check results subsequently. This is because, according to the principle of locality, when the CPU accesses memory, whether it is accessing instructions or data, the accessed storage units tend to be concentrated in a relatively small continuous area. That is to say, frequently accessed physical pages are usually accessed again, and repeatedly performing reclamation checks on frequently accessed physical pages is meaningless and a waste of resources. However, in this application, a longer period is used for reclamation checks on frequently accessed physical pages, which can avoid unnecessary reclamation checks of the operating system process and improve the read and write performance of the operating system.

[0059] In a specific implementation, during the reclamation check, the electronic device can determine whether a physical page has been accessed within the most recent first preset time period according to the PG_referenced flag bit of each physical page, and combine the identifier of the active_list where each physical page is located (used to identify different active_lists) to determine the frequency of access to the physical page.

[0060] Exemplarily, the electronic device of this application can be a mobile phone, a tablet computer, a personal computer (PC), a personal digital assistant (PDA), a smart watch, a netbook, a wearable electronic device, an augmented reality (AR) device, a virtual reality (VR) device, a vehicle-mounted device, a smart car, a smart speaker, a robot, etc. This application does not impose special restrictions on the specific form of the electronic device.

[0061] Figure 1 Shows a schematic structural diagram of the electronic device 100.

[0062] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0063] It can be understood that the structure schematically shown in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0064] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0065] The controller may generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.

[0066] A memory can also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can hold the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the said memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

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

[0068] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 can be respectively coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: The processor 110 can be coupled to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface to implement the touch function of the electronic device 100.

[0069] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple groups of I2S buses. The processor 110 can be coupled to the audio module 170 through the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the I2S interface to implement the function of answering a call through a Bluetooth headset.

[0070] The PCM interface can also be used for audio communication to sample, quantize, and encode analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled through the PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface to implement the function of answering a call through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0071] The UART interface is a general-purpose serial data bus for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0072] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate through the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface to implement the display function of the electronic device 100.

[0073] The GPIO interface can be configured through software. The GPIO interface can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0074] The USB interface 130 is an interface that complies with the USB standard specification, and can specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used for data transmission between the electronic device 100 and peripheral devices. It can also be used to connect a headset to play audio through the headset. This interface can also be used to connect other electronic devices, such as AR devices, etc.

[0075] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods or a combination of multiple interface connection methods in the above embodiments.

[0076] The charging management module 140 is configured to receive a charging input from a charger. The charger may be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 may receive the charging input from the wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 may also supply power to the electronic device through the power management module 141.

[0077] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives the inputs from the battery 142 and / or the charging management module 140 and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, etc. The power management module 141 may also be used to monitor parameters such as the battery capacity, the number of battery cycles, and the battery health status (leakage, impedance). In some other embodiments, the power management module 141 may also be disposed in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be disposed in the same device.

[0078] The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.

[0079] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas may also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 may be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna may be used in combination with a tuning switch.

[0080] The mobile communication module 150 may provide solutions for wireless communications such as 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 may receive electromagnetic waves through the antenna 1, filter, amplify, and perform other processing on the received electromagnetic waves, and then transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modulation and demodulation processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least some functional modules of the mobile communication module 150 may be provided in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be provided in the same device.

[0081] The modulation and demodulation processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, receiver 170B, etc.), or displays an image or video through the display screen 194. In some embodiments, the modulation and demodulation processor may be an independent device. In other embodiments, the modulation and demodulation processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.

[0082] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared (IR), and the like. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.

[0083] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, such that electronic device 100 can communicate with a network and other devices via wireless communication technologies. The wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).

[0084] Electronic device 100 implements a display function via a GPU, display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, and is connected to display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0085] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.

[0086] The electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, etc.

[0087] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and light passes through the lens and is transmitted to the camera photosensitive element. The optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.

[0088] The camera 193 is used to capture static images or videos. An object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, etc. format. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.

[0089] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.

[0090] The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple coding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0091] The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission pattern between human brain neurons, it can quickly process input information and can also continuously learn on its own. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as: image recognition, face recognition, speech recognition, text understanding, etc.

[0092] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to achieve the data storage function. For example, files such as music and videos are saved in the external memory card.

[0093] The internal memory 121 can be used to store computer-executable program code, and the executable program code includes instructions. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.). The data storage area can store the data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include high-speed random access memory and can also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 and / or the instructions stored in the memory provided in the processor.

[0094] The electronic device 100 can implement audio functions through the audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and the application processor, etc. For example, music playback, recording, etc.

[0095] The audio module 170 is used to convert digital audio information into an analog audio signal for output, and is also used to convert an analog audio input into a digital audio signal. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 can be disposed in the processor 110, or some functional modules of the audio module 170 can be disposed in the processor 110.

[0096] The speaker 170A, also known as the "loudspeaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or hands-free calls through the speaker 170A.

[0097] The receiver 170B, also known as the "earpiece", is used to convert an audio electrical signal into a sound signal. When the electronic device 100 answers a call or a voice message, the voice can be listened to by placing the receiver 170B close to the human ear.

[0098] The microphone 170C, also known as the "microphone" or "transmitter", is used to convert a sound signal into an electrical signal. When making a call or sending a voice message, the user can speak by placing the mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In some other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also implement a noise reduction function. In some other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, and implement a directional recording function, etc.

[0099] The headphone jack 170D is used to connect a wired headphone. The headphone jack 170D can be a USB interface 130, or a 3.5 mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0100] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0101] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0102] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.

[0103] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.

[0104] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0105] A distance sensor 180F is used to measure distance. The electronic device 100 can measure distance through infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure distance to achieve rapid focusing.

[0106] The proximity light sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The light-emitting diode may be an infrared light-emitting diode. The electronic device 100 emits infrared light outward through the light-emitting diode. The electronic device 100 uses the photodiode to detect the infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear for a call, so as to automatically turn off the screen to achieve the purpose of power saving. The proximity light sensor 180G can also be used for automatic unlocking and locking of the holster mode and pocket mode.

[0107] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket to prevent accidental touch.

[0108] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access to application locks, fingerprint photography, fingerprint answering of incoming calls, etc.

[0109] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by low temperature. In other embodiments, when the temperature is lower than yet another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0110] The touch sensor 180K, also known as the "touch control device". The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 together form a touch screen, also known as the "touch control screen". The touch sensor 180K is used to detect touch operations acting thereon or in its vicinity. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In some other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, at a different position from that of the display screen 194.

[0111] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals of the vibrating bone mass of the human vocal tract. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure pulsation signals. In some embodiments, the bone conduction sensor 180M can also be disposed in the earphone to form a bone conduction earphone. The audio module 170 can parse out voice signals based on the vibration signals of the vibrating bone mass acquired by the bone conduction sensor 180M to implement the voice function. The application processor can parse out heart rate information based on the blood pressure pulsation signals acquired by the bone conduction sensor 180M to implement the heart rate detection function.

[0112] The keys 190 include a power-on key, volume keys, etc. The keys 190 can be mechanical keys or touch keys. The electronic device 100 can receive key inputs to generate key signal inputs related to the user settings and function control of the electronic device 100.

[0113] The motor 191 can generate vibration prompts. The motor 191 can be used for incoming call vibration prompts and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playing, etc.) can correspond to different vibration feedback effects. Touch operations acting on different areas of the display screen 194 can also correspond to different vibration feedback effects by the motor 191. Different application scenarios (such as time reminder, receiving information, alarm clock, game, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0114] The indicator 192 can be an indicator light and can be used to indicate the charging state, power change, and can also be used to indicate messages, missed calls, notifications, etc.

[0115] The SIM card interface 195 is used to connect to the SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to achieve contact and separation from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, that is, an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0116] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present invention, the Android system with a layered architecture is taken as an example to exemplarily illustrate the software structure of the electronic device 100.

[0117] Figure 2 It is a software structure block diagram of the electronic device 100 in the embodiments of the present invention.

[0118] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0119] The application layer may include a series of application packages.

[0120] As Figure 2 shown, the application packages may include applications such as a camera, a gallery, a calendar, a call, a map, a navigation, a WLAN, a Bluetooth, music, a video, a short message, etc.

[0121] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.

[0122] As Figure 2 shown, the application framework layer may include a window manager, a content provider, a view system, a telephone manager, a resource manager, a notification manager, etc.

[0123] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0124] The content provider is used to store and obtain data, and make this data accessible to application programs. The data may include videos, images, audio, incoming and outgoing calls, browsing history and bookmarks, phone books, etc.

[0125] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build application programs. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon may include a view for displaying text and a view for displaying pictures.

[0126] The phone manager is used to provide the communication function of the electronic device 100. For example, the management of call states (including connection, disconnection, etc.).

[0127] The resource manager provides various resources for application programs, such as localized strings, icons, pictures, layout files, video files, etc.

[0128] The notification manager enables application programs to display notification information in the status bar. It can be used to convey message types of notifications, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform that the download is completed, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as the notification of a background running application program, and can also be a notification that appears on the screen in the form of a dialogue window. For example, prompting text information in the status bar, emitting a prompt tone, the electronic device vibrating, the indicator light flashing, etc.

[0129] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for the scheduling and management of the Android system.

[0130] The core libraries contain two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.

[0131] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as the management of object life cycles, stack management, thread management, security and exception management, and garbage collection.

[0132] The system library may include multiple functional modules. For example: a surface manager, Media Libraries, a 3D graphics processing library (e.g., OpenGL ES), a 2D graphics engine (e.g., SGL), etc.

[0133] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.

[0134] The media library supports the playback and recording of multiple common audio and video formats, as well as static image files, etc. The media library can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0135] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.

[0136] The 2D graphics engine is a drawing engine for 2D drawing.

[0137] The kernel layer is the layer between hardware and software. The kernel layer at least includes a display driver, a camera driver, an audio driver, and a sensor driver.

[0138] In the embodiment of the present application, the kernel layer further includes a memory management module for allocating and managing the memory resources of the electronic device 100. Specifically, it includes efficiently and quickly allocating memory resources, and releasing and recycling memory resources at appropriate times.

[0139] For example, the memory management module uses multiple inactive_lists and / or multiple active_lists to manage the allocated physical pages. Place the newly allocated physical pages in the corresponding inactive_list and / or active_list.

[0140] For another example, when the memory management module performs the operation of reclaiming physical pages, it can adopt a specific scanning scheme to scan the physical pages in multiple inactive_lists and / or multiple active_lists, and perform a reclaim check on the scanned physical pages.

[0141] For another example, when performing reclaim check on physical pages in the inactive_list, the physical pages are reclaimed according to the result of the reclaim check, or the physical pages are moved to a specific active_list. When performing reclaim check on the active_list, the physical pages are moved to other active_lists according to the result of the reclaim check, or the physical pages are moved to a specific inactive_list. The specific solution will be described in detail below.

[0142] The technical solutions involved in the embodiments of the present application can all be implemented in the electronic device 100 with the above-mentioned hardware architecture and software architecture. Hereinafter, taking the installation of the Linux operating system in the electronic device 100 as an example for illustration.

[0143] In the prior art, as Figure 3 shown, the operating system maintains each physical page allocated by the operating system with only one inactive_list and one active_list for each memory area. When the operating system performs the reclaim operation of physical pages, it starts scanning each physical page from the tail of the inactive_list and checks whether the scanned physical page has been accessed within the first preset time period recently. If it has been accessed, the physical page is inserted into the head of the active_list. If it has not been accessed, the physical page can be reclaimed. It should be noted that there are ratio and total amount limitations on the number of physical pages in the inactive_list and the active_list. If the ratio of physical pages in the inactive_list is lower than the threshold, the physical pages in the active_list are scanned, and the physical pages that have not been used within the first preset time period recently are moved to the head of the inactive_list. Until the physical pages reclaimed from the inactive_list meet the memory requirements.

[0144] In the embodiments of the present application, the operating system uses multiple inactive_lists for each memory area, and one or more active_lists to maintain each physical page allocated by the operating system. Moreover, different recycling check periods are adopted for different inactive_lists to increase the recycling check period for frequently accessed physical pages (such as physical pages shared by multiple application processes), extend the survival time of frequently accessed physical pages, improve the cache hit rate of the memory, and improve the read / write performance of the operating system. Alternatively, the operating system uses multiple active_lists for one memory area, and one or more active_lists to maintain each physical page allocated by the operating system. Moreover, different recycling check periods are adopted for different active_lists to increase the recycling check period for frequently accessed physical pages, reduce unnecessary recycling checks, and improve the read / write performance of the operating system.

[0145] In some embodiments, as Figure 4 shown, the operating system may use n inactive_lists and one active_list for each memory area, and adopt different recycling check periods for different inactive_lists. Wherein, n is an integer greater than or equal to 2.

[0146] 1. First, introduce the division basis of different inactive_lists and the different recycling check periods for different inactive_lists.

[0147] To facilitate the distinction of different inactive_lists, in this article, inactive_list[i] is used to represent the i-th inactive_list, that is, the i value is used to represent the index value or identifier of the inactive_list. In the present application, the n inactive_lists are divided according to the number of times the physical page is accessed. That is to say, the number of times the physical page stored in inactive_list[i] is accessed is positively or negatively correlated with the size of the i value in inactive_list[i].

[0148] It should be noted that the division of the n inactive_lists here is to facilitate the subsequent adoption of different scanning periods and recycling periods for these n inactive_lists respectively. Therefore, the n inactive_lists can be logically divided, that is, the n inactive_lists are not necessarily physically separated.

[0149] Exemplarily, as described above, the larger the mapcount value of a physical page, the more applications share the physical page, and it can be considered that the probability of the physical page being frequently accessed is higher, that is, the number of accesses is more. Therefore, the n inactive_lists can be divided according to the size order of the mapcount of the physical pages stored in inactive_list[i], so that the mapcount value of the physical pages stored in inactive_list[i] is positively or negatively correlated with the value of i. For example: the larger the mapcount value of the physical pages stored in inactive_list[i], the larger or smaller the value of i.

[0150] Taking n = 4 as an example, the mapcount value of the physical pages stored in inactive_list[i] is positively correlated with the value of i.

[0151] For example, Table 1 shows the corresponding relationship between the numerical values of the physical page mapcount and inactive_list[i].

[0152] Table 1

[0153]

[0154] That is to say, when the mapcount value of a physical page is 1, the physical page is placed in inactive_list[0]; when the mapcount value of a physical page is 2, the physical page is placed in inactive_list[1]; when the mapcount value of a physical page is 3, the physical page is placed in inactive_list[2]; when the mapcount value of a physical page is greater than or equal to 4, the physical page is placed in inactive_list[3].

[0155] It can be seen that the number of times the physical pages in inactive_list[0] are accessed < the number of times the physical pages in inactive_list[1] are accessed < the number of times the physical pages in inactive_list[2] are accessed < the number of times the physical pages in inactive_list[3] are accessed.

[0156] Again, for example, Table 2 shows another corresponding relationship between the numerical values of the physical page mapcount and inactive_list[i].

[0157] Table 2

[0158]

[0159]

[0160] It can be seen that the number of times the physical page in inactive_list[0] is accessed < the number of times the physical page in inactive_list[1] is accessed < the number of times the physical page in inactive_list[2] is accessed < the number of times the physical page in inactive_list[3] is accessed. Other content can be referred to the description in Table 1.

[0161] For another example, Table 3 shows the corresponding relationship between the value of the physical page mapcount and inactive_list[i] in another case.

[0162] Table 3

[0163]

[0164] It can be seen that the number of times the physical page in inactive_list[0] is accessed < the number of times the physical page in inactive_list[1] is accessed < the number of times the physical page in inactive_list[2] is accessed < the number of times the physical page in inactive_list[3] is accessed. Other content can be referred to the description in Table 1.

[0165] In summary, the embodiments of the present application do not limit the specific corresponding relationship between the value of the physical page mapcount and inactive_list[i], and it is only necessary that the value of the physical page mapcount is roughly positively or negatively correlated with the i value in inactive_list[i].

[0166] When the operating system performs the recycling operation of the physical page, it will scan the physical pages in each inactive_list and perform a recycling check on the scanned physical pages, that is, judge whether the physical page has been accessed in the most recent first preset time period, so as to perform different operations according to different check results in the follow-up. In the present application, the scanning period of the inactive_list (hereinafter simply referred to as the frequently accessed inactive_list) storing frequently accessed physical pages can be increased, and then the recycling check period of the physical pages in the frequently accessed inactive_list can be increased, so as to increase the recycling check period of the frequently accessed physical pages, and then reduce the number of recycling checks on the frequently accessed physical pages. That is to say, the more times the physical page is accessed, the larger the corresponding scanning period is, and the larger the corresponding recycling check period is.

[0167] Taking Table 1 as an example, according to the above analysis, it is known that the number of times the physical page in inactive_list[0] is accessed < the number of times the physical page in inactive_list[1] is accessed < the number of times the physical page in inactive_list[2] is accessed < the number of times the physical page in inactive_list[3] is accessed. Then, the scan periods of each inactive_list can be set as follows: the scan period of inactive_list[0] > the scan period of inactive_list[1] > the scan period of inactive_list[2] > the scan period of inactive_list[2].

[0168] Generally speaking, P rounds of scans can be performed on n inactive_lists. During each round of scanning, inactive_lists with more access times are added according to certain rules. Among them, P is greater than or equal to 2. In this way, during P rounds of scans, the physical pages in n inactive_lists are all scanned at least once, and the number of rounds of scans participated by inactive_lists with fewer access times is greater than that of inactive_lists with more access times. The following gives two specific solutions, Solution 1 and Solution 2, by way of example.

[0169] Solution 1: Start scanning from the tail of the inactive_list with the fewest access times, and add a specific number (for example: 1) of inactive_lists with more access times during each round of scanning.

[0170] When specifically implemented, a counter a can be added to represent the inactive_list to be processed in this round of scanning. For example, use inactive_list[0:a] to represent the inactive_list[0] to inactive_list to be processed in this round of scanning. The counter e represents the currently processed inactive_list[e]. The scanning process can refer to the following code:

[0171]

[0172] For example Figure 4 Taking the 4 inactive_lists (n = 4) shown as an example, and taking inactive_list[0] as the linked list with the fewest access times of the physical page.

[0173] In the first round, scan inactive_list[0];

[0174] The second round scans inactive_list[0] and inactive_list[1];

[0175] The third round scans inactive_list[0], inactive_list[1] and inactive_list[2];

[0176] The fourth round scans inactive_list[0], inactive_list[1], inactive_list[2] and inactive_list[3].

[0177] As can be seen from the above, after four rounds (P = 4) of scanning, all physical pages in inactive_list[0] to inactive_list[3] have been scanned once. And inactive_list[0] is scanned 4 times, inactive_list[1] is scanned 3 times, inactive_list[2] is scanned 2 times, and inactive_list3] is scanned 1 time.

[0178] Solution 2: Start scanning from the tail of the inactive_list with the fewest access times, and add a specific number of inactive_lists with more access times in a round after a preset number.

[0179] For example, still taking Figure 4 the 4 inactive_lists shown as an example, and taking inactive_list[0] as the linked list with the fewest access times of physical pages as an example.

[0180] The first round scans inactive_list[0];

[0181] The second round scans inactive_list[0];

[0182] The third round scans inactive_list[0];

[0183] The fourth round scans inactive_list[0];

[0184] The fifth round scans inactive_list[0] and inactive_list[1];

[0185] The sixth round scans inactive_list[0] and inactive_list[1];

[0186] The seventh round scans inactive_list[0] and inactive_list[1];

[0187] The eighth round scans inactive_list[0], inactive_list[1], and inactive_list[2];

[0188] The ninth round scans inactive_list[0], inactive_list[1], and inactive_list[2];

[0189] The tenth round scans inactive_list[0], inactive_list[1], inactive_list[2], and inactive_list[3].

[0190] As can be seen from the above, after ten rounds (P = 10) of scanning, all the physical pages in inactive_list[0] to inactive_list[3] have been scanned once. And inactive_list[0] is scanned 10 times, inactive_list[1] is scanned 6 times, inactive_list[2] is scanned 3 times, and inactive_list[3] is scanned 1 time.

[0191] Another example: Still taking the Figure 4 four inactive_lists shown as an example, and taking inactive_list[0] as the linked list with the least number of accesses to physical pages.

[0192] The first round scans inactive_list[0];

[0193] The second round scans inactive_list[0];

[0194] The third round scans inactive_list[0];

[0195] The fourth round scans inactive_list[0];

[0196] The fifth round scans inactive_list[0] and inactive_list[1];

[0197] The sixth round scans inactive_list[0] and inactive_list[1];

[0198] The seventh round scans inactive_list[0], inactive_list[1], and inactive_list[2];

[0199] The eighth round scans inactive_list[0], inactive_list[1], inactive_list[2], and inactive_list[3].

[0200] As can be seen from the above, after ten rounds (P = 8) of scanning, all physical pages in inactive_list[0] to inactive_list[3] have been scanned once. And inactive_list[0] has been scanned 8 times, inactive_list[1] has been scanned 4 times, inactive_list[2] has been scanned 2 times, and inactive_list[3] has been scanned 1 time.

[0201] It should be noted that other rules that can be thought of by those skilled in the art can also be used to scan the n inactive_lists, so that the physical pages with more access times in the inactive_list are scanned fewer times, and the physical pages with fewer access times are scanned more times. The embodiments of the present application do not make specific limitations on this.

[0202] 1. Describe the process of the operating system reclaiming physical pages in conjunction with the accompanying drawings.

[0203] When the operating system allocates physical pages for an application process, the allocated physical pages will be put into the LRU linked list, that is, the allocated physical pages will be put into the corresponding active_list or inactive_list according to the scenario. Subsequently, when the operating system reclaims physical pages, it will scan the physical pages in the active_list or n inactive_lists according to certain rules and perform reclaim checks, move the physical pages in the active_list or n inactive_lists, and determine the physical pages that can be reclaimed from the tail of inactive[0] for reclaiming.

[0204] In one example, the operating system checks the page identifier PG_active of the physical page, and PG_active is used to identify the activity level of the physical page.

[0205] If PG_active is set (value is 1), it indicates that the physical page is active. The operating system, for example, calls lru_cache_add_active() to put the physical page into the active_list. At this time, the state of the physical page is [1, 0], that is, PG_active = 1 and PG_referenced = 0. Among them, PG_referenced is used to identify whether the physical page has been accessed within the first preset time period recently. Its function will be described below. If PG_active is not set (value is 0), it indicates that the physical page is inactive. Then the operating system, according to the value of the mapcount of the physical page, for example, calls lru_cache_add() to put the physical page into the corresponding inactive_list[k], where k is an integer greater than or equal to 0 and less than or equal to n. At this time, the state of the physical page is [0, 0], that is, PG_active = 0 and PG_referenced = 0.

[0206] In Linux, the operating system reclaims physical pages mainly including direct reclaim and kswapd (a background process) reclaim. Among them, direct reclaim is triggered by the event of "severe memory shortage". The operating system will call the function try_to_free_pages() to check the physical pages in the current memory areas (inactive_list and active_list), and reclaim the least frequently used physical pages. Kswapd reclaim means that the operating system periodically runs the kswapd process. Once it detects memory shortage, it will trigger the physical page reclaim operation. Its entry function is balance_pgdat(). It should be noted that the memory management method in the embodiments of this application is applicable to the reclaim operation triggered by any one of the methods.

[0207] Please continue to refer to Figure 4 , after triggering the operating system to execute the reclaim operation, the operating system can scan each inactive_list in the above scanning manner and perform reclaim checks on the scanned physical pages. If it is detected that a certain physical page has been accessed recently, the physical page will be moved into the active_list (for example, to the head of the active_list). If it is detected that a certain physical page has not been accessed recently, the physical page will be reclaimed.

[0208] For example, when scanning the physical page A at the tail of inactive_list[0], the check_referenced() function can be called to check the value of the page identifier PG_referenced of the physical page A. Here, PG_referenced is used to identify whether the physical page has been accessed within the first preset time period recently. When the value of PG_referenced is 1, it means that the physical page A has been accessed within the first preset time period recently. When the value of PG_referenced is 0, it means that the physical page A has not been accessed within the first preset time period recently.

[0209] If the return value of the function is 1, indicating that the value of PG_referenced is 1, the physical page A can be moved to the head of active_list. Specifically, the operating system can call the mark_page_accesed operation to set the page identifier PG_active of the physical page A to 1 and move it into active_list. At this time, the state of the physical page A can be recorded as [1, 1], that is, PG_active = 1 and PG_referenced = 1. It should be noted that if the physical page A has not been accessed again within the preset time period, the value of PG_referenced will be cleared to 0. At this time, the state of the physical page A changes to [1, 0], that is, PG_active = 1 and PG_referenced = 0.

[0210] If the return value of the function is 0, indicating that the value of PG_referenced is 0, the physical page A can be recycled. It should be noted that there will be some differences in the recycling process according to the nature of the data cached in the physical page A. For example, if the data in the physical page A is only for caching, that is, the data can be restored from the external memory, the physical page A can be directly released. If the data in the physical page A cannot be restored, the data in the physical page A needs to be swapped to the swap partition first, and then the physical page A is released.

[0211] For another example, when scanning the physical page B at the tail of inactive_list[k], the same method as that for processing the physical page A can still be adopted. If the physical page B has been accessed within the first preset time period recently, the physical page is moved into active_list, otherwise it is recycled.

[0212] It should be noted that the operating system's recycling check and the processing after the recycling check for different inactive_lists are the same. It's just that the operating system has different scanning cycles for the physical pages in different inactive_lists, and thus different recycling check cycles and different numbers of recycling checks.

[0213] In addition, when the ratio of the total number of physical pages in the n inactive_lists to the total number of physical pages in the active_list is lower than a threshold, the operating system scans the physical pages in the active_list and moves the physical pages that have not been used within the first preset time period recently to the corresponding inactive_list, so that the operating system can reclaim physical pages from the tail of the n inactive_lists.

[0214] Please continue to refer to Figure 4 , start scanning from the tail of the active_list and perform reclaim checks on the scanned physical pages. If it is checked that the physical page C has been accessed recently, move the physical page C to the head of the active_list. At this time, the state of the physical page C is [1, 1], that is, PG_active = 1 and PG_referenced = 1. If it is checked that the physical page C has not been accessed recently, move the physical page C to the inactive_list corresponding to the mapcount value of the physical page C, for example, move it to the head of the inactive_list[k]. At this time, the state of the physical page C is [0, 0], that is, PG_active = 0 and PG_referenced = 0. In some examples, the mapcount value may be very large, and the physical page C can also be moved to the inactive_list corresponding to log2(page->mapcount()). Where page->mapcount() is used to represent the numerical value of the mapcount of the physical page C. Among them, the method of reclaim check is the same as the method of reclaim check for the physical pages in the inactive_list, which will not be elaborated here.

[0215] In summary, the inactive physical pages are divided into multiple inactive_lists according to the actual frequency of access, and different scanning periods are adopted for different inactive_lists, so that the number of times the frequently accessed physical pages are scanned is reduced, and then the number of times of reclaim check for the frequently accessed physical pages is also correspondingly reduced.

[0216] In this way, on the one hand, reducing the reclaim check for frequently accessed physical pages reduces the probability of these physical pages being reclaimed, which is equivalent to extending the survival time of frequently accessed physical pages, thereby improving the memory cache hit rate and the read / write performance of the operating system. On the other hand, performing the reclaim check on frequently accessed physical pages at a longer interval is conducive to detecting during the reclaim check that the physical page has been accessed within the most recent first preset time period, so as to move the physical page from the inactive_list to the active_list, extending the survival time of the frequently accessed physical page, thereby improving the memory cache hit rate and the read / write performance of the operating system.

[0217] In some examples of this embodiment, the above-mentioned frequently accessed inactive pages may be, for example, physical pages shared by multiple application processes, specifically, some parts of the basic library files shared by multiple application processes.

[0218] In the prior art, the method of memory locking (mlock) can be used to lock some basic library files shared by multiple application processes in memory to prevent the physical pages where the shared basic files are located from being frequently reclaimed, thereby improving the memory cache hit rate. However, it should be noted that generally, the mlock method locks the entire file in memory, which has at least two deficiencies: First, according to the principle of locality, generally, the data accessed by the CPU is concentrated in a certain continuous area, that is, only a part of the file locked in memory is frequently accessed. However, when the entire file is locked in memory, the infrequently accessed content in the file will occupy the memory space for a long time, resulting in a waste of memory space. Second, once the mlock method locks the entire file in memory, even if the file is no longer accessed or is no longer frequently accessed later, the operating system will not reclaim the physical pages where the file is located, resulting in a waste of memory space.

[0219] However, in the embodiments of the present application, first, the physical pages shared by multiple application processes are determined through mapcount, and then, it is still determined through the reclaim check whether the shared physical pages have been accessed within the most recent first preset time period. If they have been accessed, they are retained in memory. If they have not been accessed, they will be reclaimed. It can be seen that in the present application, the data shared by multiple application processes is determined in units of physical pages, avoiding retaining the data of the entire shared file in memory. In addition, the present application still performs a reclaim check on the shared physical pages and reclaims the physical pages that are no longer frequently accessed. Compared with the memory locking method in the prior art, the memory management method provided by the embodiments of the present application improves the memory cache hit rate while also improving the memory utilization rate.

[0220] In other embodiments, such asFigure 5 As shown, the operating system can use an inactive_list and m active_lists for each memory area to implement the function of reclaiming physical pages. Here, m is an integer greater than or equal to 2. In this embodiment, the number m of active_lists may be the same as or different from the number n of inactive_lists in the above embodiment.

[0221] 1. First, introduce the division basis of different active_lists and the different reclaim check cycles for different active_lists.

[0222] To facilitate the distinction of different active_lists, this article uses active_list[i] to represent the i-th active_list, that is, the i value represents the index value or identifier of the active_list. In this application, the n active_lists are divided according to the number of times the physical page is accessed. That is, the number of times the physical page stored in active_list[i] is accessed is positively or negatively correlated with the size of the i value in active_list[i].

[0223] It should be noted that the division of m active_lists here is to facilitate the subsequent adoption of different scanning cycles and reclaim cycles for these m active_lists respectively. Therefore, the m active_lists can be logically divided, that is, these m inactive_lists are not necessarily physically separated.

[0224] Exemplarily, the m active_lists can be divided according to the number of times the physical page is accessed in the most recent second preset time, so that the number of times the physical page stored in active_list[i] is accessed in the most recent second preset time period is positively or negatively correlated with the size of the i value. For example: the larger the number of times the physical page stored in active_list[i] is accessed, the larger or smaller the i value.

[0225] Taking m = 4 as an example, where the number of times the physical page stored in active_list[i] is accessed in the most recent second preset time period is positively correlated with the size of the i value.

[0226] For example, Table 4 shows the corresponding relationship between the number of times a physical page is accessed in the most recent second preset time period and active_list[i].

[0227] Table 4

[0228]

[0229] That is to say, when the number of times a physical page is accessed within the second preset time period recently is 1, the physical page is placed in active_list[0]; when the number of times a physical page is accessed within the second preset time period recently is 2, the physical page is placed in active_list[1]; when the number of times a physical page is accessed within the second preset time period recently is 3, the physical page is placed in active_list[2]; when the number of times a physical page is accessed within the second preset time period recently is greater than or equal to 4, the physical page is placed in active_list[3].

[0230] It should be noted that when judging the number of times a physical page is accessed within the second preset time period recently, it can be judged as follows: when a physical page is just added to the LRU linked list, or when it moves from the inactive_list in the LRU linked list to the active_list, it can be considered that the physical page is accessed for the first time within the second preset time period recently, that is, it is added to active_list[0]. Then, when the physical page moves among multiple active_lists, the index value of the active_list to be added can be determined according to the current index value of the physical page and whether the physical page is accessed within the first preset time period recently, that is, the index value of the newly added active_list is determined. Generally, the duration of the first preset time period is less than the duration of the second preset time period.

[0231] That is, assuming that the physical page is located in active_list[k], when k is less than m - 1, if it is determined that the physical page is accessed within the first preset time period recently, the physical page is added to active_list[k + 1]. When k = m - 1, that is, the physical page is located in active_list[m - 1], if it is determined that the physical page is accessed within the first preset time period recently, the physical page is retained in active_list[m - 1].

[0232] It can be seen that the number of times the physical page in active_list[0] is accessed < the number of times the physical page in active_list[1] is accessed < the number of times the physical page in active_list[2] is accessed < the number of times the physical page in active_list[3] is accessed.

[0233] For another example, Table 5 shows the corresponding relationship between the number of times a physical page is accessed within the second preset time period and active_list[i].

[0234] Table 5

[0235]

[0236] It can be seen that the number of times the physical page in active_list[0] is accessed < the number of times the physical page in active_list[1] is accessed < the number of times the physical page in active_list[2] is accessed < the number of times the physical page in active_list[3] is accessed. For other content, please refer to the description in Table 4.

[0237] For another example, Table 6 shows the corresponding relationship between the number of times a physical page is accessed within a second preset time period and active_list[i].

[0238] Table 6

[0239]

[0240] It can be seen that the number of times the physical page in active_list[0] is accessed < the number of times the physical page in active_list[1] is accessed < the number of times the physical page in active_list[2] is accessed < the number of times the physical page in active_list[3] is accessed. For other content, please refer to the description in Table 4.

[0241] In summary, the embodiments of the present application do not limit the specific corresponding relationship between the number of times a physical page is accessed within the most recent second preset time period and active_list[i], as long as the number of times a physical page is accessed within the most recent second preset time period is roughly positively or negatively correlated with the i value in active_list[i].

[0242] When the operating system performs the recycling operation of physical pages, when the ratio of the total number of physical pages in the inactive_list to the total number of physical pages in m active_lists is lower than the threshold, the operating system will scan the physical pages in the m active_lists and move the physical pages that have not been used within the most recent first preset time period to the inactive_list, so as to recycle the physical pages that have not been used within the most recent first preset time period from the inactive_list. In the present application, the scanning period of the active_list (subsequently referred to as the active_list with frequent access) storing physical pages with frequent access can be increased, and then the recycling check period of the physical pages in the active_list with frequent access can be increased, so as to increase the recycling check period of the physical pages with frequent access, and then reduce the number of recycling checks for the physical pages with frequent access. That is to say, the more times a physical page is accessed, the larger the corresponding scanning period and the larger the corresponding recycling check period.

[0243] Taking Table 4 as an example, according to the above analysis, it is known that the number of times the physical page in active_list[0] is accessed < the number of times the physical page in active_list[1] is accessed < the number of times the physical page in active_list[2] is accessed < the number of times the physical page in active_list[3] is accessed. Then, the scan periods of each active_list can be set as follows: the scan period of active_list[0] > the scan period of active_list[1] > the scan period of active_list[2] > the scan period of active_list[2].

[0244] Generally speaking, Q rounds of scanning can be performed on m active_lists. During each round of scanning, active_lists with more access times are added according to certain rules. Among them, Q is greater than or equal to 2. In this way, during Q rounds of scanning, the physical pages in m active_lists are all scanned at least once, and the number of rounds of scanning participated by active_lists with fewer access times is greater than that of active_lists with more access times. The following gives two specific schemes, Scheme 3 and Scheme 4, by way of example.

[0245] Scheme 3: Start scanning from the tail of the active_list with the fewest access times, and add a specific number (for example: 1) of active_lists with more access times during each round of scanning.

[0246] The specific scanning scheme is similar to Scheme 1 and will not be elaborated here.

[0247] Scheme 4: Start scanning from the tail of the active_list with the fewest access times, and add a specific number of active_lists with more access times during a round of scanning after a preset number.

[0248] The specific scanning scheme is similar to Scheme 2 and will not be elaborated here.

[0249] It should be noted that other rules that can be thought of by those skilled in the art can also be used to scan m active_lists, so that the physical pages with more access times in the active_list are scanned fewer times, and the physical pages with fewer access times are scanned more times. The embodiments of the present application do not make specific limitations on this.

[0250] 2. Describe the process of the operating system reclaiming physical pages in combination with the accompanying drawings.

[0251] When the operating system allocates physical pages for application processes, it places the allocated physical pages into the LRU list, that is, it places the allocated physical pages into the corresponding active_list[0] or inactive_list according to the scenario. Subsequently, when the operating system reclaims physical pages, it scans the physical pages in m active_lists or inactive_lists according to certain rules for reclaiming checks, moves the physical pages among the m active_lists or inactive_lists, and determines the physical pages that can be reclaimed from the tail of the inactive list for reclamation.

[0252] Please continue to refer to Figure 5 , after triggering the operating system to perform the reclaim operation, the operating system scans the inactive_list and performs a reclaim check on the scanned physical pages. If it is detected that a certain physical page has been recently accessed, the physical page is moved to the active_list[0] list (for example, to the head of the active_list[0]). At this time, the state of the physical page is [1,1], that is, PG_active = 1 and PG_referenced = 1. If it is detected that a certain physical page has not been recently accessed, the physical page is reclaimed. Among them, the method of the reclaim check and the method of reclaiming physical pages can refer to the description in the above embodiments and will not be elaborated here.

[0253] When the ratio of the total number of physical pages in the inactive_list to the total number of physical pages in the m active_lists is lower than the threshold, the operating system starts from the active_list[0] and scans the physical pages in the m active_lists according to the above scanning scheme (such as Scheme 3 or Scheme 4), and moves the physical pages that have not been used in the first preset time period recently to the inactive_list, so that the operating system can reclaim physical pages from the tail of the inactive_list.

[0254] Please continue to refer to Figure 5, when the physical page D in active_list[k] is scanned, when k is greater than or equal to 0 and less than m - 1, a reclaim check is performed on the physical page D. If it is detected that the physical page D has been recently accessed, the physical page D is moved to the head of active_list[k + 1]. At this time, the state of the physical page D is [1, 1], that is, PG_active = 1 and PG_referenced = 1. If it is detected that the physical page D has not been recently accessed, the physical page D is moved to the inactive_list, for example, to the head of the inactive_list. At this time, the state of the physical page D is [0, 0], that is, PG_active = 0 and PG_referenced = 0.

[0255] When k = m - 1, that is, when the physical page E in active_list[m - 1] is scanned, a reclaim check is performed on the physical page E. If it is detected that the physical page E has been recently accessed, the physical page is placed at the head of active_list[m - 1]. If it is detected that the physical page E has not been recently accessed, the physical page E is moved to the inactive_list, for example, to the head of the inactive_list.

[0256] It should be noted that the reclaim check and the processing after the reclaim check performed by the operating system on different active_lists are the same. It's just that the operating system has different scanning periods for the physical pages in different active_lists, and thus the number of reclaim checks is different.

[0257] In summary, the active physical pages are divided into multiple active_lists according to the actual frequency of access, and different scanning periods are adopted for different active_lists, so that the number of times the frequently accessed physical pages are scanned is reduced, and accordingly the number of reclaim checks for the frequently accessed physical pages is also reduced. In this way, it is beneficial to avoid multiple unnecessary reclaim checks on the frequently accessed physical pages, accelerate the reclaim efficiency of the operating system for physical pages, and improve the performance of the operating system.

[0258] In some other embodiments, as Figure 6 shown, the operating system can use n inactive_lists and m active_lists for each memory area to implement the function of reclaiming physical pages.

[0259] Among them, the division method and scanning scheme of the n inactive_lists, and the division method and scanning scheme of the m active_lists can refer to the above embodiments and will not be elaborated here.

[0260] Exemplarily, when the operating system allocates physical pages for an application process, the allocated physical pages will be placed in the LRU linked list, that is, the allocated physical pages will be placed in the corresponding active_list[0] according to the scenario, or, combined with the value of the mapcount of the physical page, the physical page will be placed in the corresponding inactive_list[k].

[0261] Subsequently, when the operating system performs the operation of reclaiming physical pages, it will scan the physical pages in the n inactive_lists and perform reclaim checks according to the above scanning scheme (such as Scheme 1 or Scheme 2). If it is detected that the scanned physical page has been accessed within the first preset time period recently, the physical page will be moved to active_list[0]. If it is detected that the scanned physical page has not been accessed within the first preset time period recently, the physical page can be reclaimed.

[0262] When the ratio of the total number of physical pages in the n inactive_lists to the total number of physical pages in the m active_lists is lower than the threshold, the operating system will scan the physical pages in the m active_lists and move the physical pages that have not been used within the first preset time period recently to the corresponding inactive_list[k], so that the operating system can reclaim physical pages from the tail of the n inactive_lists.

[0263] The operating system will scan the physical pages in the m active_lists and perform reclaim checks according to the above scanning scheme (such as Scheme 3 or Scheme 4). For example, when scanning the physical page in active_list[k], when k is not equal to m - 1, if it is detected that the physical page has been accessed within the first preset time period recently, the physical page will be moved to active_list[k + 1]. If it is detected that the physical page has not been accessed within the first preset time period recently, according to the value of the mapcount of the physical page, the physical page will be moved to the corresponding inactive_list. When k is equal to m - 1, that is, when scanning the physical page in active_list[m - 1], if it is detected that the physical page has been accessed within the first preset time period recently, the physical page will be moved to the head of active_list[m - 1]. If it is detected that the physical page has not been accessed within the first preset time period recently, according to the value of the mapcount of the physical page, the physical page will be moved to the corresponding inactive_list.

[0264] Using the existing technology (one memory area corresponding to one active_list and one inactive_list) and the method of this application (one memory area corresponding to 4 active_lists and 4 inactive_lists) respectively, conduct tarus tests on the startup scenarios of the top 40 applications in the current market. The test found that the number of disk reads in the system partition and the data partition decreased by 3.3% and 3.9% respectively, that is, the cache hit rate of the memory was improved. In addition, the startup time of the application is shown in Table VII as follows:

[0265] Table VII

[0266]

[0267] It can be seen that the method provided by the embodiments of this application effectively improves the read and write performance of the operating system and speeds up the running rate of the application.

[0268] The embodiments of this application also provide a chip system, as Figure 7 shown. The chip system includes at least one processor 1101 and at least one interface circuit 1102. The processor 1101 and the interface circuit 1102 can be interconnected by a line. For example, the interface circuit 1102 can be used to receive signals from other devices (such as the memory of the electronic device 100). For another example, the interface circuit 1102 can be used to send signals to other devices (such as the processor 1101). Exemplarily, the interface circuit 1102 can read the instructions stored in the memory and send the instructions to the processor 1101. When the instructions are executed by the processor 1101, the electronic device can execute each step executed by the electronic device 100 in the above embodiments (for example, a mobile phone). Of course, the chip system can also include other discrete devices, and the embodiments of this application do not make specific limitations on this.

[0269] It can be understood that in order to implement the above functions, the above terminals and the like include the corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should easily realize that, combining the units and algorithm steps of each example described in the embodiments disclosed in this article, the embodiments of this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of the present invention.

[0270] The embodiments of the present application can divide the above-mentioned terminals, etc. into functional modules according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiments of the present invention is illustrative, and is only a logical function division. There may be other division methods in actual implementation.

[0271] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0272] In each embodiment of the present application, each functional unit can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0273] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: various media that can store program codes, such as flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk, or optical disc.

[0274] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for managing memory, characterized in that, Applied to an electronic device, the memory of the electronic device includes one or more memory regions, and each of the one or more memory regions corresponds to n inactive linked lists and m active linked lists, where n is an integer greater than 1, and m is an integer greater than or equal to 1. The method includes: The electronic device places the allocated inactive physical pages of the memory into the corresponding inactive linked list among the n inactive linked lists according to the number of inactive physical pages mapped by the application process. The number of physical pages stored in the i-th inactive linked list among the n inactive linked lists is positively or negatively correlated with the value of i, and i is an integer greater than or equal to 0 and less than or equal to n - 1; During the process of the electronic device reclaiming physical pages of the memory, the electronic device scans each of the n inactive linked lists and performs a reclaim check on the physical pages in each scanned inactive linked list; among them, the larger the number of physical pages in the inactive linked list mapped by the application process, the longer the scanning period corresponding to the inactive linked list, and the fewer the number of times the inactive linked list is scanned; If it is checked that the physical pages in the n inactive linked lists have not been accessed in the most recent preset time period, the electronic device reclaims the physical pages; If it is checked that the physical pages in the n inactive linked lists have been accessed in the most recent preset time period, the electronic device moves the physical pages to the m active linked lists.

2. The method according to claim 1, characterized in that The electronic device scanning each of the n inactive linked lists includes: The electronic device sorts the n inactive linked lists according to the number of physical pages mapped by the application process; During the process of the electronic device reclaiming physical pages of the memory, the electronic device performs P rounds of scanning on the n inactive linked lists, where P is an integer greater than or equal to 2; During each round of scanning in the P rounds of scanning, the electronic device starts scanning from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different.

3. The method according to claim 2, wherein During each round of scanning in the P rounds of scanning, the electronic device starts scanning from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different. Specifically: During each round of scanning in the P rounds of scanning, the electronic device starts scanning from the inactive linked list where the physical page with the smallest number of mappings by the application process is located according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is increased by a preset number compared to the number of inactive linked lists scanned in the previous round.

4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: When m = 1, during the process of the electronic device reclaiming physical pages of the memory, the electronic device starts scanning from one side of the active linked list and performs a reclaim check on the scanned physical pages; If it is detected that a physical page in the active list has not been accessed within a recent preset time period, the electronic device places the physical page into the inactive list corresponding to the number of times the physical page is mapped by an application process; If it is detected that a physical page in the active list has been accessed within a recent preset time period, the electronic device moves the physical page to the other side of the active list.

5. The method according to any one of claims 1 to 3, characterized in that, The method further includes: When m > 1, the electronic device places the active physical pages allocated in the memory into the corresponding active list among the m active lists according to the number of times the physical pages are accessed.

6. The method according to claim 5, characterized in that, The step that if it is detected that a physical page in the n inactive lists has been accessed within a recent preset time period, the electronic device moves the physical page to the m active lists, specifically is: If it is detected that a physical page in the n inactive lists has been accessed within a recent preset time period, the electronic device moves the physical page to the active list with the smallest number of times the physical page is accessed among the m active lists.

7. The method according to claim 5, wherein The method further includes: During the process of the electronic device reclaiming physical pages of the memory, the electronic device scans the m active lists and performs a reclaim check on the physical pages scanned in the m active lists; If it is detected that a physical page in the m active lists has not been accessed within a recent preset time period, the electronic device places the physical page into the inactive list corresponding to the number of times the physical page is mapped by an application process; If it is detected that a physical page in the first active list among the m active lists has been accessed within a recent preset time period, the electronic device moves the physical page to the second active list among the m active lists, and the number of times the physical page is accessed in the second active list is greater than the number of times the physical page is accessed in the first active list.

8. The method according to claim 7, wherein The electronic device scans the m active lists, including: During the process of the electronic device reclaiming physical pages of the memory, the electronic device performs Q rounds of scans on the m active lists, where Q is an integer greater than or equal to 2; During each round of scan in the Q rounds of scans, the electronic device starts scanning from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is different.

9. The method according to claim 8, wherein The step that during each round of scan in the Q rounds of scans, the electronic device starts scanning from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is different, specifically is: During each round of scan in the Q rounds of scans, the electronic device starts scanning from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is increased by a preset number compared to the number of active lists scanned in the previous round.

10. A method for managing memory, characterized in that, Applied to an electronic device, the memory of the electronic device includes one or more memory regions, each of the one or more memory regions corresponding to an inactive linked list and m active linked lists, where m is an integer greater than 1. The method includes: The electronic device places the allocated and active physical pages of the memory into the corresponding active linked list among the m active linked lists according to the number of times the physical pages are accessed. The physical pages stored in the i-th active linked list among the m active linked lists have a positive or negative correlation with the value of i, where i is an integer greater than or equal to 0 and less than or equal to m - 1. During the process of the electronic device reclaiming physical pages of the memory, the electronic device scans each of the m active linked lists and performs a reclaim check on the physical pages scanned in each of the m active linked lists. Among them, the greater the number of times the physical pages in the active linked list are accessed, the longer the scanning period corresponding to the active linked list, and the fewer the number of times the active linked list is scanned. If it is checked that the physical pages in the m active linked lists have not been accessed in the most recent preset time period, the electronic device places the physical pages on one side of the inactive linked list. If it is checked that the physical pages in the first active linked list among the m active linked lists have been accessed in the most recent preset time period, the electronic device moves the physical pages to the second active linked list among the m active linked lists, and the number of times the physical pages in the second active linked list are accessed is greater than the number of times the physical pages in the first active linked list are accessed.

11. The method according to claim 10, wherein The electronic device scanning each of the m active linked lists includes: During the process of the electronic device reclaiming physical pages of the memory, the electronic device performs Q rounds of scanning on the m active linked lists, where Q is an integer greater than or equal to 2. In each round of scanning in the Q rounds of scanning, the electronic device starts scanning from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different.

12. The method according to claim 11, wherein In each round of scanning in the Q rounds of scanning, the electronic device starts scanning from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different. Specifically: In each round of scanning in the Q rounds of scanning, the electronic device starts scanning from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is increased by a preset number compared to the number of active linked lists scanned in the previous round.

13. The method according to any one of claims 10 to 12, characterized in that The method further includes: During the process of the electronic device reclaiming physical pages of the memory, the electronic device starts scanning from the other side of the inactive linked list and performs a reclaim check on the scanned physical pages. If it is checked that the physical pages in the inactive linked list have not been accessed in the most recent preset time period, the electronic device reclaims the physical pages. If it is detected that a physical page in the inactive linked list has been accessed within a recent preset time period, the electronic device moves the physical page to the active linked list with the smallest number of accesses among the m active linked lists.

14. An electronic device, characterized in that, Including: A processor, a memory, and a touch screen, where the memory and the touch screen are coupled to the processor. The memory includes one or more memory regions, and each memory region in the one or more memory regions corresponds to n inactive linked lists and m active linked lists. Here, n is an integer greater than 1, and m is an integer greater than or equal to 1. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor reads the computer instructions from the memory, the electronic device is caused to perform the following operations: According to the number of applications to which the inactive physical pages are mapped, the allocated inactive physical pages of the electronic device are placed into the corresponding inactive linked lists among the n inactive linked lists. The number of physical pages stored in the i-th inactive linked list among the n inactive linked lists is positively or negatively correlated with the value of i. i is an integer greater than or equal to 0 and less than or equal to n - 1; During the process of the electronic device reclaiming physical pages, scan each of the n inactive linked lists and perform a reclaim check on the physical pages in each scanned inactive linked list; among them, the larger the number of applications to which the physical pages in the inactive linked list are mapped, the longer the corresponding scan period of the inactive linked list, and the fewer the number of times the inactive linked list is scanned; If it is detected that a physical page in the n inactive linked lists has not been accessed within a recent preset time period, reclaim the physical page; If it is detected that a physical page in the n inactive linked lists has been accessed within a recent preset time period, move the physical page to the m active linked lists.

15. The electronic device according to claim 14, wherein The scanning each of the n inactive linked lists includes: Sort the n inactive linked lists according to the number of applications to which the physical pages are mapped; During the process of the electronic device reclaiming physical pages, perform P rounds of scans on the n inactive linked lists, where P is an integer greater than or equal to 2; During each round of scanning in the P rounds of scanning, start scanning from the inactive linked list where the physical page with the smallest number of applications is mapped according to the sorting of the n inactive linked lists, and the number of inactive linked lists scanned in each round is different.

16. The electronic device according to claim 15, characterized in that, The specific manner of starting scanning from the inactive linked list where the physical page with the smallest number of applications is mapped according to the sorting of the n inactive linked lists during each round of scanning in the P rounds of scanning, and the number of inactive linked lists scanned in each round being different is: During each round of scanning in the P rounds of scanning, start scanning from the inactive linked list where the physical page with the smallest number of applications is mapped according to the sorting of the n inactive linked lists. The number of inactive linked lists scanned in each round is increased by a preset number compared to the number of inactive linked lists scanned in the previous round.

17. The electronic device according to any one of claims 14-16, characterized in that, The electronic device also performs the following operations: When m = 1, during the process of the electronic device reclaiming physical pages, start scanning from one side of the active list, and perform reclaiming checks on the scanned physical pages; If it is checked that the physical page in the active list has not been accessed within the most recent preset time period, put the physical page into the corresponding inactive list according to the number of times the physical page is mapped by the application process; If it is checked that the physical page in the active list has been accessed within the most recent preset time period, move the physical page to the other side of the active list.

18. The electronic device according to any one of claims 14-16, characterized in that, The electronic device also performs the following operations: When m > 1, put the allocated and active physical pages of the electronic device into the corresponding active list among the m active lists according to the number of times the physical pages are accessed.

19. The electronic device according to claim 18, wherein If it is checked that the physical page in the n inactive lists has been accessed within the most recent preset time period, move the physical page to the m active lists, specifically: If it is checked that the physical page in the n inactive lists has been accessed within the most recent preset time period, move the physical page to the active list with the smallest number of times the physical page is accessed among the m active lists.

20. The electronic device according to claim 18, wherein The electronic device also performs the following operations: During the process of the electronic device reclaiming physical pages, the electronic device scans the m active lists and performs reclaiming checks on the physical pages scanned in the m active lists; If it is checked that the physical page in the m active lists has not been accessed within the most recent preset time period, put the physical page into the corresponding inactive list according to the number of times the physical page is mapped by the application process; If it is checked that the physical page in the first active list among the m active lists has been accessed within the most recent preset time period, move the physical page to the second active list among the m active lists, and the number of times the physical page in the second active list is accessed is greater than the number of times the physical page in the first active list is accessed.

21. The electronic device according to claim 20, wherein The scanning of the m active lists includes: During the process of the electronic device reclaiming physical pages, perform Q rounds of scanning on the m active lists, where Q is an integer greater than or equal to 2; During each round of scanning in the Q rounds of scanning, start scanning from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is different.

22. The electronic device according to claim 21, wherein During each round of scanning in the Q rounds of scanning, start scanning from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is different, specifically: During each round of scanning in the Q rounds of scanning, start scanning from the active list where the physical page with the smallest number of accesses is located according to the sorting of the m active lists, and the number of active lists scanned in each round is increased by a preset number compared to the number of active lists scanned in the previous round.

23. An electronic device, characterized in that, Including: A processor, a memory, and a touch screen, where the memory and the touch screen are coupled to the processor. The memory includes one or more memory regions, and each of the one or more memory regions corresponds to an inactive linked list and m active linked lists, where m is an integer greater than 1. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor reads the computer instructions from the memory, the electronic device is caused to perform the following operations: Place the allocated and active physical pages of the electronic device into the corresponding active linked list among the m active linked lists according to the number of times the physical pages are accessed. The physical pages stored in the i-th active linked list among the m active linked lists have a positive or negative correlation with the value of i, where i is an integer greater than or equal to 0 and less than or equal to m - 1; During the process of the electronic device reclaiming physical pages, scan each of the m active linked lists and perform a reclaim check on the physical pages scanned in each of the m active linked lists. Among them, the greater the number of times the physical pages in the active linked list are accessed, the longer the scanning period corresponding to the active linked list, and the fewer the number of times the active linked list is scanned; If it is checked that the physical pages in the m active linked lists have not been accessed in the most recent preset time period, place the physical pages on one side of the inactive linked list; If it is checked that the physical pages in the first active linked list among the m active linked lists have been accessed in the most recent preset time period, move the physical pages to the second active linked list among the m active linked lists, where the number of times the physical pages in the second active linked list are accessed is greater than the number of times the physical pages in the first active linked list are accessed.

24. The electronic device according to claim 23, wherein The scanning of each of the m active linked lists includes: During the process of the electronic device reclaiming physical pages, perform Q rounds of scanning on the m active linked lists, where Q is an integer greater than or equal to 2; During each round of scanning in the Q rounds of scanning, start scanning from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different.

25. The electronic device according to claim 24, wherein During each round of scanning in the Q rounds of scanning, start scanning from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists, and the number of active linked lists scanned in each round is different. Specifically: During each round of scanning in the Q rounds of scanning, start scanning from the active linked list where the physical page with the smallest number of accesses is located according to the sorting of the m active linked lists. The number of active linked lists scanned in each round is increased by a preset number compared to the number of active linked lists scanned in the previous round.

26. The electronic device according to any one of claims 23-25, characterized in that, The electronic device also performs the following operations: During the process of the electronic device reclaiming physical pages, start scanning from the other side of the inactive linked list and perform a reclaim check on the scanned physical pages; If it is checked that the physical pages in the inactive linked list have not been accessed in the most recent preset time period, reclaim the physical pages; If it is detected that the physical page in the inactive linked list has been accessed within the most recent preset time period, move the physical page to the active linked list with the smallest number of accesses among the physical pages in the m active linked lists.

27. A computer-readable storage medium, characterized in that, It includes computer instructions that, when the computer instructions are run on a terminal, cause the terminal to execute the memory management method according to any one of claims 1-13.

28. A chip system, characterized in that, It includes one or more processors that, when the one or more processors execute instructions, the one or more processors execute the memory management method according to any one of claims 1-13.

Citation Information

Patent Citations

  • Memory processing method and apparatus, computer apparatus and computer readable storage medium

    CN108205473A

  • Reusable memory devices with WOM codes

    WO2016116930A1