Memory management method, electronic equipment and computer readable storage medium

By managing shared memory asynchronous threads, the business execution delay caused by read and write lock conflicts in the file system is solved, the business execution speed and user experience are improved, and the application fluency is ensured.

CN119025256APending Publication Date: 2024-11-26HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310613744.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-26
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

In the prior art, read and write lock conflicts in the file system cause delays in business execution, causing lags, and affecting user experience. Especially when the file system data is large, the probability of read and write lock conflicts is high, delaying service execution.

Method used

Using the method of asynchronous thread management of shared memory, allocate a temporary list to store information requesting shared memory in the first thread, and write it to the preset file system in the second thread to avoid read and write lock conflicts, ensure business execution and The information written to the shared memory is not interfering with each other.

Benefits of technology

It effectively avoids business execution delays caused by read and write lock holding, improves business execution speed, improves user experience, and ensures that the processes of other businesses in the application are not affected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025256A_ABST
    Figure CN119025256A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method, electronic equipment and a computer readable storage medium, and relates to the technical field of memory space processing. When the electronic equipment responds to the first operation of the user on the application, the information of applying for the shared memory is generated, and then the service is executed. In order to facilitate follow-up mounting of information applying for a shared memory by a preset file system and avoid delay of a service execution process due to reading of the information of the preset file system by other services, the electronic equipment firstly stores the information applying for the shared memory in a temporary list in a first thread; and under the condition that the electronic equipment responds to a reading request of the preset file system, creating the information of applying for the shared memory in the temporary list in the preset file system in the second thread, and deleting the information of applying for the shared memory in the temporary list. Therefore, the delay time of service execution of the electronic equipment can be shortened, the service execution speed is increased, a user can feel the service execution fluency, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of memory space processing technology, and in particular to a memory management method, an electronic device, and a computer-readable storage medium. Background Art

[0002] The part of the operating system that processes files is called a file system. In some cases, the electronic device will read the statistical information such as the memory size required by each business process that already exists in the file system, and after the reading operation is completed, the statistical information generated by executing some other business processes will be written into the file system. It can be understood that writing some other statistical information into the file system can be called mounting the statistical information into the file system.

[0003] When an electronic device reads statistical information, it cannot write other statistical information in the file system. This phenomenon is called a read-write lock conflict. Generally, the amount of data in the file system is large, the probability of statistical information being read in the file system is high, and the probability of read-write lock conflicts is high. Read-write lock conflicts will delay the execution of business, which will cause business execution to become stuck. Summary of the invention

[0004] The embodiments of the present application provide a memory management method, an electronic device, and a computer-readable storage medium, which are used to reduce the delay time of the electronic device in executing a service, increase the slow speed of service execution, allow users to feel the smoothness of service execution, and improve user experience.

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

[0006] In a first aspect, a memory management method is provided, the method being applied to an electronic device, the electronic device comprising a shared memory, the shared memory corresponding to a preset file system, the preset file system being used to manage the use of the shared memory, the method comprising: generating information for applying for shared memory in response to a first operation of a user on an application, wherein the information for applying for shared memory is used to indicate the application and use of the shared memory corresponding to the execution of a first business, the first operation being used to trigger the electronic device to execute the first business; storing the information for applying for shared memory in a temporary list in a first thread, and executing the first business in the first thread; wherein, after responding to a read request of the preset file system, deleting the information for applying for shared memory in the temporary list, creating the information for applying for shared memory in the temporary list in the preset file system in a second thread, the first thread and the second thread being asynchronous threads.

[0007] In this solution, the two tasks of writing the business execution and the information of applying for shared memory into the preset file system are executed asynchronously by two threads, and the business execution and the information of applying for shared memory into the preset file system do not interfere with each other. Even if the amount of data in the file system is large, it takes a certain reading time for the electronic device to read the memory size required for each business process in the file system, or it takes a certain writing time to modify the corresponding statistical information, but the process of the electronic device executing the business is not delayed, and the jamming phenomenon in the process of executing the business caused by the read-write lock is avoided to a certain extent. Compared with the existing technology, the speed of business execution is improved to a certain extent, thereby improving the user experience.

[0008] In combination with the first aspect, in a possible design, after executing the first business in the first thread, the method further includes: if there is information on applying for shared memory in the temporary list, deleting the information on applying for shared memory in the temporary list.

[0009] In combination with the first aspect, in a possible design, after executing the first business in the first thread, the method also includes: if there is no information applying for shared memory in the temporary list, storing a memory release task in the third thread, and the memory release task is used to trigger the electronic device to delete the information applying for shared memory in the temporary list, wherein the first thread, the second thread and the third thread are asynchronous threads.

[0010] In this solution, the execution of other services and the information on applying for shared memory are deleted from the preset file system. These two tasks are executed asynchronously by threads, and the information on business execution and shared memory application is written to the preset file system without interfering with each other. The execution process of other services in the application program (for example, after social application A is started, messages sent to friends in the address book are displayed in the conversation interface) will not be delayed. In this way, the delay time for electronic devices to execute services can be reduced, the speed of business execution can be increased, the user can feel the smoothness of business execution, and the user experience can be improved.

[0011] In combination with the first aspect, in a possible design method, a preset operating system is set in the electronic device, and the operating system includes a kernel and an application layer; in response to a first operation of a user on an application, information for applying for shared memory is generated, including: the application in the application layer, in response to the first operation of the user on the application, applies to the kernel for a request to execute a shared memory corresponding to a first business, and the kernel generates information for applying for shared memory in response to the request sent by the application layer to apply for executing the shared memory corresponding to the first business; the information for applying for shared memory is stored in a temporary list in a first thread, and the first business is executed in the first thread, including: the kernel stores the information for applying for shared memory in a temporary list in the first thread, and executes the first business in the first thread; after responding to a read request of a preset file system, the information for applying for shared memory in the temporary list is deleted, and in a second thread, the information for applying for shared memory in the temporary list is created in the preset file system, including: after responding to the read request of the preset file system, the kernel deletes the information for applying for shared memory in the temporary list, and in the second thread, the information for applying for shared memory in the temporary list is created in the preset file system.

[0012] In combination with the first aspect, in a possible design method, a preset operating system is set in the electronic device, and the operating system includes a kernel and an application layer; if there is information applying for shared memory in the temporary list, the information applying for shared memory in the temporary list is deleted; if there is no information applying for shared memory in the temporary list, a memory release task is stored in a third thread, and the memory release task is used to trigger the electronic device to delete the information applying for shared memory in the temporary list, including: if there is information applying for shared memory in the temporary list, the kernel deletes the information applying for shared memory in the temporary list; if there is no information applying for shared memory in the temporary list, the kernel stores a memory release task in the third thread, and the memory release task is used to trigger the kernel to delete the information applying for shared memory in the temporary list.

[0013] In combination with the first aspect, in a possible design, the information for applying for shared memory includes the name of the shared memory application event in a preset file system and the size of the shared memory application.

[0014] In combination with the first aspect, in a possible design, the shared memory is dma-buf shared memory, the preset file system is the Sysfs file system, and the information for applying for shared memory includes the Sysfs file name of the shared memory application event in the Sysfs file system.

[0015] In combination with the first aspect, in a possible design manner, the first service includes launching an application or exiting an application, and executing the first service includes displaying an animation of launching the application or displaying an animation of exiting the application.

[0016] In a second aspect, an electronic device is provided, which includes a processor and a memory; the memory is used to store code instructions; the processor is used to run the code instructions to execute a method for adjusting an audio signal in any possible design manner as in the first aspect.

[0017] In a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes a method for adjusting an audio signal in any possible design manner as in the first aspect.

[0018] In a fourth aspect, a computer program product is provided, comprising a computer program / instruction, which, when executed by a processor, implements the method in any possible design manner in the first aspect.

[0019] Among them, the technical effects brought about by any design method in the second aspect, the third aspect and the fourth aspect can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 A schematic diagram showing changes in a user interface during the application startup process is shown;

[0021] Figure 2 A schematic diagram showing changes in a user interface during the application startup process is shown;

[0022] Figure 3 A schematic diagram showing changes in a user interface during the application startup process is shown;

[0023] Figure 4 A schematic diagram of a jamming time is shown;

[0024] Figure 5 shows a schematic structural diagram of a mobile phone 100;

[0025] Figure 6 A schematic diagram of a memory management method is shown;

[0026] Figure 7 A schematic diagram of the interface of a social application A showing a freeze is shown;

[0027] Figure 8 It is a software structure block diagram corresponding to the Linux system of the mobile phone 100 provided in the embodiment of the present application. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The following terms "first", "second", etc. are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features.

[0029] In the embodiments of the present application, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0030] In the embodiments of the present application, "and / or" is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0031] In the description of the present application, it can be understood that, unless otherwise clearly specified and limited, the terms "set", "connected" and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection. For ordinary technicians in this field, the specific meanings of the above terms in the present application can be understood according to specific circumstances.

[0032] In order to better illustrate the technical solution of the present application, the following is a brief overview of the terms involved in the present application.

[0033] (1) Memory: Memory is an important component of electronic devices. It is also called internal memory and main memory. It is used to temporarily store the calculation data in the central processing unit (CPU) and the data exchanged with external memory such as hard disk. It is a bridge for communication between external memory and CPU. All programs in electronic devices are run in memory. The strength of memory performance affects the overall performance of electronic devices. As long as the electronic device starts running, the operating system will transfer the data to be calculated from the memory to the CPU for calculation. When the calculation is completed, the CPU will transmit the result.

[0034] (2) Shared memory: Shared memory is a special memory architecture that allows different processes to share data, greatly improving resource utilization. It is a more efficient multi-process communication method.

[0035] Shared memory is a memory structure in which the memory is divided into independent small blocks that can be shared by different applications. Any process can easily read and rewrite the data in it, but different processes can only read but not modify their data, thus preventing conflicts between different applications.

[0036] The most important advantage of shared memory is that it saves system resources and avoids copying large amounts of data between processes, which can effectively reduce process status and improve computer performance and logical processing capabilities. At the same time, shared memory can effectively reduce program latency and effectively improve program execution efficiency.

[0037] In addition, shared memory can also avoid the communication lock overhead between processes, which can effectively improve data consistency and make the program more secure and reliable. In addition, shared memory can also provide pipeline buffering in a multi-process environment, making communication between processes more stable and reliable.

[0038] In short, shared memory is an extremely efficient memory structure that can greatly improve the performance of multi-process applications and is very useful in most multi-process environments.

[0039] (3) Operating System (OS): OS is a set of interrelated system software programs that manage and control the operation of electronic devices, use and run hardware and software resources, and provide public services to organize user interactions. According to the operating environment, operating systems can be divided into desktop operating systems, mobile operating systems, server operating systems, embedded operating systems, etc. Embedded operating systems include Linux systems, Android systems, etc.

[0040] (4) File system: The part of the operating system that processes files is called the file system. The file system is the method and data structure used by the operating system to identify files on storage devices (commonly disks, but also solid-state drives based on NAND Flash) or partitions; that is, the method of organizing files on storage devices. The software organization responsible for managing and storing file information in the operating system is called the file management system, or file system for short. Among them, the Sysfs file system is a virtual file system provided by Linux 2.6. This file system can not only output device and driver information from the kernel to the user space, but can also be used to set up devices and drivers. Simply put, Sysfs is a memory-based file system that provides kernel information in the form of files for user programs to use.

[0041] (5) Asynchronous thread: An asynchronous thread means that when one thread executes, the next thread does not have to wait for it to finish executing before it can start executing.

[0042] As described in the background technology above, under normal circumstances, the amount of data in the file system is large, the probability of statistical information in the file system being read is high, and the probability of read-write lock conflicts is high. Read-write lock conflicts will delay the execution of business, thereby causing business execution to become stuck and affecting user experience.

[0043] The following is a specific scenario where the aforementioned jamming phenomenon occurs. Shared memory is a special memory architecture that allows different processes to share data, greatly improving resource utilization, and is a relatively efficient multi-process communication method. At present, when a business using shared memory is executed by an electronic device, it is necessary to apply for the shared memory corresponding to the business execution. After the electronic device applies for the shared memory corresponding to the business execution, it will mount the statistical information such as the size of the applied memory on the file system in the shared memory and expose it to other businesses, so that other businesses can read and use it, and then execute the aforementioned business.

[0044] If, during the aforementioned process, the maintenance test application needs to obtain statistical information such as the shared memory size required by each business process in the electronic device, the electronic device will read the statistical information such as the memory size required by each business process in the file system until the statistical information such as the memory size required by each business process is read. The electronic device will then mount the statistical information such as the memory size required to execute the business in the file system before executing the aforementioned business; or, if during the aforementioned process, there is a need to modify the statistical information in the file system, the electronic device will modify the corresponding statistical information in the file system until the modification is successful. The electronic device will then mount the statistical information such as the memory size required to execute the business in the file system before executing the aforementioned business.

[0045] Generally, the amount of data in the file system is large, and it takes a certain amount of time for the electronic device to read the memory size required for each business process in the file system, or it takes a certain amount of time to write to modify the corresponding statistical information. There is a delay in the electronic device mounting the statistical information such as the memory size required to execute the business (also known as the information for applying for shared memory) on the file system, which in turn causes a delay in the electronic device's processing of the aforementioned business. The aforementioned business is executed slowly, causing the electronic device to have a jamming phenomenon in the process of executing the business. For example, a read-write lock conflict can cause a jamming in the dynamic effect drawing when the application is started. In addition, the user perceives that there is a jamming phenomenon in the process of the electronic device executing the business, which also affects the user experience to a certain extent.

[0046] Figure 1 FIG. 1 shows a schematic diagram of a user interface change during an application startup process. Figure 1 As shown in FIG. 1 (a), social software A is set in the mobile phone 100. In response to the user clicking on the social software A, the mobile phone 100 creates a startup process of the social software A.

[0047] The startup animation of social software A is drawn as a service using shared memory. When the mobile phone 100 starts social software A, it needs to apply for the corresponding shared memory for application startup. After the mobile phone 100 applies for the corresponding shared memory for application startup, it will generate statistical information such as the size of the memory applied for, and mount the statistical information such as the size of the memory applied for in the file system in the shared memory, exposing it to other services, so that other services can read and use it, and then start the application.

[0048] If, during the aforementioned process, the maintenance test application needs to obtain statistical information such as the shared memory size required by each business process in mobile phone 100, then mobile phone 100 will read the statistical information such as the memory size required by each business process in the file system, and after reading the statistical information such as the memory size required by each business process, mobile phone 100 will mount the statistical information such as the memory size required to start the business in the file system before starting the application; or, if during the aforementioned process, there is a need to modify the statistical information in the file system, then mobile phone 100 will modify the corresponding statistical information in the file system, and after the modification is successful, mobile phone 100 will mount the statistical information such as the memory size required to start the business in the file system before starting the application.

[0049] Generally, the amount of data in the file system is large. It takes a certain amount of time for the mobile phone 100 to read the memory size required for each business process in the file system, or it takes a certain amount of time to write to modify the corresponding statistical information. There is a delay in the mobile phone 100 mounting the statistical information such as the memory size required to start the application on the file system, which causes the mobile phone 100 to start the application slowly, resulting in a jam in the process of the mobile phone 100 starting the application. For example, Figure 1 As shown in Figures (b) and (c) of FIG, after the user clicks on social software A, the mobile phone 100 will freeze for a while before displaying the social software A startup animation and then displaying the message page due to the aforementioned reasons. Figure 2 FIG. 1 shows a schematic diagram of a user interface change during an application startup process. Figure 2 As shown in Figures (d) and (e) of FIG, after the user clicks on social software A, the mobile phone 100 will freeze for a period of time due to the aforementioned reasons, and display a prompt message that the social software A is temporarily unresponsive. In addition, the user perceives that there is a freeze in the process of starting the application on the mobile phone 100, which also affects the user experience to a certain extent.

[0050] In order to solve the technical problems in the background technology, an embodiment of the present application provides a memory management method, and the solution is: a shared memory is set in the electronic device, and the shared memory corresponds to a preset file system, and the preset file system can manage the usage of the shared memory.

[0051] Memory application stage: When the electronic device responds to the user's first operation on the application, it will apply for the shared memory corresponding to the execution of the business, generate information on the application for shared memory, and the information on the application for shared memory is used to indicate the application and usage of the shared memory corresponding to the execution of the business, and then execute the business. In order to facilitate the subsequent mounting of the information on the application for shared memory by the preset file system, and to avoid other businesses reading the information of the preset file system and delaying the execution of the business, the electronic device will first store the information on the application for shared memory in a temporary list in the first thread, and when the electronic device responds to the read request of the preset file system, the information on the application for shared memory in the temporary list will be created in the preset file system in the second thread, and the information on the application for shared memory in the temporary list will be deleted. It can be understood that the first thread and the second thread are asynchronous threads.

[0052] In this solution, the two tasks of writing the business execution and the information of applying for shared memory into the preset file system are executed asynchronously by two threads, and the business execution and the information of applying for shared memory into the preset file system do not interfere with each other. Even if the amount of data in the file system is large, it takes a certain reading time for the electronic device to read the memory size required for each business process in the file system, or it takes a certain writing time to modify the corresponding statistical information, but the process of the electronic device executing the business is not delayed, and the jamming phenomenon in the process of executing the business caused by the read-write lock is avoided to a certain extent. Compared with the existing technology, the speed of business execution is improved to a certain extent, thereby improving the user experience.

[0053] In order to solve the technical problems in the startup of the aforementioned social application, the mobile phone 100 will apply for the shared memory corresponding to the startup application in response to the user's click operation on the social application. Then, the service startup operation is directly performed. For example, Figure 3 FIG. 1 shows a schematic diagram of a user interface change during an application startup process. Figure 3 As shown in Figures (f), (g) and (h), in response to the user clicking on social software A, the mobile phone 100 will quickly display the social software A startup animation, and then display the message page. In order to facilitate the subsequent mounting of the preset file system to apply for shared memory information, and to avoid other services reading the preset file system information to delay the start of the application process, the mobile phone 100 will first store the shared memory application information in a temporary list in the first thread, and when the mobile phone 100 responds to the read request of the preset file system, the shared memory application information in the temporary list will be created in the preset file system in the second thread, and the shared memory application information in the temporary list will be deleted.

[0054] It is understandable that after the aforementioned services are executed, if the information for applying for shared memory cannot be deleted from the preset file system in time, even if the electronic device responds to the request for executing other services in the application, it will not execute other services in the application. This will delay the execution speed of other services in the application. For example, Figure 4 A schematic diagram of the jamming time is shown. Figure 4 As shown in the figure, during the exit process of a social application, the entire memory release (freeBuffer) release time reached 129.7ms, which was noticeable to the human eye as a lag in the animation. Moreover, after analysis, it was found that the long memory release time was caused by the failure to delete the shared memory application information from the preset file system in time, which delayed the execution of other business in the application.

[0055] The following is the stack information corresponding to the freezing of the mobile phone 100 during the process of releasing memory, which is only exemplary and not limited to this.

[0056] rwsem_down_write_slowpath+0x4f4 / 0xf90

[0057] down_write+0x7c / 0x12c

[0058] _kernfs_remove+0x418 / 0x6f8

[0059] kernfs_remove_by_name_ns+0x58 / 0xa0

[0060] Sysfs_remove_group+0xcc / 0x1e0

[0061] _kobject_del+0x3c / 0x15c

[0062] dma_buf_release+0x48 / 0x100

[0063] In order not to delay the execution of other services in the application (for example, after the social application A is started, the message sent to the address book friends is displayed in the dialogue interface), in the memory release stage, the execution of other services and the information of applying for shared memory are deleted from the preset file system. These two tasks are executed asynchronously, and the business execution and the information of applying for shared memory are written into the preset file system without interfering with each other. In this way, after the electronic device completes the execution of the service, the shared memory corresponding to the execution of the service is released, and other task execution requests in the application can be executed when they arrive, instead of waiting until the information of applying for shared memory is deleted before executing other tasks in the application, which improves the execution speed of other tasks in the application and improves the user experience. Specifically, after the electronic device completes the execution of the service, if there is information of applying for shared memory in the temporary list, it indicates that there is no read request of the preset file system, and the service has been completed, the electronic device can release the shared memory corresponding to the service, and does not occupy the shared memory, then the electronic device can delete the information of applying for shared memory in the temporary list. If there is no information of applying for shared memory in the temporary list, the information deletion task of applying for shared memory is stored in the third process, and the task of memory release is used to trigger the electronic device to delete the information of applying for shared memory in the temporary list, wherein the first thread, the second thread and the third thread are asynchronous threads.

[0064] The application provided in the embodiments of the present application may be various applications applicable to the memory management method, such as games, social networking, shopping, travel, education, music, etc., but not limited thereto.

[0065] The electronic device provided in the embodiments of the present application may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The electronic device may be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with a wireless transceiver function, a virtual reality (VR) electronic device, an augmented reality (AR) electronic device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, etc.

[0066] Among them, wearable devices can also be called wearable smart devices, which are a general term for the intelligent design and development of wearable devices for daily wear using wearable technology, such as glasses, gloves, watches, clothing and shoes. Wearable devices are portable devices that are worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also realize powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and independent of smartphones to achieve complete or partial functions, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.

[0067] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection. The embodiments of the present application do not limit the specific technology and specific device form used by the electronic device.

[0068] In an embodiment of the present application, the electronic device may include a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system may be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.

[0069] The embodiment of the present application is described by taking a mobile phone as an example of the electronic device. Figure 5 1 shows a schematic diagram of the structure of the mobile phone 100, such as Figure 5 As shown, the mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0070] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0071] The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. In an embodiment of the present application, in the memory application stage, the processor 110 responds to the user's first operation on the application, and after applying for the shared memory corresponding to the execution business, generates information on the application for shared memory, and the information on the application for shared memory is used to indicate the application and usage of the shared memory corresponding to the execution business, and then directly executes the business. In order to facilitate the subsequent mounting of the preset file system and to prevent other services from reading the information of the preset file system and delaying the execution of the service, the processor 110 will first store the information of the shared memory application in a temporary list in the first thread, and when the processor 110 responds to the read request of the preset file system, the information of the shared memory application in the temporary list will be created in the preset file system in the second thread, and the information of the shared memory application in the temporary list will be deleted. It can be understood that the first thread and the second thread are asynchronous threads.

[0072] In this solution, the two tasks of writing the business execution and the information of applying for shared memory into the preset file system are executed asynchronously by two threads, and the business execution and the information of applying for shared memory are written into the preset file system without interfering with each other. Even if the amount of data in the file system is large, the processor 110 takes a certain reading time to read the memory size required by each business process in the file system, or it takes a certain writing time to modify the corresponding statistical information, but the process of the processor 110 executing the business is not delayed, and the jamming phenomenon in the process of executing the business caused by the read-write lock is avoided to a certain extent. Compared with the prior art, the speed of business execution is improved to a certain extent, thereby improving the user experience.

[0073] In order not to delay the execution process of other services in the application program, in the memory release phase, the information of other service execution and shared memory application is deleted from the preset file system, and the two tasks are executed asynchronously by threads, and the service execution and shared memory application information are written into the preset file system without interfering with each other. In this way, after the processor 110 executes the service, the shared memory corresponding to the service is released, and other task execution requests in the application program can be executed when they arrive, instead of waiting until the information of shared memory application is deleted before executing other tasks in the application program, which improves the execution speed of other tasks in the application program and improves the user experience. Specifically, after the processor 110 executes the service, if there is information of shared memory application in the temporary list, it indicates that there is no read request of the preset file system, and the service has been executed, the processor 110 can release the shared memory corresponding to the service, and does not occupy the shared memory, then the processor 110 can delete the information of shared memory application in the temporary list. If there is no information of shared memory application in the temporary list, the information deletion task of shared memory application is stored in the second thread, and the task of memory release is used to trigger the processor 110 to delete the information of shared memory application in the temporary list.

[0074] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0075] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0076] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuits 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.

[0077] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is a schematic illustration and does not constitute a structural limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0078] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the mobile phone 100. While the charging management module 140 is charging the battery 142, it may also power the mobile phone through the power management module 141.

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

[0080] The wireless communication function of the mobile phone 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0081] The mobile phone 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0082] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the mobile phone 100 may include 1 or N display screens 194, where N is a positive integer greater than 1. In the embodiment of the present application, the display screen 194 can be used to display a message prompting the user to execute the pending business corresponding to the preset geographic fence.

[0083] The mobile phone 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0084] The mobile phone 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor.

[0085] The SIM card interface 195 is used to connect the SIM card. The SIM card can be connected to and separated from the mobile phone 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The mobile phone 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of 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 mobile phone 100 interacts with the network through the SIM card to realize functions such as calls and data communications. In some embodiments, the mobile phone 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the mobile phone 100 and cannot be separated from the mobile phone 100.

[0086] The memory management method provided in the embodiment of the present application will be described in detail below by taking the electronic device as a mobile phone, the application as a social application, the first thread as thread 1, the second thread as thread 2, the third thread as thread 3, and the scenario of starting the social application as an example.

[0087] Figure 6 FIG. 1 shows a flow chart of a memory management method. Figure 6 As shown, the process includes the following steps:

[0088] Step 601: In response to the user's first operation on social application A, mobile phone 100 applies for execution of social application A in thread 1 to start the corresponding shared memory, and then generates information for applying for shared memory. The first operation is used to trigger mobile phone 100 to start social application A.

[0089] In response to the user's first operation on the social application A, the mobile phone 100 needs to create a thread to apply for memory in order to start the social application A, so as to apply for computing space for storing computing data for starting the social application A. It can be understood that the technical problem raised in the background technology of this application is aimed at an application using shared memory, and therefore, the object targeted by this application to solve the aforementioned technical problem is also an application using shared memory.

[0090] The information of applying for shared memory is used to indicate the application and usage of the shared memory corresponding to the start of social application A. In order to expose the usage of shared memory to other businesses and facilitate other businesses to read and use it, in this application, after applying for the execution of the corresponding shared memory started by social application A in thread 1, the information of applying for shared memory for sharing will also be generated.

[0091] The first operation may be a gesture operation, voice operation, touch operation, etc. of the mobile phone 100 on the social application A. For example, Figure 6As shown, the first operation may be an operation in which the user clicks on social software A.

[0092] Step 602: The mobile phone 100 stores the information of applying for shared memory in a temporary list in thread 1.

[0093] In order to facilitate the subsequent mounting of the file system to apply for shared memory information and to prevent other services from reading the file system information and delaying the execution of services, the mobile phone 100 will first store the shared memory application information in a temporary list in the first thread.

[0094] When the mobile phone 100 executes the service using the shared memory, it needs to apply for the shared memory corresponding to the service execution. After the mobile phone 100 applies for the shared memory corresponding to the service execution, it will mount the information such as the memory size applied for in the shared memory to expose it to other services so that other services can read and use it. Therefore, the mobile phone 100 needs to record the information of the shared memory application so as to expose it to other services so that other services can read and use it.

[0095] The information for applying for shared memory includes the name of the shared memory application event in the preset file system and the size of the shared memory application. In some embodiments, the shared memory may be a dma-buf shared memory, and the file system may be a Sysfs file system. The information for applying for shared memory may include the Sysfs file name of the shared memory application event in the Sysfs file system and the size of the shared memory application.

[0096] dma-buf stats can show the information of shared memory application, mainly providing two information: name and size.

[0097] The mobile phone 100 can use a preset function (node ​​ / sys / kernel / dmabuf / buffers / <inode_number> ) to access and obtain the aforementioned shared memory application information.

[0098] Step 603: the mobile phone 100 starts the social application A in thread 1.

[0099] In order to facilitate the subsequent mounting of the file system to apply for shared memory information and to prevent other services from reading the file system information and delaying the process of starting the social application A, the mobile phone 100 will apply to start the shared memory corresponding to the social application A in response to the user's first operation on the application, and then the mobile phone 100 will store the information of applying for shared memory in a temporary list in thread 1 and start the social application A. It can be understood that the speed of the mobile phone 100 executing step 602 is relatively fast, and the mobile phone 100 will not delay the start of the social application A to a certain extent.

[0100] Although Figure 6It is shown that step 603 is performed after step 602, but it is understandable that in order not to delay the mobile phone 100 from starting the social application A, step 603 and step 602 can be performed in parallel, or step 603 can be performed after step 602.

[0101] The mobile phone 100 launches the social application A, including displaying the social application A launch animation.

[0102] Step 604: in response to the operation of other social application A reading the information of applying for shared memory corresponding to the start of social application A, the mobile phone 100 traverses the temporary list in thread 2.

[0103] In response to other social application A reading the corresponding shared memory application information started by social application A in thread 2, mobile phone 100 traverses the temporary list to mount (create) the shared memory application information not mounted in the file system in the file system. See step 605 for details.

[0104] Step 605: the mobile phone 100 deletes the information of applying for shared memory corresponding to the start of the social application A in the temporary list in thread 2, and creates the information of applying for shared memory in the temporary list in a preset file system.

[0105] 606 : When the social application A starts the animation effect, the mobile phone 100 determines in thread 1 whether the information of applying for shared memory corresponding to the start of the social application A is in the temporary list.

[0106] After the mobile phone 100 starts the application, if the information requesting shared memory cannot be deleted from the preset file system in time, even if the mobile phone 100 responds to the request for executing other services in the social application, other services in the application will not be executed. This will delay the execution speed of other services in the application. For example, Figure 7 A schematic diagram of a social application A interface showing a freeze. Figure 7 As shown in (i) and (j) of FIG. 1 , the user wants to click on a dialog box opening control of a certain person in the mobile phone 100 to open a dialog box of the certain person. Due to the aforementioned reasons, Figure 7 As shown in Figure (i), the mobile phone 100 cannot respond to the user's aforementioned operation and displays a prompt message that the application is stuck, such as the application is unresponsive and whether to close it.

[0107] In order not to delay the execution of other services in social application A, in the memory release phase, the information of other service execution and shared memory application in social application A is deleted from the preset file system. The two tasks are executed asynchronously by threads, and the service execution and shared memory application information are written into the preset file system without interfering with each other. In this way, after the mobile phone 100 starts the social application A, the shared memory corresponding to the social application A is started and released, and other task execution requests in the social application A can be executed when they arrive, instead of waiting until the information of shared memory application is deleted before executing other tasks in the application, which improves the execution speed of other tasks in the application and improves the user experience. Specifically, after the mobile phone 100 executes the service, if there is information of shared memory application in the temporary list, it indicates that there is no read request of the preset file system, and the service has been executed. The mobile phone 100 can release the shared memory corresponding to the service and does not occupy the shared memory. Then the mobile phone 100 can delete the information of shared memory application in the temporary list, that is, execute step 607. If the information for applying for shared memory does not exist in the temporary list, a task for deleting the information for applying for shared memory is stored in thread 3. The task for releasing memory is used to trigger the mobile phone 100 to delete the information for applying for shared memory in the temporary list, that is, to execute step 608.

[0108] Step 607: the mobile phone 100 deletes the information on applying for shared memory in the temporary list in thread 1.

[0109] Step 608: the mobile phone 100 stores a memory release task in thread 3, where the memory release task is used to trigger the mobile phone 100 to delete the information on applying for shared memory in the preset file system.

[0110] Step 609: the mobile phone 100 deletes the information of applying for shared memory existing in the preset file system in thread 3.

[0111] The memory management method provided in the embodiment of the present application can be applied to various electronic devices with operating systems that share memory. For example, the memory management method provided in the embodiment of the present application can be applied to electronic devices that use an operating system that uses the Linux kernel.

[0112] Figure 8 1 is a software structure diagram corresponding to the Linux system of the mobile phone 100 provided in the embodiment of the present application. Figure 8As shown: the software system of the mobile phone 100 can adopt a layered architecture, which divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Linux system is divided into four layers, from top to bottom, namely, the application layer, the shell and the file system, and the kernel. It can be understood that the kernel, shell, file system and application layer are the four main components of the Linux system, but are not limited to this.

[0113] 1. Kernel

[0114] The kernel is the core of the operating system and has many basic functions. It is responsible for managing the system's processes, memory, device drivers, files, and network systems, and determines the system's performance and stability. The kernel consists of the following parts: memory management, process management, device drivers, file systems, and network management.

[0115] In an embodiment of the present application, the kernel generates information for applying for shared memory in response to a request sent by the application layer for executing shared memory corresponding to the first business, stores the information for applying for shared memory in a temporary list in thread 1, and executes the first business in thread 1.

[0116] After responding to the read request for the preset file system in the application layer, the kernel deletes the information of applying for shared memory in the temporary list, and creates the information of applying for shared memory in the temporary list in the preset file system in thread 2.

[0117] Moreover, if there is information on applying for shared memory in the temporary list, the kernel deletes the information on applying for shared memory in the temporary list; if there is no information on applying for shared memory in the temporary list, the kernel stores a memory release task in thread 3, and the memory release task is used to trigger the kernel to delete the information on applying for shared memory in the preset file system, and then the kernel deletes the information on applying for shared memory in the preset file system in thread 3.

[0118] In some embodiments, the information for applying for shared memory includes the name of the shared memory application event in a preset file system and the size of the shared memory application. In some embodiments, the shared memory may be a dma-buf shared memory, and the file system may be a Sysfs file system. The information for applying for shared memory may include the Sysfs file name of the shared memory application event in the Sysfs file system and the size of the shared memory application.

[0119] In this solution, after the kernel responds to the read request for the preset file system in the application layer, the kernel creates the information for applying for shared memory in the temporary list in the preset file system in thread 2. This can reduce the number of times the information for applying for shared memory is created and deleted, thus saving the memory occupied by the information for applying for shared memory and reducing the read-write lock time.

[0120] 1.1 Memory Management

[0121] Memory management is responsible for managing the memory resources in the mobile phone 100. Memory management is responsible for managing the allocation, use and release of memory in the mobile phone 100. The main functions of memory management include memory partitioning, memory mapping, memory protection and virtual memory. Among them, virtual memory is a technology that interleaves the use of physical memory and disk. In virtual memory, all memory used by applications and operating systems is mapped to the virtual address space. When the physical memory space is insufficient, the operating system will move a part of the temporarily unused memory to the disk, freeing up physical memory space for other applications or operating systems to use. When it is necessary to access a memory page that has been moved out of the physical memory, the operating system will read it from the disk for use by the application or operating system. In this application, memory management is used to apply for shared memory corresponding to the execution of the business in response to the user's first operation on the application.

[0122] 1.2. Process Management

[0123] Process management is to allocate the execution of instructions based on time.

[0124] 1.3 Device Drivers

[0125] Device drivers are an integral part of the Linux kernel. Like other parts of the operating system, device drivers run in a high-privilege processor environment, allowing them to directly operate the hardware. However, because of this, any error in a device driver may cause the operating system to crash. Device drivers actually control the interaction between the operating system and the hardware devices.

[0126] The device driver provides a set of abstract interfaces that the operating system can understand to complete the interaction with the operating system, while the specific operation details related to the hardware are completed by the device driver. Generally speaking, the device driver is related to the control chip of the device. For example, if the hard disk of the mobile phone 100 is a SCSI hard disk, you need to use a SCSI driver instead of an IDE driver.

[0127] 1.4 Network Interface (NET)

[0128] It provides access to various network standards and supports various network hardware. The network interface can be divided into network protocols and network drivers. The network protocol part is responsible for implementing each possible network transmission protocol. The network protocol can be TCP / IP protocol. Linux network implementation supports all TCP / IP protocols. The network part of the Linux kernel consists of the network protocol layer and network device drivers. The network device driver is responsible for communicating with the hardware device, and each possible hardware device has a corresponding device driver.

[0129] 2. Shell

[0130] The shell is the user interface of the system, providing an interface for users to interact with the kernel. It receives commands input by the user and sends them to the kernel for execution. It is a command interpreter. In the embodiment of the present application, the shell can be used to receive the first operation of the user on the application in the application layer, and send the shared memory instruction corresponding to the application execution business to the kernel.

[0131] 3. File System

[0132] The file system refers to a system software for organizing and managing files and directories in the storage device of the mobile phone 100. It provides a convenient way for users and applications to access and operate data in the storage device. The basic functions of the file system include storage management, file operations, directory management, protection control and data recovery.

[0133] In a general file system, storage devices are divided into several blocks or sectors, and each block and sector has a unique address to identify its location on the storage device. The file system records the location and attributes of files and targets in the storage device through data structures (such as file tables, directory tables, etc.). When a user or application sends a read or write request to the file system, the file system reads or saves the data from the storage device based on the relevant information of the file or directory.

[0134] 4. Application Layer

[0135] The application layer includes various applications. In the embodiment of the present application, the application in the application layer, in response to a first operation of the user on the application, applies to the kernel for a request to execute a shared memory corresponding to a first service.

[0136] dma-buf is a mechanism in the kernel that allows different devices and subsystems to share memory. It can abstract a piece of memory into a globally visible file descriptor and expose it to the application layer.

[0137] To the kernel, all open files are referenced by file descriptors. A file descriptor is a non-negative integer. When an existing file is opened or a new file is created, the kernel returns a file descriptor to the process. When reading or writing a file, the file descriptor returned by open or create is used to represent the file and is passed as a parameter to the read or write function.

[0138] The dma-buf stats in the kernel can indicate the information of applying for shared memory, mainly providing two pieces of information: name and size. Under the memory sharing mechanism, the application layer can use the preset function (node ​​ / sys / kernel / dmabuf / buffers / <inode_number> ) to access and obtain the aforementioned shared memory application information in the kernel.

[0139] It is understandable that the Android system is an operating system based on the Linux kernel and oriented to electronic devices. The memory management method provided in the application is also applicable to the Android system.

[0140] The embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned mobile terminal, the mobile terminal executes each function or step executed by the mobile phone 100 in the above-mentioned method embodiment.

[0141] The present application also provides a computer program product, which, when executed on a computer, enables the computer to execute the functions or steps executed by the mobile phone 100 in the above method embodiment. The computer may be the above mobile terminal (such as the mobile phone 100).

[0142] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0143] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0144] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0145] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable storage media. Therefore, a machine-readable storage medium may include any mechanism for storing or disseminating information in a machine (e.g., computer) readable form, including but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROM), random access memories (RAM), erasable programmable read-only memories (EPROM), electrically erasable programmable read-only memories (EEPROM), magnetic cards or optical cards, flash memory, or a tangible machine-readable memory for disseminating information (e.g., carrier waves, infrared signal digital signals, etc.) based on the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable storage media include any type of machine-readable storage media suitable for storing or propagating electronic instructions or information in a form readable by a machine (eg, a computer).

[0146] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0147] It can be understood that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0148] It is understood that in the examples and descriptions of this patent, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises", or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article, or device. In the absence of further restrictions, an element defined by the statement "comprises a" does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.

[0149] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be apparent to those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.

Claims

1. A memory management method, characterized in that: The method is applied to an electronic device, the electronic device includes a shared memory, the shared memory corresponds to a preset file system, and the preset file system is used to manage the use of the shared memory. The method includes: In response to a first operation of a user on an application, generating information for applying for a shared memory, wherein the information for applying for a shared memory is used to indicate an application and usage of a shared memory corresponding to executing a first service, and the first operation is used to trigger the electronic device to execute the first service; The information on applying for shared memory is stored in a temporary list in a first thread, and the first business is executed in the first thread; wherein, after responding to a read request of a preset file system, the information on applying for shared memory in the temporary list is deleted, and the information on applying for shared memory in the temporary list is created in a preset file system in a second thread, and the first thread and the second thread are asynchronous threads.

2. The method according to claim 1, characterized in that After executing the first service in the first thread, the method further includes: If the information of applying for shared memory exists in the temporary list, the information of applying for shared memory in the temporary list is deleted.

3. The method according to claim 1 or 2, characterized in that: After executing the first service in the first thread, the method further includes: If the information on applying for shared memory does not exist in the temporary list, a memory release task is stored in the third thread, and the memory release task is used to trigger the electronic device to delete the information on applying for shared memory in the temporary list, wherein the first thread, the second thread and the third thread are asynchronous threads.

4. The method according to any one of claims 1 to 3, characterized in that A preset operating system is set in the electronic device, and the operating system includes a kernel and an application layer; The generating of information for applying for shared memory in response to a first operation of the application by the user comprises: the application in the application layer, in response to the first operation of the application by the user, applying to the kernel for a request for executing the shared memory corresponding to the first service, and the kernel generating information for applying for shared memory in response to the request for executing the shared memory corresponding to the first service sent by the application layer; The step of storing the information of applying for shared memory in a temporary list in the first thread and executing the first service in the first thread includes: the kernel storing the information of applying for shared memory in a temporary list in the first thread and executing the first service in the first thread; After responding to a read request from a preset file system, the information on the shared memory application in the temporary list is deleted, and the information on the shared memory application in the temporary list is created in the preset file system in a second thread, including: after responding to a read request from the preset file system, the kernel deletes the information on the shared memory application in the temporary list, and creates the information on the shared memory application in the temporary list in the preset file system in the second thread.

5. The method according to claim 3, characterized in that: A preset operating system is set in the electronic device, and the operating system includes a kernel and an application layer; If the information of applying for shared memory exists in the temporary list, deleting the information of applying for shared memory in the temporary list; If the information of applying for shared memory does not exist in the temporary list, a task of releasing memory is stored in the third thread, and the task of releasing memory is used to trigger the electronic device to delete the information of applying for shared memory in the temporary list, including: If the information of applying for shared memory exists in the temporary list, the kernel deletes the information of applying for shared memory existing in the temporary list; If the information on the shared memory application does not exist in the temporary list, the kernel stores a memory release task in a third thread, and the memory release task is used to trigger the kernel to delete the information on the shared memory application in the temporary list.

6. The method according to any one of claims 1 to 5, characterized in that The information on applying for shared memory includes the name of the shared memory application event in the preset file system and the size of the shared memory application.

7. The method according to claim 6, characterized in that The shared memory is a dma-buf shared memory, the preset file system is a Sysfs file system, and the information for applying for shared memory includes a Sysfs file name of an event for applying for shared memory in the Sysfs file system.

8. The method according to any one of claims 1 to 7, characterized in that The first service includes starting the application or exiting the application, and the executing the first service includes displaying an animation of starting the application or displaying an animation of exiting the application.

9. An electronic device, characterized in that: It comprises a processor and a memory; the memory is used to store code instructions; the processor is used to run the code instructions, so that the electronic device executes the method as described in any one of claims 1-8.

10. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 8.