Search

CN-121979624-A - Hierarchical scheduling algorithm based on LSTM prediction threshold

CN121979624ACN 121979624 ACN121979624 ACN 121979624ACN-121979624-A

Abstract

The invention discloses a hierarchical scheduling algorithm based on LSTM prediction threshold in the technical field of computer task scheduling, which comprises the steps of acquiring the load rate of an operating system when detecting that a real-time task exists; and if the margin of the next task is larger than or equal to zero, executing inertia context switching when the priority of the next task is larger than the priority threshold of the current task acquired in real time and the priority of the next task is inconsistent with the current task, and ending the process when the priority of the next task is smaller than or equal to the priority threshold of the current task acquired in real time. The method and the system can solve the technical problems that the existing dynamic priority scheduling algorithm has a large number of tasks for preempting and switching under the complex load scene of the active power distribution network feeder terminal, so that the context switching overhead is increased and the system efficiency is affected.

Inventors

  • LIU SHEN
  • WANG YANPENG
  • YAN QI
  • LIANG WEICHEN
  • ZHAO LIPING
  • LI RUIRUI
  • JI YINGDONG
  • CHANG XIAOXU
  • QI XIAOXIA
  • WANG YUMENG
  • WU SIXUE

Assignees

  • 国网冀北电力有限公司张家口供电公司

Dates

Publication Date
20260505
Application Date
20251127

Claims (8)

  1. 1. The hierarchical scheduling algorithm based on the LSTM prediction threshold is realized on the basis of a Linux system, and is characterized by comprising the following steps of: When detecting that a real-time task exists, acquiring the load rate of an operating system; selecting a next task according to the relation between the load rate of the operating system and a preset threshold value; And if the margin of the next task is greater than or equal to zero, when the priority of the next task is greater than the priority threshold of the current task acquired in real time and the next task is inconsistent with the current task, performing inertia context switching, and ending the process when the priority of the next task is less than or equal to the priority threshold of the current task acquired in real time.
  2. 2. The LSTM prediction threshold based hierarchical scheduling algorithm according to claim 1, further comprising: when no real-time task is detected, selecting a next task from the active array, and executing inertia context switching when the next task is inconsistent with the current task; when the next task is consistent with the current task, the flow ends.
  3. 3. The LSTM prediction threshold based hierarchical scheduling algorithm according to claim 1, further comprising: and if the margin of the next task is smaller than zero, triggering a task failure mechanism, re-acquiring the load rate of the operating system, and re-selecting the next task according to the relation between the re-acquired load rate of the operating system and a preset threshold value until the margin of the re-selected next task is larger than or equal to zero.
  4. 4. The LSTM prediction threshold based hierarchical scheduling algorithm of claim 1, wherein obtaining the priority threshold of the current task in real-time comprises: acquiring priority threshold data; calculating a dynamic baseline according to the priority threshold data; And calculating a predicted deviation degree based on a normalized priority predicted value output by the pre-trained LSTM model and the dynamic baseline, and generating a priority threshold of the current task based on the predicted deviation degree.
  5. 5. The LSTM prediction threshold based hierarchical scheduling algorithm according to claim 1, wherein selecting the next task according to a relationship between a load rate of the operating system and a preset threshold comprises: when the load rate of the operating system exceeds a preset threshold, selecting a next task from a key task queue; and when the load rate of the operating system does not exceed a preset threshold value, selecting a next task from the emergency task queue.
  6. 6. The hierarchical scheduling algorithm based on LSTM prediction threshold according to claim 1 or 2, characterized in that performing lazy context switching comprises: Acquiring information of all registers of a CPU, and screening an unconventional register as an inert object; Scanning code paths of all tasks to generate a resource usage bit chart of each task; storing the resource use bitmap into a special section of an ELF file, and loading the resource use bitmap into a memory when an RTOS is started; When the task corresponding to the resource use bitmap table triggers an exception for the first time using the unconventional register, the unconventional register state of the last task is saved.
  7. 7. The hierarchical scheduling algorithm for LSTM prediction threshold according to claim 1, further comprising: Removing the high-precision timer in the Linux system overtime before the next system clock interruption from the original queue at the lower half part of each Linux system clock interruption process, and inserting the high-precision timer into an event scheduling queue of the high-precision timer; wherein all timers in the event scheduling queue will timeout before the next Linux system clock interrupt.
  8. 8. The hierarchical scheduling algorithm for LSTM prediction threshold according to claim 7, further comprising: After setting the timeout time for the clock chip, when the timeout event is captured by the clock interrupt processing program, recalculating and setting the next timeout time in microseconds according to the real-time task requirement; The method comprises the steps of obtaining a clock source abstract layer maintained by a current time interface, providing a standardized time access interface for a timing module of a Linux system, supporting calculation of time intervals between any historical time points and current time, and replacing an original periodic clock of the Linux system by interruption through dynamic generated by a high-precision timer timing point in the Linux system to realize microsecond timing precision; And the control system dynamically switches the clock source in the operation stage through the clock source abstraction layer of the Linux system.

Description

Hierarchical scheduling algorithm based on LSTM prediction threshold Technical Field The invention relates to the technical field of computer task scheduling, in particular to a hierarchical scheduling algorithm based on an LSTM prediction threshold. Background In the operation of the active power distribution network, the novel feeder terminal needs to process a large number of real-time tasks, such as fault detection, data acquisition, control instruction response and the like. However, the precision (millisecond level) of the traditional Linux kernel clock is difficult to meet microsecond real-time task timing requirements, and the existing dynamic priority scheduling algorithms such as EDF (Earliest-demand-First, earliest Deadline First) and LSF (Least Slack-First, minimum Slack-First) are large in task preemption and switching under the complex load scene of the active power distribution network feeder terminal, so that the context switching overhead is increased, and the system efficiency is affected. Therefore, a hierarchical scheduling algorithm based on LSTM prediction threshold is needed to solve the above technical problems. Disclosure of Invention The invention aims to overcome the defects in the prior art, provides a hierarchical scheduling algorithm based on an LSTM prediction threshold, and can solve the technical problems that the existing dynamic priority scheduling algorithm has a large number of tasks to preempt and switch under the complex load scene of an active power distribution network feeder terminal, so that the context switching overhead is increased and the system efficiency is affected. In order to achieve the above purpose, the invention is realized by adopting the following technical scheme: In a first aspect, the present invention provides a hierarchical scheduling algorithm based on LSTM prediction threshold, implemented based on a Linux system, including: When detecting that a real-time task exists, acquiring the load rate of an operating system; selecting a next task according to the relation between the load rate of the operating system and a preset threshold value; And if the margin of the next task is greater than or equal to zero, when the priority of the next task is greater than the priority threshold of the current task acquired in real time and the next task is inconsistent with the current task, performing inertia context switching, and ending the process when the priority of the next task is less than or equal to the priority threshold of the current task acquired in real time. Further, the method further comprises the following steps: when no real-time task is detected, selecting a next task from the active array, and executing inertia context switching when the next task is inconsistent with the current task; when the next task is consistent with the current task, the flow ends. Further, the method further comprises the following steps: and if the margin of the next task is smaller than zero, triggering a task failure mechanism, re-acquiring the load rate of the operating system, and re-selecting the next task according to the relation between the re-acquired load rate of the operating system and a preset threshold value until the margin of the re-selected next task is larger than or equal to zero. Further, acquiring the priority threshold of the current task in real time includes: Acquiring priority threshold data in a plurality of periods; Calculating a dynamic baseline from the priority threshold data: And calculating a predicted deviation degree based on a normalized priority predicted value output by the pre-trained LSTM model and the dynamic baseline, and generating a priority threshold of the current task based on the predicted deviation degree. Further, selecting the next task according to the relationship between the load rate of the operating system and a preset threshold value includes: when the load rate of the operating system exceeds a preset threshold, selecting a next task from a key task queue; and when the load rate of the operating system does not exceed a preset threshold value, selecting a next task from the emergency task queue. Further, performing the lazy context switch includes: Acquiring information of all registers of a CPU, and screening an unconventional register as an inert object; Scanning code paths of all tasks to generate a resource usage bit chart of each task; storing the resource use bitmap into a special section of an ELF file, and loading the resource use bitmap into a memory when an RTOS is started; When the task corresponding to the resource use bitmap table triggers an exception for the first time using the unconventional register, the unconventional register state of the last task is saved. Further, the method further comprises the following steps: Removing the high-precision timer in the Linux system overtime before the next system clock interruption from the original queue at the lower half part of each Linux system