A dynamic APP management method and device, terminal equipment and storage medium
Patent Information
- Application Number
- CN202511326512.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2045-09-17
AI Technical Summary
[0005]本申请提供了一种动态APP管理方法、装置、终端设备及存储介质,能够解决现有技术中无法在有限的硬件资源下,满足实时加载多种动态APP程序需求的问题
[0017] Compared to existing technologies, the above embodiments have the following advantages: By reading the entry address of the dynamic APP from flash memory and directly jumping to execution, the APP is initialized and run in flash memory, rather than copying the entire program to RAM. This significantly reduces the dependence on RAM resources, allowing limited RAM resources to be used to preserve runtime data that is more easily lost. Furthermore, the APP can create corresponding tasks during initialization and push them to the operating system scheduler for unified management via the task scheduler interface. This eliminates the need for the operating system to create threads for each dynamic APP program, avoiding excessive modifications to the operating system. It also shortens the loading and startup time of dynamic APP programs and improves task scheduling efficiency and operational stability.
Smart Images

Figure CN121187667B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of operating system and application management technology, and in particular to a dynamic APP management method, device, terminal equipment and storage medium. Background Technology
[0002] The DeeHung OS is an operating system developed based on the open-source HarmonyOS. It can be applied to the module components of smart meters to manage different dynamic APP programs in the module components.
[0003] However, smart meters are used in a wide variety of scenarios, so the modules within smart meters need to load and run multiple different apps. Since the standard consumer-side operating system lacks the capability for real-time dynamic app loading and execution, smart meter modules using this system must pre-install all functional apps within the microcontroller. However, the hardware resources of smart meter modules are limited, making it difficult to effectively meet the real-time loading and execution requirements of multiple dynamic apps.
[0004] Therefore, how to meet the demand for real-time loading of multiple dynamic APP programs under limited hardware resources is a technical problem that needs to be solved. Summary of the Invention
[0005] This application provides a dynamic APP management method, apparatus, terminal device, and storage medium, which can solve the problem in the prior art that it is impossible to meet the requirements of real-time loading of multiple dynamic APP programs under limited hardware resources.
[0006] This application provides a dynamic APP management method in some embodiments, applied to any module component of a smart meter, each module component including at least: flash memory and RAM; the dynamic APP management method includes:
[0007] Receive the first dynamic APP program, save the first dynamic APP program to the flash memory, and determine the first storage space required to store the running data corresponding to the first dynamic APP program;
[0008] When there is no first contiguous free storage space in the RAM that is greater than or equal to the first storage space, multiple second contiguous free storage spaces are selected from all contiguous free storage spaces in the RAM; wherein the sum of all second contiguous free storage spaces is greater than or equal to the first storage space.
[0009] Based on the plurality of second contiguous free storage spaces, determine a number of second dynamic APP programs that need to be paused from the dynamic APP programs that are currently running in the flash memory;
[0010] Pause each of the second dynamic APP programs, move the running data of each of the second dynamic APP programs stored in the RAM, and merge the multiple second consecutive free storage spaces to obtain a third consecutive free storage space;
[0011] The first dynamic APP and each of the second dynamic APPs are launched in the flash memory, and the running data of the first dynamic APP program is stored in the third continuous free storage space.
[0012] Compared with the prior art, the above embodiments have the following beneficial effects: By storing the first dynamic APP program in flash memory and starting the first dynamic APP program in flash memory, it is not necessary to copy the first dynamic APP program to RAM when running the first dynamic APP program. Only the running data generated by the first dynamic APP program is stored in RAM, thereby saving RAM resources. Furthermore, since the dynamic APP program in the smart meter module component needs to keep running in real time, when managing the storage space of the running data corresponding to the dynamic APP program in RAM, firstly, multiple second consecutive free storage spaces are selected from all consecutive free storage spaces. Based on the multiple second consecutive free storage spaces, several second dynamic APP programs that need to be paused are determined from the started dynamic APP programs. Further, by pausing the second dynamic APP programs, the running data of each second dynamic APP program stored in RAM is retained. Finally, by transferring the running data of each second dynamic APP program stored in RAM, the multiple second consecutive free storage spaces are merged to obtain a third consecutive free storage space, thereby avoiding the loss of real-time running data stored in RAM under the condition of limited RAM resources.
[0013] Furthermore, any module component of the smart meter is equipped with a preset operating system with a task scheduler; the code of each dynamic APP program includes first code for creating the task corresponding to the dynamic APP program and second code for calling the interface of the task scheduler; each dynamic APP program is obtained by compiling the code of the dynamic APP program into an address-independent program.
[0014] Compared to existing technologies, the above embodiments have the following advantages: By including first code for creating tasks and second code for calling the task scheduler interface in the code of each dynamic APP program, the operating system does not need to create threads for each dynamic APP program. When a dynamic APP program starts, it automatically creates tasks, and the operating system manages the tasks created by each dynamic APP program based on its own scheduling functions, avoiding significant modifications to the operating system. Furthermore, by compiling the code of the dynamic APP program into address-independent code, the flexibility of subsequent storage and transfer of the corresponding running data of each dynamic APP program can be improved, thereby increasing the efficiency of dynamic APP management.
[0015] Further, launching the first dynamic APP in the flash memory includes:
[0016] The entry address of the first dynamic APP program is read from the flash memory, and the user jumps to the entry address. The first dynamic APP program is initialized in the flash memory. After the task is created by the first dynamic APP program, the task is pushed to the task scheduler of the preset operating system through the interface.
[0017] Compared to existing technologies, the above embodiments have the following advantages: By reading the entry address of the dynamic APP from flash memory and directly jumping to execution, the APP is initialized and run in flash memory, rather than copying the entire program to RAM. This significantly reduces the dependence on RAM resources, allowing limited RAM resources to be used to preserve runtime data that is more easily lost. Furthermore, the APP can create corresponding tasks during initialization and push them to the operating system scheduler for unified management via the task scheduler interface. This eliminates the need for the operating system to create threads for each dynamic APP program, avoiding excessive modifications to the operating system. It also shortens the loading and startup time of dynamic APP programs and improves task scheduling efficiency and operational stability.
[0018] Furthermore, the dynamic APP management method also includes:
[0019] The task scheduler includes a monitoring task; when each dynamic APP program in the flash memory starts, it sends a heartbeat signal cyclically according to a preset period.
[0020] The monitoring task receives the heartbeat signal in real time, and for each dynamic APP, if the monitoring task does not receive the heartbeat signal sent by the dynamic APP for more than the preset period, the dynamic APP is restarted.
[0021] Compared to existing technologies, the above embodiments have the following advantages: By periodically receiving heartbeat signals from each dynamic APP program through the monitoring task in the task scheduler, real-time monitoring of the running status of the dynamic APP programs can be achieved. When a dynamic APP program fails to send a heartbeat signal within a preset period, the system will automatically trigger a restart operation to ensure that the dynamic APP program resumes normal operation. This effectively prevents system freezes caused by program abnormalities, infinite loops, or resource blockages, improves the overall reliability and fault tolerance of operation, and ensures that the smart meter remains stable during long-term operation.
[0022] Further, the step of filtering multiple second contiguous free storage spaces from all contiguous free storage spaces within RAM includes:
[0023] From all the contiguous free storage spaces, select all possible sets of contiguous free storage spaces; wherein the sum of all contiguous free storage spaces in each set of contiguous free storage spaces is greater than or equal to the first storage space;
[0024] Determine the first number of dynamic apps that need to be paused when merging all contiguous free storage spaces within each set of contiguous free storage spaces;
[0025] The set of contiguous free storage spaces with the smallest first quantity is selected as the plurality of second contiguous free storage spaces.
[0026] Compared with the prior art, the above embodiments have the following beneficial effects: by filtering out all the continuous free storage space sets that can free up enough first storage space from the continuous free storage space, and selecting the continuous free storage space set that requires pausing the fewest dynamic APP programs, the impact of the pausing operation on the running dynamic APP program is minimized. At the same time, since the number of dynamic APP programs that need to transfer running data is reduced, the amount of data transferred to RAM memory is also significantly reduced, thus improving the management efficiency of dynamic APP programs.
[0027] Furthermore, the dynamic APP management method further includes: when the RAM contains a plurality of first consecutive free storage spaces that are greater than or equal to the first storage space, the first consecutive free storage space with the smallest difference from the first storage space is used as the third consecutive free storage space.
[0028] Compared with the prior art, the above embodiments have the following beneficial effects: when there are multiple consecutive free storage spaces in RAM that meet the conditions, the consecutive free storage space with the smallest difference from the required first storage space is preferentially selected as the storage area for running data. This can avoid the problem of too many discrete consecutive spaces caused by unreasonable space selection, thereby improving the overall utilization rate of RAM resources under limited RAM resources.
[0029] Furthermore, after determining the first storage space required to store the running data corresponding to the first dynamic APP program, the method further includes: reading the file information header and checksum of the first dynamic APP program from the flash memory, and determining the validity of the first dynamic APP program by comparing the file information header and calculating the checksum.
[0030] Compared with the prior art, the above embodiments have the following beneficial effects: by reading the file information header and verification code before loading the dynamic APP program and comparing and verifying them, the validity of the dynamic APP program is ensured, and abnormal operation problems caused by program corruption, incomplete download or tampering are prevented, thereby improving the security and stability of the system from the source.
[0031] Another embodiment of this application provides a dynamic APP management device, applied to a module component of a smart meter, each of the module components including at least: flash memory and RAM; the dynamic APP management device includes: a first dynamic APP program receiving module, a second continuous free storage space filtering module, a second dynamic APP program determining module, a second continuous free storage space merging module, and a first dynamic APP launching module;
[0032] The first dynamic APP program receiving module is used to receive the first dynamic APP program, save the first dynamic APP program to the flash memory, and determine the first storage space required to store the running data corresponding to the first dynamic APP program.
[0033] The second consecutive free storage space filtering module is used to filter multiple second consecutive free storage spaces from all consecutive free storage spaces in the RAM when there is no first consecutive free storage space greater than or equal to the first storage space in the RAM; wherein the sum of all second consecutive free storage spaces is greater than or equal to the first storage space;
[0034] The second dynamic APP program determination module is used to determine, based on the plurality of second consecutive free storage spaces, a number of second dynamic APP programs that need to be paused from the dynamic APP programs that have been started in the current flash memory.
[0035] The second consecutive free storage space merging module is used to pause each of the second dynamic APP programs, move the running data of each of the second dynamic APP programs stored in the RAM, and merge the multiple second consecutive free storage spaces to obtain a third consecutive free storage space.
[0036] The first dynamic APP startup module is used to start the first dynamic APP and each of the second dynamic APPs in the flash memory, and to store the running data of the first dynamic APP program in the third continuous free storage space.
[0037] Another embodiment of this application provides a terminal device, including: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the steps of the dynamic APP management method of this application.
[0038] Another embodiment of this application also provides a computer-readable storage medium item, including: a stored computer program, which, when the computer program is running, controls the device where the computer-readable storage medium is located to perform the steps of the dynamic APP management method of this application. Attached Figure Description
[0039] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0040] Figure 1 This is a flowchart illustrating a dynamic APP management method provided in some embodiments of this application;
[0041] Figure 2 This is a schematic diagram of a RAM resource management process provided in some embodiments of this application;
[0042] Figure 3 This is a schematic diagram of RAM resource occupancy status provided in some embodiments of this application;
[0043] Figure 4 This is a timing diagram for monitoring a heartbeat signal provided in some embodiments of this application;
[0044] Figure 5 This is a schematic diagram of the structure of a dynamic APP management device provided in some embodiments of this application. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0047] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0048] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0049] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0050] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).
[0051] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.
[0052] In existing technologies, smart meters are used in numerous scenarios, thus requiring their modules to load and run multiple different applications. Since standard consumer-side operating systems lack real-time dynamic application loading and execution capabilities, smart meter modules using these systems must pre-install all functional applications within the microcontroller. However, the hardware resources of smart meter modules are limited, making it difficult to effectively meet the real-time loading and execution requirements of various dynamic applications.
[0053] Please refer to Figure 1 To address the problem in existing technologies that cannot meet the real-time loading requirements of multiple dynamic APP programs under limited hardware resources, this application provides a dynamic APP management method applied to the module components of a smart meter. Each module component includes at least flash memory and RAM. The dynamic APP management method includes steps S101 to S105, specifically:
[0054] S101: Receive the first dynamic APP program, save the first dynamic APP program to the flash memory, and determine the first storage space required to store the running data corresponding to the first dynamic APP program.
[0055] Furthermore, in some embodiments of the application, any module component of the smart meter is loaded with a preset operating system having a task scheduler; the code of each dynamic APP program includes first code for creating the task corresponding to the dynamic APP program and second code for calling the interface of the task scheduler; each dynamic APP program is obtained by compiling the code of the dynamic APP program into an address-independent program.
[0056] Preferably, in some embodiments of this application, the preset operating system is the Elec-Honda operating system, which is an operating system developed based on the open-source HarmonyOS and can be applied to the module components of smart meters.
[0057] Preferably, in some embodiments of the application, the module components of the smart meter include, but are not limited to, hardware devices such as a Bluetooth module. Taking a Bluetooth module as an example, the Bluetooth module includes at least one microcontroller unit (MCU), and each MCU includes at least one flash memory and one random access memory (RAM). Before the Bluetooth module receives the first dynamic APP program, the programming and compilation operations of the first dynamic APP program are first implemented through an external computer device. Specifically, this includes: firstly, during the programming operation of the first dynamic APP program, task creation is implemented in the first dynamic APP program, and an interface that can call the internal functions of the Elec-Tech operating system is constructed, such as the task scheduling function of the Elec-Tech operating system. This task scheduling function is implemented by calling the task scheduler inside the Elec-Tech operating system; after the programming operation of the first dynamic APP program is further completed, when compiling the source code of the first dynamic APP program, it is compiled into an address-independent program, thereby ensuring that the running data of the first dynamic APP program can be stored at any location in RAM.
[0058] Preferably, in some embodiments of the application, receiving the first dynamic APP program includes: an external computer device transmitting the compiled first dynamic APP program to the main MCU of the Bluetooth module of the smart meter via a communication interface (such as Bluetooth, asynchronous transceiver interface, etc.), so as to save the first dynamic APP program to the flash memory inside the main MCU of the Bluetooth module, and simultaneously storing the entry address of the first dynamic APP program in a fixed area of the flash memory. After receiving the first dynamic APP program, the main MCU performs a reset action and begins subsequent dynamic APP program management work.
[0059] Preferably, in some embodiments of this application, when starting subsequent dynamic APP program management work, a preset operating system is first initialized, such as performing kernel and driver-related initialization actions; then the task scheduler in the preset operating system is started to schedule the tasks created by each dynamic APP program.
[0060] Preferably, in some embodiments of this application, determining the first storage space required to store the running data corresponding to the first dynamic APP program includes: firstly reading the entry address of the first dynamic APP program from a fixed area of the flash memory, and then jumping to the entry address of the flash memory to read the APP information in the first dynamic APP program, thereby obtaining the first storage space (i.e. the required RAM resource size) required after the first dynamic APP program runs.
[0061] By including the first code for creating tasks and the second code for calling the task scheduler interface in the code of each dynamic application, the operating system no longer needs to create threads for each dynamic application. When a dynamic application starts, it automatically creates tasks, and the operating system manages these tasks using its own scheduling capabilities, avoiding significant modifications to the operating system. Furthermore, by compiling the code of dynamic applications into address-independent programs, the flexibility of storing and transferring the corresponding runtime data of each dynamic application is improved, thus increasing the efficiency of dynamic application management.
[0062] Furthermore, in some embodiments of the application, after determining the first storage space required to store the running data corresponding to the first dynamic APP program, the method further includes: reading the file information header and checksum of the first dynamic APP program from the flash memory, and determining the validity of the first dynamic APP program by comparing the file information header and calculating the checksum.
[0063] Preferably, in some embodiments of this application, the entry address of the first dynamic APP program can be read from a fixed area of the flash memory. Then, after jumping to the entry address of the flash memory, the file information header and Cyclic Redundancy Check (CRC) check code of the first dynamic APP program can be read. First, the file information header is compared to see if it is correct. Then, the CRC check code is calculated to see if it is correct, thereby determining whether the first dynamic APP program received by the smart meter module component is valid.
[0064] This application ensures the validity of dynamic APP programs by reading the file header and verification code before loading and comparing them, thus preventing abnormal operation problems caused by program corruption, incomplete downloads, or tampering, thereby improving the security and stability of the system from the source.
[0065] To more clearly explain S102 to S105, the following will combine... Figure 2 and Figure 3 S102 to S105 are described in detail.
[0066] First refer to Figure 2 Once the first storage space required for storing the running data of the first dynamic APP program is determined, the existence of a contiguous storage space greater than or equal to the first storage space in the current RAM is determined by the RAM allocation list recorded in real time. The RAM classification list includes the RAM size and address occupied by the running data of each currently running dynamic APP program.
[0067] S102: When there is no first consecutive free storage space in the RAM that is greater than or equal to the first storage space, select a plurality of second consecutive free storage spaces from all consecutive free storage spaces in the RAM; wherein the sum of all the second consecutive free storage spaces is greater than or equal to the first storage space.
[0068] refer to Figure 3 As shown, the first running data, second running data, third running data, and fourth running data are the running data of each launched dynamic APP program. Assuming that spaces A to E are all contiguous free storage spaces smaller than the first storage space, it is necessary to... Figure 3 Multiple running data are selected from all running data and moved to merge multiple consecutive free storage spaces in spaces A to E, thereby obtaining a third consecutive free storage space that is greater than or equal to the first storage space.
[0069] from Figure 3 As can be seen, in some cases, there are multiple ways to merge contiguous free storage spaces that meet the above conditions (i.e., greater than or equal to the first storage space). It is necessary to select the merging method that is most efficient and has the least impact on the second dynamic application. For example, Figure 3 The application can merge spaces C and D, spaces A and C, or spaces B and C, etc. To solve this problem, this application selects multiple second contiguous free storage spaces from the contiguous free storage space.
[0070] Furthermore, in some embodiments of this application, the step of filtering multiple second contiguous free storage spaces from all contiguous free storage spaces within RAM includes:
[0071] From all the contiguous free storage spaces, select all possible sets of contiguous free storage spaces; wherein the sum of all contiguous free storage spaces in each set of contiguous free storage spaces is greater than or equal to the first storage space;
[0072] Determine the first number of dynamic apps that need to be paused when merging all contiguous free storage spaces within each set of contiguous free storage spaces;
[0073] The set of contiguous free storage spaces with the smallest first quantity is selected as the plurality of second contiguous free storage spaces.
[0074] Preferably, in some embodiments of this application, in order to ensure the efficiency of data transfer during subsequent operation, sequentially adjacent consecutive free storage spaces are preferentially selected when constructing a set of contiguous free storage spaces. For example... Figure 3As shown, if there are no other contiguous free storage spaces between spaces A and B, then spaces A and B are adjacent. If the total size of spaces A and B is greater than or equal to the first storage space, then spaces A and B can form a set of free storage spaces. For example, if the total size of spaces A and C is greater than or equal to the first storage space, but there are other additional contiguous free storage spaces between them, merging spaces A and C would require simultaneously moving both the first and second running data, resulting in redundant data movement. Therefore, a set of contiguous free storage spaces cannot be formed. By ensuring that the contiguous free storage spaces within a set are consecutively adjacent, the need to move additional running data is avoided, improving the efficiency of dynamic app management.
[0075] Preferably, in some embodiments of this application, determining the first number of dynamic APP programs that need to be paused based on the contiguous free storage space to be merged includes: based on the premise that when constructing the contiguous free storage space set, sequentially adjacent contiguous free storage spaces are preferentially selected, the first number is equal to the size of the contiguous free storage space set minus 1.
[0076] This application minimizes the impact of pausing operations on running dynamic apps by selecting all sets of continuous free storage spaces that can free up enough first storage space from the continuous free storage space and selecting the set of continuous free storage spaces that requires pausing the fewest dynamic apps. At the same time, since the number of dynamic apps that need to transfer running data is reduced, the amount of data transferred to RAM memory is also significantly reduced, thus improving the management efficiency of dynamic apps.
[0077] Preferably, in some embodiments of this application, reference is made to Figure 2 If the sum of all currently existing contiguous free storage spaces is less than the first storage space, a RAM resource allocation failure message will be returned directly.
[0078] refer to Figure 2 When there are multiple consecutive free storage spaces that are greater than or equal to the first storage space, one of the consecutive free storage spaces needs to be selected as the storage space for the running data of the subsequent first dynamic APP program.
[0079] Furthermore, in some embodiments of this application, when the RAM contains a plurality of first consecutive free storage spaces that are greater than or equal to the first storage space, the first consecutive free storage space with the smallest difference from the first storage space is used as the third consecutive free storage space.
[0080] When multiple consecutive free storage spaces that meet the conditions exist in RAM, this application prioritizes selecting the consecutive free storage space with the smallest difference from the required first storage space as the storage area for running data. This can avoid the problem of too many discrete consecutive spaces caused by unreasonable space selection, thereby improving the overall utilization rate of RAM resources with limited RAM resources.
[0081] S103: Based on the plurality of second consecutive free storage spaces, determine a number of second dynamic APP programs that need to be paused from the dynamic APP programs that have been started in the current flash memory.
[0082] Preferably, in some embodiments of this application, reference is made to Figure 3 Meanwhile, while prioritizing the selection of sequentially adjacent consecutive free storage spaces when constructing a set of contiguous free storage spaces, the second dynamic application programs that need to be paused are: the dynamic application programs corresponding to the running data between the starting and ending consecutive free storage spaces of multiple second contiguous free storage spaces. If spaces C and D need to be merged, it is only necessary to pause the dynamic application programs corresponding to the third running data between spaces C and D.
[0083] S104: Pause each of the second dynamic APP programs, move the running data of each of the second dynamic APP programs stored in the RAM, and merge the multiple second consecutive free storage spaces to obtain a third consecutive free storage space.
[0084] Preferably, in some embodiments of this application, reference is made to Figure 3 At the same time, when constructing a set of contiguous free storage spaces, the premise is to prioritize the selection of consecutively adjacent contiguous free storage spaces. When moving the running data of each second dynamic APP program stored in RAM, the method with the shortest data moving path can be prioritized. For example, when merging spaces C and D, the third running data can be merged with the fourth running data. At this time, the moving path of the third running data is the shortest, thereby improving the data moving efficiency.
[0085] S105: Start the first dynamic APP and each of the second dynamic APPs in the flash memory, and store the running data of the first dynamic APP program in the third continuous free storage space.
[0086] Furthermore, in some embodiments of this application, launching the first dynamic APP in the flash memory includes: reading the entry address of the first dynamic APP program from the flash memory and jumping to the entry address; initializing the first dynamic APP program in the flash memory; creating the task through the first dynamic APP program; and pushing the task to the task scheduler of the preset operating system through the interface.
[0087] Preferably, in some embodiments of this application, when the task scheduler receives the task tasks pushed by each dynamic APP program, it performs each task task in a time-sharing manner and schedules the task tasks existing in the task scheduler according to the task priority.
[0088] This application achieves app initialization and execution in flash memory by reading the entry address of the dynamic app from flash memory and directly jumping to it, instead of copying the entire program to RAM. This significantly reduces the dependence on RAM resources, allowing limited RAM resources to be used to preserve runtime data that is more easily lost. Furthermore, the app can create corresponding tasks during initialization and push them to the operating system scheduler for unified management via the task scheduler interface. This eliminates the need for the operating system to create threads for each dynamic app, avoiding significant modifications to the operating system, while also shortening the loading and startup time of dynamic apps and improving task scheduling efficiency and operational stability.
[0089] Furthermore, in some embodiments of this application, after starting the first dynamic APP program and allocating RAM resources for the corresponding running data of the first dynamic APP program, the method further includes:
[0090] The task scheduler includes a monitoring task; when each dynamic APP program in the flash memory starts, it sends a heartbeat signal cyclically according to a preset period.
[0091] The monitoring task receives the heartbeat signal in real time, and for each dynamic APP, if the monitoring task does not receive the heartbeat signal sent by the dynamic APP for more than the preset period, the dynamic APP is restarted.
[0092] Preferably, in some embodiments of this application, after a dynamic APP program runs, there may be APP malfunctions, causing the APP to lose its corresponding functions. Therefore, a monitoring task is preset in the task scheduler, and this monitoring task has the highest priority. (See reference...) Figure 4The timing diagram shown illustrates how a monitoring task monitors the heartbeat signals periodically emitted by a dynamic app. When the dynamic app malfunctions and fails to send a heartbeat signal, the monitoring task will shut down all tasks of that app and restart it, thus enabling app recovery from the malfunction.
[0093] This application achieves real-time monitoring of the running status of dynamic APP programs by periodically receiving heartbeat signals from each dynamic APP program through a monitoring task in the task scheduler. When a dynamic APP program fails to send a heartbeat signal within a preset period, the system will automatically trigger a restart operation to ensure that the dynamic APP program resumes normal operation. This effectively prevents system freezes caused by program abnormalities, infinite loops, or resource blockages, improves the overall reliability and fault tolerance of operation, and ensures that the smart meter remains stable during long-term operation.
[0094] In summary, the dynamic APP management method provided in this application has the following advantages compared to the prior art: By storing the first dynamic APP program in flash memory and starting the first dynamic APP program in flash memory, it is not necessary to copy the first dynamic APP program to RAM when running the first dynamic APP program. Only the running data generated by the first dynamic APP program is stored in RAM, thereby saving RAM resources. Furthermore, since the dynamic APP program in the smart meter module component needs to keep running in real time, when managing the storage space of the running data corresponding to the dynamic APP program in RAM, firstly, multiple second consecutive free storage spaces are selected from all consecutive free storage spaces. Based on the multiple second consecutive free storage spaces, several second dynamic APP programs that need to be paused are determined from the started dynamic APP programs. Further, by pausing the second dynamic APP programs, the running data of each second dynamic APP program stored in RAM is retained. Finally, by moving the running data of each second dynamic APP program stored in RAM, the multiple second consecutive free storage spaces are merged to obtain a third consecutive free storage space, thereby avoiding the loss of real-time running data stored in RAM under the condition of limited RAM resources.
[0095] like Figure 5 As shown, based on the above method embodiments, one embodiment of this application provides a dynamic APP management device applied to the module components of a smart meter. Each module component includes at least: flash memory and RAM. The dynamic APP management device includes: a first dynamic APP program receiving module 201, a second continuous free storage space filtering module 202, a second dynamic APP program determining module 203, a second continuous free storage space merging module 204, and a first dynamic APP launching module 205.
[0096] Further, in some embodiments of this application, the first dynamic APP program receiving module 201 is used to receive the first dynamic APP program, save the first dynamic APP program to the flash memory, and determine the first storage space required to store the running data corresponding to the first dynamic APP program; the second continuous free storage space filtering module 202 is used to filter multiple second continuous free storage spaces from all continuous free storage spaces in the RAM when there is no first continuous free storage space greater than or equal to the first storage space in the RAM; wherein, the sum of all second continuous free storage spaces is greater than or equal to the first storage space; the second dynamic APP program determining module 203 is used to determine a number of second dynamic APP programs that need to be paused from the dynamic APP programs currently started in the flash memory according to the multiple second continuous free storage spaces; the second continuous free storage space merging module 204 is used to pause each second dynamic APP program, move the running data of each second dynamic APP program stored in the RAM, so as to merge the multiple second continuous free storage spaces to obtain a third continuous free storage space; the first dynamic APP starting module 205 is used to start the first dynamic APP and each second dynamic APP in the flash memory, and store the running data of the first dynamic APP program in the third continuous free storage space.
[0097] Furthermore, in some embodiments of this application, any module component of the smart meter is loaded with a preset operating system having a task scheduler; the code of each dynamic APP program includes first code for creating the task corresponding to the dynamic APP program and second code for calling the interface of the task scheduler; each dynamic APP program is obtained by compiling the code of the dynamic APP program into an address-independent program.
[0098] Furthermore, in some embodiments of this application, the first dynamic APP startup module 205 is used to start the first dynamic APP in the flash memory, including: the first dynamic APP startup module 205 is also used to read the entry address of the first dynamic APP program from the flash memory, jump to the entry address, initialize the first dynamic APP program in the flash memory, so that after the task is created by the first dynamic APP program, the task is pushed to the task scheduler of the preset operating system through the interface.
[0099] Furthermore, in some embodiments of this application, the task scheduler contains a monitoring task; after each dynamic APP program in the flash memory is started, it sends a heartbeat signal cyclically according to a preset period; the first dynamic APP startup module 205 is also used to receive the heartbeat signal in real time through the monitoring task, and for each dynamic APP program, when the monitoring task does not receive the heartbeat signal sent by the dynamic APP program for more than the preset period, it restarts the dynamic APP program.
[0100] Further, in some embodiments of this application, the second consecutive free storage space filtering module 202 includes: a consecutive free storage space set construction unit, a first quantity calculation unit, and a second consecutive free storage space filtering unit; the second consecutive free storage space filtering module 202 is used to filter multiple second consecutive free storage spaces from all consecutive free storage spaces in RAM, including: the consecutive free storage space set construction unit is used to filter all possible consecutive free storage space sets from all the consecutive free storage spaces; wherein, the sum of all consecutive free storage spaces in each consecutive free storage space set is greater than or equal to the first storage space; the first quantity calculation unit is used to determine the first number of dynamic APP programs that need to be paused when merging all consecutive free storage spaces in each consecutive free storage space set; the second consecutive free storage space filtering unit is used to select the consecutive free storage space set with the smallest first quantity as the multiple second consecutive free storage spaces.
[0101] Furthermore, in some embodiments of this application, when the RAM contains a plurality of first consecutive free storage spaces that are greater than or equal to the first storage space, the first consecutive free storage space with the smallest difference from the first storage space is used as the third consecutive free storage space.
[0102] Furthermore, in some embodiments of this application, after determining the first storage space required to store the running data corresponding to the first dynamic APP program, the method further includes: reading the file information header and checksum of the first dynamic APP program from the flash memory, and determining the validity of the first dynamic APP program by comparing the file information header and calculating the checksum.
[0103] It is understood that the above-described device embodiments correspond to the method embodiments of this application, and can implement the dynamic APP management method provided by any of the above-described method embodiments of this application.
[0104] In summary, the dynamic APP management device provided in this application has the following advantages compared to the prior art: By storing the first dynamic APP program in flash memory and starting the first dynamic APP program in flash memory, it is not necessary to copy the first dynamic APP program to RAM when running the first dynamic APP program. Only the running data generated by the first dynamic APP program is stored in RAM, thereby saving RAM resources. Furthermore, since the dynamic APP program in the smart meter module component needs to keep running in real time, when managing the storage space of the running data corresponding to the dynamic APP program in RAM, firstly, multiple second consecutive free storage spaces are selected from all consecutive free storage spaces. Based on the multiple second consecutive free storage spaces, several second dynamic APP programs that need to be paused are determined from the started dynamic APP programs. Further, by pausing the second dynamic APP programs, the running data of each second dynamic APP program stored in RAM is retained. Finally, by moving the running data of each second dynamic APP program stored in RAM, the multiple second consecutive free storage spaces are merged to obtain a third consecutive free storage space, thereby avoiding the loss of real-time running data stored in RAM under limited RAM resource conditions.
[0105] It should be noted that the device embodiments described above are merely illustrative, and some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided in this application, the connection relationships between modules indicate that they have communication connections, which can specifically be implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0106] Based on the above embodiments of the dynamic APP management method, another embodiment of this application provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the dynamic APP management method of any embodiment of this application.
[0107] For example, in this embodiment, the computer program can be divided into one or more modules, which are stored in the memory and executed by the processor to complete this application. The one or more module units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal device.
[0108] The terminal device may be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0109] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the terminal device, connecting all parts of the terminal device via various interfaces and lines.
[0110] Based on the above-described method embodiments, another embodiment of this application provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the dynamic APP management method described in any of the above-described method embodiments of this application.
[0111] The modules / units integrated in the device / terminal equipment, if implemented as software functional units and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
Claims
1. A dynamic APP management method, characterized in that, The module components used in smart meters, each module component including at least: flash memory and RAM; the dynamic APP management method includes: Receive the first dynamic APP program, save the first dynamic APP program to the flash memory, and determine the first storage space required to store the running data corresponding to the first dynamic APP program; When there is no first contiguous free storage space in the RAM that is greater than or equal to the first storage space, multiple second contiguous free storage spaces are selected from all contiguous free storage spaces in the RAM; wherein the sum of all second contiguous free storage spaces is greater than or equal to the first storage space. Based on the plurality of second contiguous free storage spaces, determine a number of second dynamic APP programs that need to be paused from the dynamic APP programs that are currently running in the flash memory; Pause each of the second dynamic APP programs, move the running data of each of the second dynamic APP programs stored in the RAM, and merge the multiple second consecutive free storage spaces to obtain a third consecutive free storage space; The first dynamic APP program is launched in the flash memory, and the running data of the first dynamic APP program is stored in the third continuous free storage space, while the second dynamic APP programs are restored. Any module component of the smart meter is equipped with a preset operating system with a task scheduler; the code of each dynamic APP program includes first code for creating the task corresponding to the dynamic APP program and second code for calling the interface of the task scheduler; each dynamic APP program is obtained by compiling the code of the dynamic APP program into an address-independent program; The step of launching the first dynamic APP program in the flash memory includes: The entry address of the first dynamic APP program is read from the flash memory, and the user jumps to the entry address. The first dynamic APP program is initialized in the flash memory. After the task is created by the first dynamic APP program, the task is pushed to the task scheduler of the preset operating system through the interface. The step of filtering multiple second contiguous free storage spaces from all contiguous free storage spaces in RAM includes: From all the contiguous free storage spaces, select all possible sets of contiguous free storage spaces; wherein the sum of all contiguous free storage spaces in each set of contiguous free storage spaces is greater than or equal to the first storage space; Determine the first number of dynamic apps that need to be paused when merging all contiguous free storage spaces within each set of contiguous free storage spaces; The set of contiguous free storage spaces with the smallest first quantity is selected as the plurality of second contiguous free storage spaces.
2. The dynamic APP management method as described in claim 1, characterized in that, Also includes: The task scheduler includes a monitoring task; when each dynamic APP program in the flash memory starts, it sends a heartbeat signal cyclically according to a preset period. The monitoring task receives the heartbeat signal in real time, and for each dynamic APP, if the monitoring task does not receive the heartbeat signal sent by the dynamic APP for more than the preset period, the dynamic APP is restarted.
3. The dynamic APP management method as described in claim 1, characterized in that, Also includes: When the RAM contains multiple first consecutive free storage spaces that are greater than or equal to the first storage space, the first consecutive free storage space with the smallest difference from the first storage space is taken as the third consecutive free storage space.
4. A dynamic APP management method as described in any one of claims 1 to 3, characterized in that, After determining the first storage space required to store the running data corresponding to the first dynamic APP program, the method further includes: reading the file information header and checksum of the first dynamic APP program from the flash memory, and determining the validity of the first dynamic APP program by comparing the file information header and calculating the checksum.
5. A dynamic APP management device, characterized in that, The module components used in smart meters, each of the module components includes at least: flash memory and RAM; the dynamic APP management device includes: a first dynamic APP program receiving module, a second continuous free storage space filtering module, a second dynamic APP program determining module, a second continuous free storage space merging module, and a first dynamic APP launching module; The first dynamic APP program receiving module is used to receive the first dynamic APP program, save the first dynamic APP program to the flash memory, and determine the first storage space required to store the running data corresponding to the first dynamic APP program. The second consecutive free storage space filtering module is used to filter multiple second consecutive free storage spaces from all consecutive free storage spaces in the RAM when there is no first consecutive free storage space greater than or equal to the first storage space in the RAM; wherein the sum of all second consecutive free storage spaces is greater than or equal to the first storage space; The second dynamic APP program determination module is used to determine, based on the plurality of second consecutive free storage spaces, a number of second dynamic APP programs that need to be paused from the dynamic APP programs that have been started in the current flash memory. The second consecutive free storage space merging module is used to pause each of the second dynamic APP programs, move the running data of each of the second dynamic APP programs stored in the RAM, and merge the multiple second consecutive free storage spaces to obtain a third consecutive free storage space. The first dynamic APP startup module is used to start the first dynamic APP program in the flash memory, store the running data of the first dynamic APP program in the third continuous free storage space, and restore each of the second dynamic APP programs. Any module component of the smart meter is equipped with a preset operating system with a task scheduler; the code of each dynamic APP program includes first code for creating the task corresponding to the dynamic APP program and second code for calling the interface of the task scheduler; each dynamic APP program is obtained by compiling the code of the dynamic APP program into an address-independent program; The first dynamic APP startup module is used to start the first dynamic APP program in the flash memory, including: the first dynamic APP startup module is further used to read the entry address of the first dynamic APP program from the flash memory, jump to the entry address, initialize the first dynamic APP program in the flash memory, and after creating the task through the first dynamic APP program, push the task to the task scheduler of the preset operating system through the interface. The second consecutive free storage space filtering module includes: a consecutive free storage space set construction unit, a first quantity calculation unit, and a second consecutive free storage space filtering unit. The second consecutive free storage space filtering module is used to filter multiple second consecutive free storage spaces from all consecutive free storage spaces in RAM, including: the consecutive free storage space set construction unit is used to filter all possible consecutive free storage space sets from all the consecutive free storage spaces; wherein the sum of all consecutive free storage spaces in each consecutive free storage space set is greater than or equal to the first storage space; the first quantity calculation unit is used to determine a first number of dynamic APP programs that need to be paused when merging all consecutive free storage spaces in each consecutive free storage space set; the second consecutive free storage space filtering unit is used to select the consecutive free storage space set with the smallest first quantity as the multiple second consecutive free storage spaces.
6. A terminal device, characterized in that, The device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement a dynamic APP management method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform a dynamic APP management method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Distributed storage system, space allocation method and device, electronic equipment and nonvolatile storage medium
CN119718211A
Method and apparatus for reclaiming and defragmenting a flash memory device
WO1999056212A1