OpenHarmony-based task scheduling method with earliest deadline priority

By calculating the static priority and resource weight of tasks in the OpenHarmony task scheduling method and combining it with an optimized time-slice round-robin scheduling, the problem of low resource utilization in multi-core environments is solved, and efficient task scheduling and real-time response are achieved.

CN120973486APending Publication Date: 2025-11-18HARBIN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510949120.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing robot operating systems struggle to efficiently utilize resources in multi-core environments, leading to task scheduling delays and resource contention conflicts, which fail to meet the real-time and load balancing requirements of industrial robots.

Method used

We adopt an earliest deadline-first task scheduling method based on OpenHarmony. By calculating the static priority and resource weight of tasks and combining it with an optimized time-slice round-robin scheduling algorithm, we prioritize the allocation of resources to urgent tasks to ensure timely response of high-priority tasks.

Benefits of technology

It improves resource utilization and task execution efficiency, reduces task latency and resource contention, and enhances the system's real-time performance and load balancing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973486A_ABST
    Figure CN120973486A_ABST
Patent Text Reader

Abstract

The invention provides a task scheduling method with earliest deadline priority based on OpenHarmony, belongs to the technical field of operating system cores, and aims to solve the problem of low real-time performance of an industrial robot operating system. Sorting the task queues according to the task priorities; when the new task arrives, determining whether to preempt the current to-be-executed task according to the priority of the new task; and if the priority of the new task is equal to the priority of the current to-be-executed task, determining an execution sequence of the new task and the to-be-executed task by adopting an optimized version time slice round-robin scheduling algorithm to complete task scheduling. In the task scheduling process, the I / O bandwidth requirement and the required memory resource of the task are superior to those of an existing algorithm, the resource can still be allocated to the more emergency task more reasonably and preferentially in the environment with high load and complex resource requirement, and better scheduling performance and efficiency are shown.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an earliest deadline-first task scheduling method based on OpenHarmony, belonging to the field of operating system kernel technology. Background Technology

[0002] As the core software system of industrial robots, the robot operating system undertakes the core tasks of managing hardware and software resources, realizing physical-information mapping, and controlling low-level operations and movements. Its performance and real-time performance directly determine the capabilities and efficiency of industrial robots. Real-time performance issues not only affect the operating efficiency of industrial robots but also directly impact the stability and safety of production lines. Improving the real-time performance of robot operating systems has become a key research and application topic.

[0003] Existing robot operating systems still have many problems and shortcomings in real-time scheduling. Scheduling algorithms struggle to guarantee sufficient response time for high-priority tasks, leading to potential delays or missed deadlines in time-sensitive tasks. In environments with high task concurrency and dynamically changing resources, resource management mechanisms easily become bottlenecks, exacerbating resource contention and preemption conflicts. Current systems lack a unified coordination mechanism in multi-core environments, making it difficult to fully utilize multi-core processing power in task scheduling and resource allocation, further impacting real-time performance and load balancing. With the increasing demands of industrial automation and intelligent manufacturing, the real-time requirements of industrial robots' operating systems are constantly rising. The widespread adoption of multi-core processors provides the hardware foundation for improving real-time scheduling capabilities, but how to efficiently utilize resources, reduce scheduling latency, and ensure the determinism of task execution in multi-core environments remains a pressing issue. Exploring real-time scheduling and load balancing strategies for multi-core environments, as well as rapid response mechanisms for high-priority tasks, has become a key research direction for improving the performance of industrial robot operating systems.

[0004] OpenHarmony's LiteOS-A kernel, evolved from Huawei's LiteOS, provides a solid foundation for the technological accumulation and future development of domestic operating systems. LiteOS, with its high efficiency and flexibility, has broad application prospects in the industrial field. However, current domestic embedded operating systems still face multiple challenges in the development of intelligent operating systems for industrial robots, particularly in terms of real-time performance, failing to meet the strict time constraints and complex environments required by industrial robots. Therefore, researching strong real-time scheduling algorithms based on multi-feature fusion is of great significance for improving the real-time performance and optimizing the performance of domestic industrial robot operating systems.

[0005] In OpenHarmony's LiteOS-A kernel task scheduling, two core scheduling algorithms are employed: time-slice round-robin scheduling and FIFO (First-In, First-Out) scheduling. Compared to other complex scheduling methods (such as purely priority-based scheduling), these two algorithms, with their simplicity and efficiency, are particularly suitable for embedded devices and IoT scenarios, meeting the requirements of real-time performance and resource management.

[0006] The core idea of ​​round-robin scheduling is to divide CPU time into fixed-length time slices. Each task is allocated a time slice and runs sequentially according to the order of the ready queue. In the HarmonyOS kernel, the default time slice length is 20ms. When a task's time slice expires, the scheduler switches the task from the running state to the ready state and selects the next task in the ready queue to run. If a task needs to wait for resources or events during its execution, it will be suspended in the blocking queue (pendList) until the blocking condition is resolved before re-entering the ready queue.

[0007] The advantages of this scheduling method lie in its fairness and simplicity, making it particularly suitable for tasks with unpredictable execution times. It ensures that each task receives CPU resources in turn, avoiding the "starvation" phenomenon caused by some tasks occupying the CPU for extended periods. Furthermore, by flexibly adjusting the time slice length, this scheduling strategy can meet the needs of tasks with different priorities, achieving a good balance between real-time performance and system response speed.

[0008] The core idea of ​​the FIFO scheduling strategy is to execute tasks in the order they arrive. For tasks of the same priority, the system runs them according to the first-in, first-out rule. This single scheduling strategy can lead to efficiency problems in some situations. Especially in real-time task scenarios, the simplicity of FIFO scheduling can cause more serious problems. For example, when there are many high-priority real-time task instances, if one instance occupies CPU resources for a long time while other tasks of the same priority cannot be scheduled in time, this will directly undermine the system's real-time goal and may cause task timeouts, delays in critical functions, or performance bottlenecks. Although time-slice round-robin scheduling and FIFO scheduling mechanisms themselves do not contain the concept of priority, the kernel still incorporates priority management to enhance the flexibility and real-time performance of scheduling. Each task is assigned a priority at creation, ranging from [0, 31], with smaller numbers indicating higher priority. This priority mechanism does not directly change the scheduling method of RR and FIFO, but indirectly optimizes the scheduling effect by affecting the order in which tasks enter the ready queue and resource contention behavior. When multiple tasks enter the ready queue at the same time, higher-priority tasks will be scheduled to run in advance, thereby ensuring the timely response of critical tasks.

[0009] However, in industrial robot applications, real-time requirements are high, and tasks have multiple characteristics, so the two algorithms mentioned above cannot meet the real-time requirements. Summary of the Invention

[0010] To address the issue of low real-time performance in industrial robot operating systems, this invention proposes an earliest deadline-first task scheduling method based on OpenHarmony.

[0011] The technical solution adopted by the present invention to solve the above problems is as follows: The present invention includes the following steps: Step 1: Calculate the corresponding task T based on the task's static priority and the weights allocated by the parameter quota. i Priority; Step 2: Sort the task queue according to the calculated task priorities and execute the highest priority task; Step 3: When a new task arrives, calculate its priority and compare it with the priority of the currently pending task. If the priority of the new task is greater than the priority of the currently pending task, then preempt the current task. If it is less than the priority, then put the new task back into the corresponding position in the task queue according to its priority. If the priority of the new task is equal to the priority of the pending task, then proceed to step 4. Step 4: Use an optimized time-slice round-robin scheduling algorithm to determine the execution order of new tasks and tasks to be executed, thus completing task scheduling.

[0012] Furthermore, step 1 specifically includes: Set task T i urgency And obtain execution tasks T i Time required C i According to the task T i urgency Computational tasks T i Static priority ; Set resource weight parameters W cpu , W mem and W io Combined with the task T i Required memory resources M i ,Task T i I / O bandwidth requirements IO iand tasks T i CPU utilization U i Computational tasks T i The weight of the parameter quota allocation R i ; Based on task static priority Weights of parameter quota allocation R i Calculate the corresponding task T i priority ; Static priority The calculation formula is: (1); In formula (1), For the task T i The degree of urgency, C i To carry out the mission T i Time required; Weight of parameter quota allocation R i The calculation formula is: (2); In formula (2), CPU utilization for the task; This is the upper limit of the core utilization rate. The memory resources required for task Ti; This represents the total amount of available memory for that core. For the task's I / O bandwidth requirements; This represents the maximum available I / O bandwidth for this core. , and As a resource weight parameter, the influence ratio of various resources can be adjusted according to actual needs to achieve normalization; Task T i priority The calculation formula is: (3); In formula (3), To adjust the coefficient of the static priority of the task, To adjust the coefficients of the task parameter quota, normalization is completed.

[0013] Furthermore, step 2, which involves sorting the task queue based on the calculated task priorities, includes: Step 2.1: Initialize the task queue; Step 2.2: Calculate the priority of each task in the queue according to formula (3); Step 2.3: Sort the array storing tasks in descending order according to task priority; Step 2.4: Assign the sorted task array to the task queue.

[0014] Furthermore, step 4 specifically includes: Step 4.1: Obtain the scheduling queue; Step 4.2: Initialize the maximum number of ready tasks, the minimum time slice, and the time slice range difference; Step 4.3: Obtain the number of ready tasks with the current priority from the scheduling queue; Step 4.4: If the number of ready tasks with the current priority is greater than the maximum number of ready tasks, it indicates that the task load is high. In this case, a smaller time slice is allocated for time slice round-robin scheduling to reduce the CPU time occupied by a single task. Otherwise, it indicates that the task load is low. In this case, a larger time slice is allocated to reduce the context switching overhead caused by frequent task switching. Step 4.5: Return the calculated time slice size.

[0015] The beneficial effects of this invention are: 1. This invention integrates the CPU utilization of a task, the I / O bandwidth requirements of a task, and the priority of the computational task based on the required memory resources, thereby normalizing the changes in cache utilization and maintaining a high level of resource utilization.

[0016] 2. During task scheduling, the I / O bandwidth requirements and memory resources required by the task are superior to those of existing algorithms. It has a better resource allocation scheme and task execution capability. Even under high load and complex resource requirements, the present invention can still allocate resources to more urgent tasks more reasonably, showing better scheduling performance and efficiency. Attached Figure Description

[0017] Figure 1 A flowchart illustrating the earliest deadline-first task scheduling method based on OpenHarmony provided by this invention. Figure 2 A flowchart illustrating the computational task queue order provided by this invention; Figure 3 This invention provides a schematic diagram illustrating the processing when a new task arrives. Figure 4 A flowchart illustrating the optimized time-slice round-robin scheduling algorithm provided by this invention; Figure 5This diagram illustrates the comparison of CPU, memory, and IO utilization between the present invention and the traditional EDF scheduling algorithm under the high-pressure environment simulated by QEMU. Detailed Implementation

[0018] Combination Figure 1-5 This implementation method is described as follows: Figure 1 As shown, the steps of the earliest deadline-first task scheduling method based on OpenHarmony described in this embodiment include: S1: Calculate the priority of the task; Set task T i urgency And obtain execution tasks T i Time required C i According to the task T i urgency Computational tasks T i Static priority : (1); In formula (1), For the task T i The degree of urgency, C i To carry out the mission T i Time required; Set resource weight parameters W cpu , W mem and W io Combined with the task T i Required memory resources M i ,Task T i I / O bandwidth requirements IO i and tasks T i CPU utilization U i Computational tasks T i The weight of the parameter quota allocation R i : (2); In formula (2), CPU utilization for the task; This is the upper limit of the core utilization rate. The memory resources required for task Ti; This represents the total amount of available memory for that core. For the task's I / O bandwidth requirements; This represents the maximum available I / O bandwidth for this core. , and As a resource weight parameter, the influence ratio of various resources can be adjusted according to actual needs to achieve normalization; Based on task static priority Weights of parameter quota allocation R i Calculate the corresponding task T i priority : (3); In formula (3), To adjust the coefficient of the static priority of the task, To adjust the coefficients of the task parameter quota, normalization is completed.

[0019] S2: Sort the task queue according to task priority; like Figure 2 As shown, the steps for calculating the task queue order include: S201: Obtain a series of tasks T that need to be executed. i ; S202: Initialize the task queue; S203: Calculate the task priority for each task. ; S204: Sort the array storing tasks in descending order according to task priority; S205: Assign the sorted task array to the task queue.

[0020] S206: Return to the task queue.

[0021] S3: When a new task arrives, decide whether to preempt the currently pending task based on its priority; When a new task Tnew arrives, the system determines whether to preempt the current task Tcurr: P(Tnew) > P(Tcurr). If the condition is met, the current task is preempted, and Tcurr is returned to the task queue. Figure 3 As shown, the specific steps of the algorithm for handling new tasks upon arrival are as follows: S301: Receive the new task that has arrived; S302: Calculate the task priority of the new task; S303: If the remaining execution time of the new task is less than the remaining execution time of the currently executing task and the priority of the new task is greater than the priority of the current task, then interrupt the current task, return it to the task queue, sort it, and then execute the new task; otherwise, insert the new task into the task queue and sort it.

[0022] S4: If the priority of the new task is equal to the priority of the current task to be executed, then the optimized time-slice round-robin scheduling algorithm is used to determine the execution order of the new task and the task to be executed, thus completing the task scheduling.

[0023] like Figure 4 As shown, the steps of the optimized time-slice round-robin scheduling algorithm include: S401: Obtain the scheduling queue; S402: Initialize the maximum number of ready tasks, minimum time slice, and time slice range difference; S403: Retrieve the number of ready tasks with the current priority from the scheduling queue; S404: If the number of ready tasks with the current priority is greater than the maximum number of ready tasks, it indicates that the task load is high. In this case, a smaller time slice is allocated for time slice round-robin scheduling to reduce the CPU time occupied by a single task, ensuring that more tasks can get execution opportunities in time and avoiding task starvation. Otherwise, it indicates that the task load is low. A larger time slice is allocated to reduce the context switching overhead caused by frequent task switching, thereby improving the overall execution efficiency and throughput of the system. S405: Returns the calculated time slice size.

[0024] To verify the real-time performance of the task scheduling method proposed in this invention, this embodiment compares the CPU, memory, and I / O utilization of the traditional EDF scheduling algorithm and the MFFEDF algorithm of this invention under a high-pressure environment simulated by QEMU. The comparison results are as follows: Figure 5 As shown, by Figure 5 We can conclude that: according to Figure 5 As shown in the first subgraph, the MFFEDF algorithm proposed in this invention exhibits high CPU utilization compared to the traditional EDF algorithm under conditions of limited system resources. However, because the MFFEDF algorithm handles more priority calculations than the traditional EDF method, its CPU utilization is slightly lower. From Figure 5The second subgraph shows that, under the same workload, MFFEDF exhibits a gradual decrease in cache resource utilization over time, while still maintaining a relatively high overall utilization rate. In contrast, the cache utilization rate of the traditional EDF algorithm changes more randomly, making it difficult to maintain a high resource utilization rate. This indicates that when the task load distribution is uneven, the cache resource utilization rate of the traditional EDF is also relatively random, and cache resources cannot be fully utilized. From... Figure 5 The third subgraph shows that MFFEDF maintains a high level of IO resource utilization, indicating that this method offers superior resource allocation and task execution capabilities. In contrast, the IO utilization performance of the traditional EDF algorithm, as seen in the MU experiment, is relatively random. Therefore, we can conclude that, under resource constraints, MFFEDF can more rationally prioritize resource allocation to more urgent tasks compared to traditional EDF, thus demonstrating better scheduling performance and efficiency under high load and complex resource requirements.

[0025] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent substitutions, and improvements made to the above embodiments without departing from the scope of the present invention, based on the technical essence of the present invention and within the spirit and principles of the present invention, shall still fall within the protection scope of the present invention.

Claims

1. A task scheduling method based on OpenHarmony with earliest due date first, characterized in that, include: Step 1: Calculate the corresponding task T based on the task's static priority and the weights allocated by the parameter quota. i priority ; Step 2: Sort the task queue according to the calculated task priorities; Step 3: When a new task arrives, calculate its priority and compare it with the priority of the currently pending task. If the priority of the new task is greater than the priority of the currently pending task, then preempt the current task. If it is less than the priority, then put the new task back into the corresponding position in the task queue according to its priority. If the priority of the new task is equal to the priority of the pending task, then proceed to step 4. Step 4: Use an optimized time-slice round-robin scheduling algorithm to determine the execution order of new tasks and tasks to be executed, thus completing task scheduling.

2. The earliest deadline-first task scheduling method based on OpenHarmony according to claim 1, characterized in that, Step 1 specifically includes: Set task T i urgency And obtain execution tasks T i Time required C i According to the task T i urgency Computational tasks T i Static priority ; Set resource weight parameters W cpu , W mem and W io Combined with the task T i Required memory resources M i ,Task T i I / O bandwidth requirements IO i And tasks T i CPU utilization U i Computational tasks T i The weight of the parameter quota allocation R i ; Based on task static priority Weights of parameter quota allocation R i Calculate the corresponding task T i priority ; Static priority The calculation formula is: (1); In formula (1), For the task T i The degree of urgency, C i To carry out the mission T i Time required; Weight of parameter quota allocation R i The calculation formula is: (2); In formula (2), CPU utilization for the task; This is the upper limit of the core utilization rate; The memory resources required for task Ti; This represents the total available memory for that core. For the task's I / O bandwidth requirements; This represents the maximum available I / O bandwidth for this core. , and As a resource weight parameter, the influence ratio of various resources can be adjusted according to actual needs to achieve normalization; Task T i priority The calculation formula is: (3); In formula (3), To adjust the coefficient of the static priority of the task, To adjust the coefficients of the task parameter quotas, normalization is completed.

3. The earliest deadline-first task scheduling method based on OpenHarmony according to claim 1, characterized in that, Step 2, which involves sorting the task queue based on the calculated task priorities, includes: Step 2.1: Initialize the task queue; Step 2.2: Calculate the priority of each task in the queue according to formula (3); Step 2.3: Sort the array storing tasks in descending order according to task priority; Step 2.4: Assign the sorted task array to the task queue.

4. The earliest deadline-first task scheduling method based on OpenHarmony according to claim 1, characterized in that, Step 4 specifically includes: Step 4.1: Obtain the scheduling queue; Step 4.2: Initialize the maximum number of ready tasks, the minimum time slice, and the time slice range difference; Step 4.3: Obtain the number of ready tasks with the current priority from the scheduling queue; Step 4.4: If the number of ready tasks with the current priority is greater than the maximum number of ready tasks, it indicates that the task load is high. In this case, a smaller time slice is allocated for time slice round-robin scheduling to reduce the CPU time occupied by a single task. Otherwise, it indicates that the task load is low. In this case, a larger time slice is allocated to reduce the context switching overhead caused by frequent task switching. Step 4.5: Return the calculated time slice size.