A task scheduling method and system of an electric energy meter, a terminal device, and a medium

By classifying application types and setting priorities in the electricity meter, and adopting a time-slice allocation strategy, the problem of resource allocation imbalance in traditional electricity meter task scheduling is solved, achieving efficient task processing and subroutine collaborative scheduling, and improving the task processing efficiency and stability of the electricity meter.

CN122363830APending Publication Date: 2026-07-10GUANGDONG ELECTRIC POWER SCI RES INST ENERGY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610344871.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-20
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Traditional electricity meter task scheduling strategies are vulnerable to human-caused code attacks, which can prevent low-priority tasks from obtaining resources and result in low task processing efficiency.

Method used

The system employs application type-based partitioning and priority settings, with system applications having higher priority than business applications. Time slice allocation ensures that system applications are not preempted by business applications, and a unified scheduling subroutine is used for containerized applications to achieve collaborative scheduling.

Benefits of technology

It improves the efficiency of electricity meter task processing, avoids resource allocation imbalance, ensures the execution of high-priority tasks and the resource supply of subroutines, and enhances the stability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122363830A_ABST
    Figure CN122363830A_ABST
Patent Text Reader

Abstract

This invention provides a task scheduling method, system, terminal device, and medium for electricity meters. The method includes: determining the type of each application of the target electricity meter; obtaining the total time slice to be allocated to all applications; wherein the application types include system applications, business applications, and container applications, and container applications include subroutines; allocating time to each application based on the total time slice according to the application priority, to obtain a first time slice for each application; allocating time to each subroutine based on the first time slice of the container application according to a preset execution time ratio, to obtain a second time slice for each subroutine; and controlling the central processing unit to execute the tasks and subroutines in each application sequentially according to the allocation results of the first and second time slices. This can improve the task processing efficiency of the electricity meter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention application relates to the field of electricity meter systems, and more particularly to a task scheduling method, system, terminal equipment, and medium for electricity meters. Background Technology

[0002] With the development of smart grid technology, the functions of electricity meter systems are becoming increasingly complex, requiring effective scheduling of different types of tasks. Traditional electricity meters use basic microcontrollers, which meet the requirements for stable task operation through a simple main program (main loop) and timer interrupt scheduling strategy.

[0003] However, with the increasing complexity of task processing logic and the rising demands for real-time performance, emerging energy meters typically employ MCUs (Microcontroller Units) with SOC (System on Chip) to run embedded operating systems, thereby enabling them to handle more complex tasks and optimize real-time performance. Currently, the task scheduling strategies used in energy meters based on these embedded operating systems are mainly priority-based preemptive scheduling and round-robin scheduling. However, these scheduling strategies are vulnerable to human-caused code attacks, which can prevent low-priority tasks from acquiring resources, resulting in low task processing efficiency for the energy meter. Summary of the Invention

[0004] This invention application provides a task scheduling method, system, terminal equipment, and medium for electricity meters to solve the technical problem of how to improve the task processing efficiency of electricity meters.

[0005] To address the aforementioned technical problems, this invention provides a task scheduling method for electricity meters, comprising: Determine the type of each application for the target energy meter; and obtain the total time slice to be allocated for all applications; wherein, the types of applications include system applications, business applications, and container applications, and the container applications include subroutines; Based on the application priority and the total time slice, time is allocated to each application to obtain the first time slice for each application; wherein, the priority of the system application is higher than the priority of the business application. Based on the preset execution time ratio and the first time slice of the containerized application, time is allocated to each subroutine to obtain the second time slice of each subroutine. Based on the allocation results of the first and second time slices, the central processing unit is controlled to execute the tasks and subroutines in each application sequentially.

[0006] As a preferred embodiment, the step of controlling the central processing unit to execute tasks in each application sequentially according to the allocation results of the first and second time slices further includes: Get the priority values ​​of each task in each system application, and get the priority values ​​of each task in each business application; Calculate the first proportion of the priority value of a task in a system application to the sum of the priority values ​​of all tasks in the system application, and divide the first time slice of the system application according to the first proportion to obtain the third time slice of each task in the system application. Calculate the second proportion of the priority value of a task in the business application to the sum of the priority values ​​of all tasks in the business application, and divide the first time slice of the business application according to the second proportion to obtain the third time slice of each task in the business application. Based on the second time slice of each subroutine, the third time slice of each task in the system application, and the third time slice of each task in the business application, the central processing unit is controlled to execute the tasks and subroutines in each application sequentially.

[0007] As a preferred embodiment, when the third time slice of each task in the system application is obtained, the third time slice of each task in the system application is rounded down, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the system application. When the third time slice of each task in the business application is obtained, the third time slice of each task in the business application is rounded down, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the business application.

[0008] As a preferred embodiment, when the task type in the system application and the business application is a protection task, the priority value of the protection task includes a basic priority and a load compensation; the load compensation is calculated based on the real-time CPU utilization.

[0009] As a preferred embodiment, the task scheduling method further includes: Monitor the execution status of each subroutine; When an abnormal state or abnormal exit is detected during the execution of a subroutine, the subroutine that has the abnormal state or abnormal exit is recorded. In the next scheduling cycle, the central processing unit skips recorded subroutines when executing tasks and subroutines.

[0010] As a preferred embodiment, before determining the type of each application for the target energy meter, the method further includes: Perform validity checks on the information items of each application; When the validity check passes, the kernel task management interface is called to create a corresponding task control block for the application, allocate a task stack for each task, configure the initial task state for each task, and complete the registration of each task.

[0011] As a preferred embodiment, before performing the validity verification on the information items of each application, the method further includes: The bootloader is started to initialize the hardware; Load the kernel image into memory and perform an integrity check on the kernel image loaded into memory; Load the basic kernel module and initialize the system core data structure of the target electricity meter.

[0012] Accordingly, this invention application also provides a task scheduling system for an electricity meter, including a total time slice acquisition module, a first allocation module, a second allocation module, and an execution module; wherein, The total time slice acquisition module is used to determine the type of each application of the target energy meter; and to acquire the total time slice to be allocated to all applications; wherein, the types of applications include system applications, business applications and container applications, and the container applications include subroutines; The first allocation module is used to allocate time to each application based on the total time slice according to the application's priority, thereby obtaining a first time slice for each application; wherein, the priority of the system application is greater than the priority of the business application. The second allocation module is used to allocate time to each subroutine based on the first time slice of the containerized application according to a preset execution time ratio, so as to obtain the second time slice of each subroutine. The execution module is used to control the central processing unit to execute tasks and subroutines in each application sequentially according to the allocation results of the first time slice and the second time slice.

[0013] As a preferred embodiment, the execution module controls the central processing unit to execute tasks in each application sequentially according to the allocation results of the first and second time slices, and further includes: The execution module obtains the priority values ​​of each task in each system application and the priority values ​​of each task in each business application. Calculate the first proportion of the priority value of a task in a system application to the sum of the priority values ​​of all tasks in the system application, and divide the first time slice of the system application according to the first proportion to obtain the third time slice of each task in the system application. Calculate the second proportion of the priority value of a task in the business application to the sum of the priority values ​​of all tasks in the business application, and divide the first time slice of the business application according to the second proportion to obtain the third time slice of each task in the business application. Based on the second time slice of each subroutine, the third time slice of each task in the system application, and the third time slice of each task in the business application, the central processing unit is controlled to execute the tasks and subroutines in each application sequentially.

[0014] As a preferred embodiment, when the third time slice of each task in the system application is obtained, the execution module performs rounding on the third time slice of each task in the system application, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the system application. When the third time slice of each task in the business application is obtained, the execution module performs rounding on the third time slice of each task in the business application, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the business application.

[0015] As a preferred embodiment, when the task type in the system application and the business application is a protection task, the priority value of the protection task includes a basic priority and a load compensation; the load compensation is calculated based on the real-time CPU utilization.

[0016] As a preferred embodiment, the task scheduling system further includes a monitoring module, which is used for: Monitor the execution status of each subroutine; When an abnormal state or abnormal exit is detected during the execution of a subroutine, the subroutine that has the abnormal state or abnormal exit is recorded. In the next scheduling cycle, the central processing unit skips recorded subroutines when executing tasks and subroutines.

[0017] As a preferred embodiment, the task scheduling system further includes a task registration module, which is used before determining the type of each application for the target energy meter: Perform validity checks on the information items of each application; When the validity check passes, the kernel task management interface is called to create a corresponding task control block for the application, allocate a task stack for each task, configure the initial task state for each task, and complete the registration of each task.

[0018] As a preferred embodiment, the task scheduling system further includes an initialization module, which is used before performing validity checks on the information items of each application: The bootloader is started to initialize the hardware; Load the kernel image into memory and perform an integrity check on the kernel image loaded into memory; Load the basic kernel module and initialize the system core data structure of the target electricity meter.

[0019] Accordingly, this application also 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, wherein the processor executes the computer program to implement the task scheduling method of the electricity meter.

[0020] Accordingly, this application also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the task scheduling method of the electricity meter.

[0021] Compared with the prior art, this invention application has the following beneficial effects: This invention provides a task scheduling method, system, terminal device, and medium for electricity meters. Traditional preemptive or cyclic scheduling techniques often result in high-priority tasks excessively consuming resources, preventing low-priority tasks from obtaining operational resources. This invention addresses this by clearly defining application types and prioritizing system applications over business applications, thus allocating first time slices first. This ensures that tasks in system applications are not preempted by tasks in business applications. Furthermore, business applications also receive first time slices based on the total time slice. Subroutines are allocated second time slices by dividing the first time slice of container applications according to a preset ratio. This unified scheduling of subroutines through container applications achieves collaborative scheduling between subroutines, avoiding data interference caused by multiple subroutines simultaneously accessing shared resources while ensuring resource supply for subroutines. Moreover, applications and subroutines employ different resource allocation mechanisms. Applications allocate resources based on priority, considering application type, while subroutines are allocated according to a preset execution time ratio. This allocation and scheduling process implements a resource separation design for the central processing unit, fundamentally solving the resource allocation imbalance problem of traditional scheduling and significantly improving the overall processing efficiency of electricity meter tasks. Attached Figure Description

[0022] Figure 1 : A flowchart illustrating an embodiment of the task scheduling method for an electricity meter provided in this application.

[0023] Figure 2: A flowchart illustrating a preferred embodiment of the task scheduling method for an electricity meter provided in this application.

[0024] Figure 3 : A schematic diagram of an embodiment of the task scheduling system for an electricity meter provided in this application. Detailed Implementation

[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0026] Example 1 Please refer to Figure 1 , Figure 1 The present invention provides a task scheduling method for an electricity meter, comprising steps S101 to S104; wherein each step is described in detail below: Step S101: Determine the type of each application of the target energy meter; and obtain the total time slices to be allocated to all applications.

[0027] In some preferred embodiments, before step S101, after the target energy meter's system is powered on or reset, a boot program can be started to initialize the hardware; the kernel image is loaded into memory or random access memory (RAM), and the integrity of the kernel image loaded into memory is verified; the basic kernel module is loaded, and the system core data structure of the target energy meter is initialized.

[0028] For example, the initialized hardware can be for minimal hardware, such as clock configuration, stack setup, and serial debugging interface, etc.

[0029] The integrity verification can be signature verification or CRC check, thereby ensuring a trusted system boot. After initialization and image loading are completed, the bootloader transfers control to the kernel entry function, and the system enters the formal running state.

[0030] The basic kernel modules described in this embodiment include a scheduler, timers, and memory management. After the kernel starts, it enters the system initialization phase, sequentially initializing the scheduler, timers, interrupt controller, memory management module, etc. The system establishes a task control block pool, a ready queue, and a scheduling policy structure, configures the system timer for time-slice scheduling, and initializes the memory pool and task communication mechanisms (such as semaphores, message queues, etc.). Simultaneously, it configures memory access permissions to achieve task isolation and memory protection.

[0031] Furthermore, the validity of each application's information items is verified; when the validity verification passes, the kernel task management interface is called to create a corresponding task control block for the application, and a task stack is allocated to each task, the initial task state is configured for each task, and the registration of each task is completed.

[0032] In some embodiments, the application's information items (or application's information block configuration items) are shown in Table 1: Table 1 Examples of information items in the application For example, based on the application information block, the system verifies its validity and completes task creation and scheduling registration. The system reads the application information block from a specified address (0x800000) in Flash. The application information block describes the application's basic information, resource requests, and permissions, and is defined at a fixed location (0x800000) in the program. When scheduling the application, the system uses this parameter to manage the application's running state. The system verifies the validity of each application information item (such as signature authentication or CRC check). Ensuring data integrity and security, the system calls the kernel task management interface to create a corresponding task control block for the application, allocates a task stack, sets the initial task state (ready state), and registers the task to the global task ready queue.

[0033] In addition, applications can configure the CPU usage time by setting the APP_SLICE_TICKS parameter, with a value ranging from 10 to 255 ticks.

[0034] In step S101, the application types include system applications, business applications, and container applications. Each container application includes several subroutines. The target energy meter system includes at least one system application, at least one business application, and at least one container application. The application described in this embodiment can be understood as an App.

[0035] In this embodiment, the total time slice to be allocated refers to the total duration to be allocated. In subsequent steps, the total time slice can be divided according to the type or priority of the application to obtain the first time slice for each application. Whether it is the total time slice, the first time slice, the second time slice, or the third time slice, the smallest unit of time is represented by a tick, and each tick has a duration of ten milliseconds.

[0036] Step S102: Based on the application priority and the total time slice, allocate time to each application to obtain the first time slice for each application.

[0037] In this step, the priority of the system application is higher than that of the business application. That is, when determining the first time slice for each application, the execution quality of the system application should be given priority. This priority includes, but is not limited to, prioritizing the allocation of the first time slice to the system application, or allocating a longer first time slice to the system application. The purpose is to ensure that tasks in the system application are not preempted by tasks in the business application, and to ensure that tasks in the system application can be executed efficiently and with high quality.

[0038] In some preferred embodiments, each system application and business application contains several tasks to be executed. During the execution of tasks in the system application and business application, if high load or increased system real-time requirements occur, a "task type label" mechanism is used to assign dynamic priorities to protection tasks (label SAFETY_CRITICAL).

[0039] In other words, when the tasks in the system application and the business application are protection tasks, the priority value of the protection task includes a base priority and load compensation. The base priority is fixed and can be pre-configured, while the load compensation is calculated based on the real-time CPU utilization. Thus, by using a load compensation strategy for protection tasks, the priority value can be flexibly adjusted according to the real-time requirements of the task, effectively solving the resource waste and task queuing problems caused by fixed-priority scheduling in existing technologies, and improving the system's real-time performance and response speed. For example, when the CPU load exceeds 80%, the priority of the protection task is automatically increased to ensure its latency is ≤20ms; when the CPU load drops below a safe threshold (e.g., 60%), the original priority is restored.

[0040] In some embodiments, the identification of protection-related tasks is as follows: The Inos_get_CPU_Usage interface can be used to obtain the CPU utilization rate of the entire system. When the utilization rate exceeds the system's set threshold, such as 60%, the APP_PROPERTY feature word in the APP information block definition can be obtained. If the feature word is SAFETY_CRITICAL, the APP is considered to be a protected task.

[0041] Step S103: Based on the preset execution time ratio and the first time slice of the container application, allocate time to each subroutine to obtain the second time slice of each subroutine.

[0042] In some implementations, a subroutine may refer to a small task application that executes within a container application.

[0043] The second time slice of each subroutine can be obtained by dividing the first time slice of the containerized application according to a pre-set execution time ratio.

[0044] For example, a container application is allocated a first time slice of 60 ticks, which includes a first subroutine, a second subroutine, and a third subroutine. The execution time ratio of the three subroutines is preset to be 2:1:1. Then, the second time slices allocated to the three subroutines are 30 ticks, 15 ticks, and 15 ticks, respectively.

[0045] Step S104: Based on the allocation results of the first time slice and the second time slice, control the central processing unit to execute the tasks and subroutines in each application sequentially.

[0046] Since each system application and each business application contains several tasks that need to be performed, the first time slice for system applications and business applications needs to be further subdivided.

[0047] Therefore, in some preferred embodiments, such as Figure 2 As shown, step S104, which involves controlling the central processing unit to execute tasks in each application sequentially based on the allocation results of the first and second time slices, includes steps S201 to S204; each step is detailed below: Step S201: Obtain the priority values ​​of each task in each system application and the priority values ​​of each task in each business application. Step S202: Calculate the first proportion of the priority value of the task in the system application to the sum of the priority values ​​of all tasks in the system application, and divide the first time slice of the system application according to the first proportion to obtain the third time slice of each task in the system application. Step S203: Calculate the second proportion of the priority value of the task in the business application to the sum of the priority values ​​of all tasks in the business application, and divide the first time slice of the business application according to the second proportion to obtain the third time slice of each task in the business application. Step S204: Based on the second time slice of each subroutine, the third time slice of each task in the system application, and the third time slice of each task in the business application, control the central processing unit to execute the tasks and subroutines in each application sequentially.

[0048] This preferred embodiment divides the first time slice of a system application into third time slices for each task in the system application based on the proportion of the priority value of each task in the sum of all task priority values. Similarly, it obtains the third time slices for each task in the business application, thereby achieving further refinement of the time slices. This ensures that tasks with high importance or high priority are executed first, thus ensuring the integrity of the execution.

[0049] For example, the allocation result of the third time slice by dividing a single (system application layer program or business application) first time slice can be expressed as: ; Where n is the total number of tasks in the application, t i This represents the number of ticks allocated to the third time slice corresponding to the i-th task of a system application or business application, where t is the total number of ticks in the first time slice of the system application or business application, and s is the total number of ticks allocated to the third time slice. i This represents the priority value of the i-th task in a system application or business application, and the value can range from 0 to 31.

[0050] To avoid omissions or starvation during time slice allocation, all calculation results for the second ratio are rounded down. Therefore, in a further preferred embodiment, when obtaining the third time slice for each task in the system application, the third time slice for each task in the system application is rounded down, and if a remainder exists, the time slice corresponding to the remainder is allocated to the first task in the system application; similarly, when obtaining the third time slice for each task in the business application, the third time slice for each task in the business application is rounded down, and if a remainder exists, the time slice corresponding to the remainder is allocated to the first task in the business application.

[0051] For example, the time slice ultimately allocated to the first task (task0) in a business application or system application can be represented as: ; ; Where s0 is the priority value of task0, and mod represents the remainder.

[0052] Furthermore, the execution status of each subroutine can be monitored. When an abnormal state or abnormal exit is detected during the execution of a subroutine, the subroutine with the abnormal state or abnormal exit is recorded. In the next scheduling cycle, the central processing unit is controlled to skip the recorded subroutine when executing tasks and subroutines. This can effectively prevent the system from crashing due to abnormalities and improve the reliability and stability of the system.

[0053] Accordingly, such as Figure 3 As shown, this application also provides a task scheduling system 300 for an electricity meter, including a total time slice acquisition module 301, a first allocation module 302, a second allocation module 303, and an execution module 304; wherein, The total time slice acquisition module 301 is used to determine the type of each application of the target energy meter; and to acquire the total time slice to be allocated to all applications; wherein, the types of applications include system applications, business applications and container applications, and the container applications include subroutines; The first allocation module 302 is used to allocate time to each application according to the application priority and based on the total time slice, to obtain the first time slice of each application; wherein, the priority of the system application is greater than the priority of the business application. The second allocation module 303 is used to allocate time to each subroutine according to a preset execution time ratio and based on the first time slice of the container application, so as to obtain the second time slice of each subroutine. The execution module 304 is used to control the central processing unit to execute the tasks and subroutines in each application sequentially according to the allocation results of the first time slice and the second time slice.

[0054] As a preferred embodiment, the execution module 304 controls the central processing unit to execute tasks in each application sequentially according to the allocation results of the first time slice and the second time slice, and further includes: The execution module 304 obtains the priority values ​​of each task in each system application and the priority values ​​of each task in each business application. Calculate the first proportion of the priority value of a task in a system application to the sum of the priority values ​​of all tasks in the system application, and divide the first time slice of the system application according to the first proportion to obtain the third time slice of each task in the system application. Calculate the second proportion of the priority value of a task in the business application to the sum of the priority values ​​of all tasks in the business application, and divide the first time slice of the business application according to the second proportion to obtain the third time slice of each task in the business application. Based on the second time slice of each subroutine, the third time slice of each task in the system application, and the third time slice of each task in the business application, the central processing unit is controlled to execute the tasks and subroutines in each application sequentially.

[0055] As a preferred embodiment, when the third time slice of each task in the system application is obtained, the execution module 304 performs rounding on the third time slice of each task in the system application, and if there is a remainder, allocates the time slice corresponding to the remainder to the first task in the system application. When the third time slice of each task in the business application is obtained, the execution module 304 performs rounding on the third time slice of each task in the business application, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the business application.

[0056] As a preferred embodiment, when the task type in the system application and the business application is a protection task, the priority value of the protection task includes a basic priority and a load compensation; the load compensation is calculated based on the real-time CPU utilization.

[0057] As a preferred embodiment, the task scheduling system 300 further includes a monitoring module, which is used for: Monitor the execution status of each subroutine; When an abnormal state or abnormal exit is detected during the execution of a subroutine, the subroutine that has the abnormal state or abnormal exit is recorded. In the next scheduling cycle, the central processing unit skips recorded subroutines when executing tasks and subroutines.

[0058] As a preferred embodiment, the task scheduling system 300 further includes a task registration module, which is used before determining the type of each application for the target energy meter: Perform validity checks on the information items of each application; When the validity check passes, the kernel task management interface is called to create a corresponding task control block for the application, allocate a task stack for each task, configure the initial task state for each task, and complete the registration of each task.

[0059] As a preferred embodiment, the task scheduling system 300 further includes an initialization module, which is used before the validity verification of the information items of each application is performed: The bootloader is started to initialize the hardware; Load the kernel image into memory and perform an integrity check on the kernel image loaded into memory; Load the basic kernel module and initialize the system core data structure of the target electricity meter.

[0060] Accordingly, this application also 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, wherein the processor executes the computer program to implement the task scheduling method of the electricity meter.

[0061] 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, connecting various parts of the terminal via various interfaces and lines.

[0062] The memory can be used to store the computer program. The processor implements various functions of the terminal by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0063] Accordingly, this application also provides a computer-readable storage medium, which includes a stored computer program, wherein the computer program, when running, controls the device where the computer-readable storage medium is located to execute the task scheduling method of the electricity meter.

[0064] If the module integrated into the task scheduling system of the electricity meter is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention 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.

[0065] Compared with the prior art, this invention application has the following beneficial effects: This invention provides a task scheduling method, system, terminal device, and medium for electricity meters. Traditional preemptive or cyclic scheduling techniques often result in high-priority tasks excessively consuming resources, preventing low-priority tasks from obtaining operational resources. This invention addresses this by clearly defining application types and prioritizing system applications over business applications, thus allocating first time slices first. This ensures that tasks in system applications are not preempted by tasks in business applications. Furthermore, business applications also receive first time slices based on the total time slice. Subroutines are allocated second time slices by dividing the first time slice of container applications according to a preset ratio. This unified scheduling of subroutines through container applications achieves collaborative scheduling between subroutines, avoiding data interference caused by multiple subroutines simultaneously accessing shared resources while ensuring resource supply for subroutines. Moreover, applications and subroutines employ different resource allocation mechanisms. Applications allocate resources based on priority, considering application type, while subroutines are allocated according to a preset execution time ratio. This allocation and scheduling process implements a resource separation design for the central processing unit, fundamentally solving the resource allocation imbalance problem of traditional scheduling and significantly improving the overall processing efficiency of electricity meter tasks.

[0066] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.

Claims

1. A task scheduling method for an electricity meter, characterized in that, include: Determine the type of application for each target energy meter; And obtain the total time slice to be allocated for all applications; wherein, the types of applications include system applications, business applications and container applications, and the container applications include subroutines; Based on the application priority and the total time slice, time is allocated to each application to obtain the first time slice for each application; wherein, the priority of the system application is higher than the priority of the business application. Based on the preset execution time ratio and the first time slice of the containerized application, time is allocated to each subroutine to obtain the second time slice of each subroutine. Based on the allocation results of the first and second time slices, the central processing unit is controlled to execute the tasks and subroutines in each application sequentially.

2. The task scheduling method for an electricity meter as described in claim 1, characterized in that, The step of controlling the central processing unit to execute tasks in each application sequentially based on the allocation results of the first and second time slices also includes: Get the priority values ​​of each task in each system application, and get the priority values ​​of each task in each business application; Calculate the first proportion of the priority value of a task in a system application to the sum of the priority values ​​of all tasks in the system application, and divide the first time slice of the system application according to the first proportion to obtain the third time slice of each task in the system application. Calculate the second proportion of the priority value of a task in the business application to the sum of the priority values ​​of all tasks in the business application, and divide the first time slice of the business application according to the second proportion to obtain the third time slice of each task in the business application. Based on the second time slice of each subroutine, the third time slice of each task in the system application, and the third time slice of each task in the business application, the central processing unit is controlled to execute the tasks and subroutines in each application sequentially.

3. The task scheduling method for an electricity meter as described in claim 2, characterized in that, When the third time slice of each task in the system application is obtained, the third time slice of each task in the system application is rounded down, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the system application. When the third time slice of each task in the business application is obtained, the third time slice of each task in the business application is rounded down, and if there is a remainder, the time slice corresponding to the remainder is allocated to the first task in the system application.

4. The task scheduling method for an electricity meter as described in claim 2, characterized in that, When the task type in the system application and the business application is a protection task, the priority value of the protection task includes a basic priority and a load compensation; the load compensation is calculated based on the real-time CPU utilization.

5. The task scheduling method for an electricity meter as described in claim 1, characterized in that, The task scheduling method further includes: Monitor the execution status of each subroutine; When an abnormal state or abnormal exit is detected during the execution of a subroutine, the subroutine that has the abnormal state or abnormal exit is recorded. In the next scheduling cycle, the central processing unit skips recorded subroutines when executing tasks and subroutines.

6. A task scheduling method for an electricity meter as described in any one of claims 1 to 5, characterized in that, Before determining the type of application for each target energy meter, the following is also included: Perform validity checks on the information items of each application; When the validity check passes, the kernel task management interface is called to create a corresponding task control block for the application, allocate a task stack for each task, configure the initial task state for each task, and complete the registration of each task.

7. The task scheduling method for an electricity meter as described in claim 6, characterized in that, Before performing the validity verification on the information items of each application, the following is also included: The bootloader is started to initialize the hardware; Load the kernel image into memory and perform an integrity check on the kernel image loaded into memory; Load the basic kernel module and initialize the system core data structure of the target electricity meter.

8. A task scheduling system for an electricity meter, characterized in that, It includes a total time slice acquisition module, a first allocation module, a second allocation module, and an execution module; among which, The total time slice acquisition module is used to determine the type of each application of the target energy meter; and to acquire the total time slice to be allocated to all applications; wherein, the types of applications include system applications, business applications and container applications, and the container applications include subroutines; The first allocation module is used to allocate time to each application based on the total time slice according to the application's priority, thereby obtaining a first time slice for each application; wherein, the priority of the system application is greater than the priority of the business application. The second allocation module is used to allocate time to each subroutine based on the first time slice of the containerized application according to a preset execution time ratio, so as to obtain the second time slice of each subroutine. The execution module is used to control the central processing unit to execute tasks and subroutines in each application sequentially according to the allocation results of the first time slice and the second time slice.

9. 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, when executing the computer program, implements the task scheduling method for an energy meter as described in any one of claims 1 to 7.

10. 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 containing the computer-readable storage medium to perform the task scheduling method for an energy meter as described in any one of claims 1 to 7.