Self-adaptive priority dynamic adjustment method and system for system threading interruption

By monitoring the running statistics of interrupted threads, the interrupt handling method and priority are dynamically adjusted, which solves the problems of delay overhead and priority inversion in real-time system interrupt handling, improves the system's adaptability and stability, and adapts to the needs of more complex application scenarios.

CN121833199APending Publication Date: 2026-04-10GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
Filing Date
2025-12-31
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing technologies, real-time system interrupt handling suffers from unnecessary latency overhead, implicit priority inversion, and a lack of adaptive capabilities, which particularly affects system performance and determinism in complex application scenarios.

Method used

An adaptive priority dynamic adjustment method is provided. By monitoring the running statistics of interrupted threads, the interrupt handling method is dynamically determined using a preset rule model or machine learning model. The priority of interrupted threads is adjusted according to the interrupt frequency and execution time, and hardware interrupt or threaded interrupt method is adopted to avoid indiscriminate handling.

Benefits of technology

It improves the performance and stability of real-time systems in complex application scenarios, reduces scheduling overhead, avoids frequent interruptions of high-priority tasks, enhances the system's adaptability, and ensures real-time response of critical tasks and system robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833199A_ABST
    Figure CN121833199A_ABST
Patent Text Reader

Abstract

The invention provides a self-adaptive priority dynamic adjustment method and system for system threading interruption, and the method comprises the steps: monitoring all interrupted threads running in a real-time system, and obtaining running statistical data of all interrupted threads, the running statistical data at least comprising interruption occurrence frequency and interruption average execution time; analyzing the operation statistical data based on a pre-constructed dynamic decision model, and determining a processing mode of each interrupt thread, the processing mode being a hard interrupt mode or a threading interrupt mode; if it is determined that the processing mode of the interrupt thread is a threading interrupt mode, adjusting the priority of the interrupt thread based on a preset interrupt thread priority dynamic adjustment strategy; according to the method, different types of interrupts can be intelligently distinguished, and the situation that all interrupts are subjected to undifferentiated threading is avoided, so that the certainty of key tasks is guaranteed, meanwhile, unnecessary real-time system overhead is reduced, and the overall performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of interrupt processing of real-time systems, and particularly relates to an adaptive priority dynamic adjustment method and system for system thread interrupt. BACKGROUND

[0002] In a real-time system, interrupt processing is a core issue. A sudden hardware interrupt usually preempts any task currently being executed, including a real-time task with the highest priority. If the interrupt processing program takes too long to execute, it will cause the real-time task to miss its deadline, affecting the determinacy of the system.

[0003] In order to solve the above problems, the PREEMPT_RT represented real-time Linux kernel introduces an interrupt thread technology, that is, the lower half of most interrupt processing is executed as a normal kernel thread, so that the interrupt processing can be preempted by a task with a higher priority.

[0004] However, the prior art mainly relies on a statically configured interrupt thread strategy. Whether it is the default complete thread or the manual configuration of CPU affinity and priority through the irq interface, this static strategy of "one size fits all" has the following obvious disadvantages in complex application scenarios: 1. Unnecessary delay overhead: For interrupts with extremely short execution time and extremely high frequency (such as timers and high-speed network card packet reception), the context switching and scheduling delay introduced by threadization actually reduces system performance.

[0005] 2. Implicit priority inversion: The priority of an interrupt thread is usually fixed (for example, the default priority level is 50). When a low-priority disk I / O interrupt thread preempts a high-priority (for example, priority level 90) real-time task, the interrupt thread itself may be preempted by a medium-priority (for example, priority level 60) task, causing the high-priority real-time task to be indirectly blocked, which seriously affects the real-time performance.

[0006] 3. Lack of adaptive ability: The system cannot dynamically adjust the interrupt strategy according to the current load state (idle or busy) and running mode (pursuing low delay or high determinacy).

[0007] Therefore, there is an urgent need for an adaptive priority dynamic adjustment method and system for system thread interrupt to solve one or more of the above technical problems. SUMMARY

[0008] The purpose of the present application is to provide an adaptive priority dynamic adjustment method and system for system thread interrupt.

[0009] According to a first aspect of the present application, there is provided an adaptive priority dynamic adjustment method for system threaded interrupt, comprising: Step S1: monitoring all interrupt threads running in a real-time system, and obtaining running statistical data of all interrupt threads, wherein the running statistical data at least includes interrupt occurrence frequency and interrupt average execution time; Step S2: analyzing the obtained running statistical data based on a pre-constructed dynamic decision model, and determining the processing mode of each interrupt thread, wherein the processing mode is a hard interrupt mode or a threaded interrupt mode; Step S3: if it is determined that the processing mode of the interrupt thread is the threaded interrupt mode, adjusting the priority of the interrupt thread based on a pre-set interrupt thread priority dynamic adjustment strategy.

[0010] Optionally, in the step S1, the running statistical data is recorded by extending an interrupt descriptor structure of a kernel.

[0011] Optionally, in the step S2, the dynamic decision model is a pre-set rule model or a machine learning model established based on historical load data and historical interrupt running data.

[0012] Optionally, in the step S2, when the dynamic decision model is the pre-set rule model, determining the processing mode of each interrupt thread specifically comprises: if the interrupt occurrence frequency of the interrupt thread is higher than a first frequency threshold and the interrupt average execution time of the interrupt thread is lower than a first execution time threshold, determining that the interrupt thread adopts the hard interrupt mode; if the interrupt occurrence frequency of the interrupt thread is lower than a second frequency threshold and the interrupt average execution time of the interrupt thread is higher than a second execution time threshold, determining that the interrupt thread adopts the threaded interrupt mode.

[0013] Optionally, in the step S2, when the dynamic decision model is the pre-set rule model, determining the processing mode of each interrupt thread further comprises: when the real-time system is in a high determinacy mode, reducing the second execution time threshold to increase the number of interrupt threads determined to adopt the threaded interrupt mode.

[0014] Optionally, in the step S3, the interrupt thread priority dynamic adjustment strategy is: when it is detected that a current interrupt thread is in a ready state and is about to preempt a real-time task being run, adjusting the priority of the current interrupt thread according to the relationship between the priority of the current interrupt thread and the current priority of the real-time task being run.

[0015] Optionally, the step S3 specifically comprises: when it is detected that the current interrupt thread is in a ready state and a wake-up source of the current interrupt thread is about to perform an interrupt on a running real-time task; obtaining a current priority of the running real-time task and a priority of the current interrupt thread; if the priority of the current interrupt thread is less than the current priority of the running real-time task, adjusting the priority of the current interrupt thread to the current priority of the running real-time task; when the current interrupt thread is about to sleep after completing execution, restoring the priority of the current interrupt thread to the priority before adjustment.

[0016] According to a second aspect of the present application, there is provided an adaptive priority dynamic adjustment system for system thread interrupt, comprising: a first processing module configured to monitor all interrupt threads running in a real-time system and obtain running statistical data of all interrupt threads, wherein the running statistical data at least includes interrupt occurrence frequency and interrupt average execution time; a second processing module configured to analyze the obtained running statistical data based on a pre-constructed dynamic decision model to determine a processing mode of each interrupt thread, wherein the processing mode is a hard interrupt mode or a thread interrupt mode; a third processing module configured to, if it is determined that the processing mode of the interrupt thread is the thread interrupt mode, adjust a priority of the interrupt thread based on a pre-set interrupt thread priority dynamic adjustment strategy.

[0017] According to a third aspect of the present application, there is provided an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor, when executing the computer program, implements the steps of any one of the adaptive priority dynamic adjustment methods for system thread interrupt according to the first aspect of the present application.

[0018] According to a fourth aspect of the present application, there is provided a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps of any one of the adaptive priority dynamic adjustment methods for system thread interrupt according to the first aspect of the present application.

[0019] The present application has the following beneficial effects: As can be seen from the above solutions, the present application provides an adaptive priority dynamic adjustment method and system for system thread interrupt, which has the following beneficial effects: The application provides a kind of adaptive priority dynamic adjustment method for system thread interruption, the occurrence frequency and average execution time of interruption thread are judged by preset rule model in two dimensions, intelligently distinguish two kinds of interruption of high frequency short time and low frequency long time, respectively adapt hard interruption and thread interruption mode, avoid the indiscriminate thread processing of all interruptions, both use hard interruption to guarantee the quick response of high frequency key interruption, and avoid the exclusive block of long time interruption to CPU by thread interruption, while ensuring the determinacy of key task execution, reduce unnecessary real-time system scheduling overhead, comprehensively improve the overall operation performance of real-time system;Secondly, for the preemption conflict of interruption thread and real-time task, by the strategy of dynamically adjusting the priority of interruption thread, when the interruption thread is about to preempt the running real-time task, accurate adaptation is carried out according to the priority relationship between the two, the frequent interruption of non-key interruption thread to high priority real-time task is avoided, the total time of high priority task being interrupted is shortened, so as to effectively reduce the worst case execution time, guarantee the timeliness and stability of real-time task;Finally, it has strong adaptive ability, whether it is through the classification and adaptation of preset rule model to interruption processing mode, or the threshold value dynamic adjustment of real-time system in high determinacy mode, or the real-time optimization of interruption thread priority, can flexibly cope with sudden interruption storm or dynamically changing system load mode, avoid the problems of block, delay fluctuation and other problems of real-time system under fixed processing mode, significantly enhance the stability and robustness of real-time system operation, so that it can adapt to the needs of more complex application scenarios. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 A flowchart of an adaptive priority dynamic adjustment method for system thread interruption according to an embodiment is provided. Figure 2 An implementation process diagram of an adaptive priority dynamic adjustment method for system thread interruption according to an embodiment is provided. Figure 3 A structure diagram of an adaptive priority dynamic adjustment system for system thread interruption according to an embodiment is provided. Figure 4 An electronic device diagram according to an embodiment is provided. DETAILED DESCRIPTION

[0021] To make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0022] According to a first aspect of the present application, there is provided an adaptive priority dynamic adjustment method for system thread interrupt, as shown in Figure 1 , the method comprises, Step S1: monitoring all interrupt threads running in the real-time system, and obtaining running statistical data of all interrupt threads, wherein the running statistical data at least includes interrupt occurrence frequency and interrupt average execution time; Step S2: analyzing the obtained running statistical data based on a pre-constructed dynamic decision model, and determining the processing mode of each interrupt thread, wherein the processing mode is a hard interrupt mode or a thread interrupt mode; Step S3: if it is determined that the processing mode of the interrupt thread is the thread interrupt mode, adjusting the priority of the interrupt thread based on a pre-set interrupt thread priority dynamic adjustment strategy.

[0023] Optionally, in the adaptive priority dynamic adjustment method for system thread interrupt, the running statistical data is recorded by extending the interrupt descriptor structure of the kernel.

[0024] Specifically, as shown in Figure 2 , in the embodiment, a lightweight kernel module is set in the real-time system as an interrupt behavior monitor to monitor the behavior of the interrupt thread and obtain interrupt running information, and the kernel module extends the interrupt descriptor structure (irq_desc) of the kernel. For each interrupt vector in the interrupt descriptor, a set of statistical fields is added to record the running statistical data.

[0025] In the embodiment, the running statistical data includes other data in addition to the interrupt occurrence frequency and the interrupt average execution time, and the specific contents include the following: The interrupt occurrence frequency frequency represents the occurrence frequency of the interrupt in a unit of time.

[0026] The interrupt average execution time avg_execution_time represents the average execution time of the interrupt handler.

[0027] The maximum execution time max_execution_time represents the maximum execution time of the interrupt handler.

[0028] Preemption statistics, preemption_stats, is a data structure that records which priority tasks are preempted by interrupt threads and the number of preemptions. In Linux systems, preemption-related statistics can be viewed through kernel debugging interfaces or performance tools. Preemption statistics include: process preemption counter, which indicates whether the current process can be preempted; preemption frequency: the total number of times high-priority tasks preempt low-priority tasks per unit of time; preemption delay: the time difference from when a high-priority task is ready to when it actually gets the CPU.

[0029] Optionally, in the adaptive priority dynamic adjustment method for system threadization of interrupts according to an embodiment of the present application, the dynamic decision model is a preset rule model or a machine learning model established based on historical load data and historical interrupt running data.

[0030] Specifically, the pre-constructed dynamic decision model in the embodiment can be a preset rule model formulated according to developer experience, which includes specific decision logic, such as: decision logic includes system mode determination, interrupt classification and processing method rules, and special processing rules, etc. Of course, the pre-constructed dynamic decision model can also be a machine learning model established based on historical load data and historical interrupt running data. The machine learning model predicts the performance gain or loss that may be brought by threadization of a certain interrupt under a specific system load by learning historical data, thereby making more refined decisions.

[0031] Optionally, in the adaptive priority dynamic adjustment method for system threadization of interrupts according to an embodiment of the present application, when the dynamic decision model is a preset rule model, determining the processing method of each interrupt thread specifically includes: if the interrupt occurrence frequency of the interrupt thread is higher than a first frequency threshold and the interrupt average execution time of the interrupt thread is lower than a first execution time threshold, it is determined that the interrupt thread adopts a hard interrupt method; if the interrupt occurrence frequency of the interrupt thread is lower than a second frequency threshold and the interrupt average execution time of the interrupt thread is higher than a second execution time threshold, it is determined that the interrupt thread adopts a threadized interrupt method.

[0032] Specifically, the hard interrupt method belongs to a fast response mechanism in the kernel mode, and the processing process will shield other interrupts. Its advantage is that the response delay is extremely low, and its disadvantage is that it cannot be preempted when occupying the CPU core, and long-time processing will block other tasks. Threadized interrupt is to encapsulate the interrupt processing logic as a kernel thread, which can participate in the priority scheduling of the system. Its advantage is that it supports preemption and will not block the CPU for a long time. Its disadvantage is that the scheduling overhead is slightly higher than that of hard interrupt, and the response delay is slightly larger.

[0033] The determination condition of the hard interrupt mode in the embodiment is that the interrupt occurrence frequency is higher than the first frequency threshold and the average execution time of the interrupt is lower than the first execution time threshold, that is, the strategy of using the hard interrupt for high frequency and short time consumption; and the determination condition of the thread interrupt mode is that the interrupt occurrence frequency is lower than the second frequency threshold and the average execution time of the interrupt is higher than the second execution time threshold, that is, the strategy of using the thread interrupt for low frequency and long time consumption. The method of the embodiment realizes the maximization of processing efficiency by accurately matching the interrupt characteristics, that is, the hard interrupt mode is used for the high frequency and short time consumption interrupt, the processing can be completed with the minimum response delay, the thread interrupt mode is used for the low frequency and long time consumption interrupt, the interrupt can be converted into a schedulable kernel thread, the real-time system can dynamically schedule according to the task priority, the complete processing of the interrupt is ensured, and the execution of the high priority task is not blocked; the method of the embodiment reduces the waste of system resources and improves the resource utilization rate, the preset rule model uses the two-dimensional threshold determination, avoids the defects of the one-size-fits-all interrupt processing mode, accurately classifies the two interrupt processing modes, reduces the invalid resource consumption, and improves the utilization rate of the overall CPU and memory; the method of the embodiment guarantees the balance between the real-time and stability of the system, the determination rule of the preset rule model strictly limits the use scenario of the hard interrupt, that is, only used for the high frequency and short time consumption interrupt, the fast response ability of the hard interrupt to the key signal is reserved, and the blocking of the system scheduling by the long time consumption hard interrupt is avoided; meanwhile, the application scenario of the thread interrupt is limited to the low frequency and long time consumption interrupt, through the scheduling preemption mechanism, it is ensured that the real-time system can still respond to other high priority requirements when processing complex interrupt tasks.

[0034] Optionally, in the adaptive priority dynamic adjustment method for system thread interrupt, when the dynamic decision model is the preset rule model, the processing mode of each interrupt thread further includes: when the real-time system is in a high determinacy mode, the second execution time threshold is reduced to increase the number of interrupt threads determined to use the thread interrupt mode.

[0035] In this embodiment, when the real-time system is in a high deterministic mode, the number of interrupt threads judged as threaded interrupts is increased by lowering the second execution time threshold. This can accurately adapt to the stringent requirements of system task scheduling controllability and response stability in the high deterministic mode. Lowering the second execution time threshold means that some interrupt threads whose execution time was originally around the original threshold will be included in the category of threaded interrupts. Threaded interrupts have the characteristic of being preempted by the system scheduler and will not block other interrupt requests during processing like hard interrupts. This can avoid the risk of high-priority tasks being blocked due to hard interrupts occupying the CPU for a long time, and can also allow more interrupt threads to execute in an orderly and controllable manner through the scheduling mechanism, reducing system response delay fluctuations caused by the abuse of hard interrupts. This improves the predictability and stability of real-time system interrupt handling in the high deterministic mode and ensures the real-time response capability of critical tasks.

[0036] Specifically, such as Figure 2 As shown, in this embodiment, the dynamic decision model, or dynamic decision engine, is a low-priority kernel worker thread in the real-time system. It is periodically (e.g., once per second) awakened to analyze the global interrupt operation statistics collected by the interrupt behavior monitor.

[0037] For example, when the dynamic decision-making model is a pre-defined rule model, its decision-making logic is as follows: 1. Mode determination: First, check the current real-time mode of the real-time system. The real-time mode can be set by the user through system calls. For example, the real-time mode can be low-latency mode (MODE_LOW_LATENCY) or high-determinism mode (MODE_HIGH_DETERMINISM).

[0038] 2. Next, the interrupted threads are classified and their handling methods are determined, specifically including: Rule 1: If the interrupt frequency of an interrupt thread is greater than the first frequency threshold F1 (e.g., F1 is 10000 Hz) and the average execution time of the interrupt is less than the first execution time threshold T1 (e.g., T1 is 5 μs), then the interrupt thread is determined to be of the latency-sensitive type. In this case, the interrupt thread is forced to run in the traditional hard interrupt (Hard IRQ) mode through the interface irq_set_threaded(false) to obtain the lowest latency.

[0039] Rule 2: If the interruption frequency of an interrupt thread is less than the second frequency threshold F2 (e.g., F2 is 100Hz) and the average execution time of the interrupt is less than the second execution time threshold T2 (e.g., T2 is 100 μs), then the interrupt thread is determined to be a heavy-load type. In this case, the interrupt thread will be forced to become a thread and given a basic priority (e.g., priority 40).

[0040] Rule 3: In other cases, the default interruption thread is threaded, and the priority is set to a preset value, for example, the preset value is 50.

[0041] 3. Special processing: If the real-time system is in the high determinism mode MODE_HIGH_DETERMINISM, the second execution time threshold T2 is reduced, more interruption threads are determined as heavy load type and forced to be threaded, so as to minimize the interference of hard interruption to real-time tasks.

[0042] Optionally, in the adaptive priority dynamic adjustment method for system interruption thread, the interruption thread priority dynamic adjustment strategy is: when it is detected that the current interruption thread is in the ready state and is about to preempt the running real-time task, the priority of the current interruption thread is adjusted according to the relationship between the priority of the current interruption thread and the current priority of the running real-time task.

[0043] In this embodiment, by designing a priority dynamic adjustment mechanism for interruption threads, when an interruption thread affects a real-time task with a higher priority, the priority of the interruption thread is adjusted, which effectively avoids the implicit priority inversion caused by interruption processing.

[0044] Optionally, in the adaptive priority dynamic adjustment method for system interruption thread, the step S3 specifically comprises: When it is detected that the current interruption thread is in the ready state and the wake-up source of the current interruption thread is about to perform interruption on the running real-time task; obtaining the current priority of the running real-time task and the priority of the current interruption thread; if the priority of the current interruption thread is less than the current priority of the running real-time task, the priority of the current interruption thread is adjusted to the current priority of the running real-time task; when the current interruption thread is about to sleep after execution, the priority of the current interruption thread is restored to the priority before adjustment.

[0045] Specifically, referring to Figure 2 The interruption thread priority dynamic adjustment strategy in this embodiment is a real-time priority manager for managing the priority of interruption threads in a real-time system, which is a modification of the kernel scheduler and the interruption entry / exit logic, and is used to realize dynamic adjustment of interruption priority and solve the priority inversion problem. The working process of the interruption thread priority dynamic adjustment strategy is: First, when an interrupt thread IRQ-Thread-X is about to preempt a running real-time task RT-Task-Y, the kernel records the priority of the running real-time task RT-Task-Y as P_Y.

[0046] Secondly, the current priority of the interrupt thread IRQ-Thread-X is recorded as P_X. The kernel immediately compares the two, and if P_X < P_Y, the priority of the interrupt thread IRQ-Thread-X is temporarily raised to P_Y.

[0047] Finally, when the interrupt thread IRQ-Thread-X has finished processing and is about to sleep, the kernel restores its priority to its original base priority P_X.

[0048] In engineering implementation, the priority of the thread can be adjusted by modifying the code of the relevant function, and the priority of the interrupt thread can be adjusted. For example, if the interrupt thread IRQ-Thread-X is to preempt the real-time task RT-Task-Y, the code for modifying the priority of the thread is directly inserted at the entry of the function for preempting the task (such as the switch_to function), and the specific logic of the code is as described above (only the execution priority of the interrupt thread is modified). The exit is the same, and the code is inserted in the function, and the execution logic of the code is the same as the last step of the above workflow (the priority is restored to the base priority).

[0049] The interrupt thread priority dynamic adjustment strategy of the embodiment breaks the limitation that the priority of the interrupt thread is fixed and unchangeable. By dynamically adjusting the priority of the interrupt thread at the key node when the interrupt thread is ready and is about to preempt the real-time task according to the priority relationship between the two, the resource occupation conflict between the interrupt thread and the real-time task can be accurately coordinated, the problem that the non-critical interrupt thread with a too high priority indiscriminately preempts the real-time task, causing the execution of the real-time task to be frequently interrupted and the response timeliness to be damaged is avoided, and the problem that the priority of the interrupt thread is excessively lowered, causing the delay of the processing of the corresponding interrupt request to be too high and system abnormalities to be caused is prevented. Therefore, on the premise of guaranteeing the core demand that the real-time task is stably and efficiently executed, the timeliness of the processing of the interrupt thread is considered, the priority adaptation and resource scheduling balance between the real-time task and the interrupt processing of the real-time system are realized, and the reliability and accuracy of the overall operation of the real-time system are improved.

[0050] According to a second aspect of the present application, an adaptive priority dynamic adjustment system for system thread interrupt is provided, as shown in Figure 3 The system 300 comprises: A first processing module 301 configured to monitor all interrupt threads running in a real-time system and obtain running statistical data of all interrupt threads, wherein the running statistical data at least comprises interrupt occurrence frequency and interrupt average execution time; The second processing module 302 is configured to analyze the obtained running statistical data based on a pre-constructed dynamic decision model to determine a processing mode of each interrupt thread, wherein the processing mode is a hard interrupt mode or a threaded interrupt mode; The third processing module 303 is configured to adjust the priority of the interrupt thread based on a pre-set interrupt thread priority dynamic adjustment strategy if it is determined that the processing mode of the interrupt thread is the threaded interrupt mode.

[0051] It should be noted that the first processing module 301, the second processing module 302 and the third processing module 303 in the embodiment are only exemplary names, and can be named according to the functions implemented, for example, can be named as an interrupt behavior monitor, a decision engine and a real-time priority manager, which are not limited here.

[0052] In summary, the adaptive priority dynamic adjustment method for system threaded interrupt provided by the embodiment of the application achieves the best balance between performance and certainty, effectively reduces the worst-case execution time and significantly enhances the system robustness through multi-dimensional intelligent decision and dynamic adaptation design. The core beneficial effects are as follows: first, the method of the embodiment of the application determines the occurrence frequency and average execution time of the interrupt thread in two dimensions through a pre-set rule model, intelligently distinguishes two types of interrupts, i.e., high-frequency short-time consumption and low-frequency long-time consumption, and adapts to the hard interrupt and the threaded interrupt mode respectively, avoiding indiscriminate threaded processing of all interrupts, which not only guarantees the fast response of high-frequency critical interrupts through the hard interrupt, but also avoids the exclusive blocking of the CPU by long-time consumption interrupts through the threaded interrupt, ensuring the certainty of critical task execution while reducing unnecessary real-time system scheduling overhead, and comprehensively improving the overall performance of the real-time system; second, for the preemption conflict between the interrupt thread and the real-time task, the method of the embodiment of the application precisely adapts to the priority relationship between the two when the interrupt thread is about to preempt the running real-time task through the strategy of dynamically adjusting the priority of the interrupt thread, avoiding the frequent interruption of high-priority real-time tasks by non-critical interrupt threads, shortening the total duration of high-priority tasks being interrupted, and thus effectively reducing the worst-case execution time, ensuring the timeliness and stability of the real-time task; finally, the method of the embodiment of the application has strong adaptability, whether it is the classification and adaptation of the interrupt processing mode through the pre-set rule model, the threshold dynamic adjustment of the real-time system in the high-deterministic mode, or the real-time optimization of the priority of the interrupt thread, it can flexibly cope with sudden interrupt storms or dynamically changing system load modes, avoiding the problems of blocking, delay fluctuation and the like of the real-time system under the fixed processing mode, significantly enhancing the stability and robustness of the system operation, and making it adapt to the needs of more complex application scenarios.

[0053] According to a third aspect of the present application, an electronic device is provided, the electronic device comprising a memory and a processor, the memory storing a computer program, the processor implementing the steps of any one of the methods for adaptive priority dynamic adjustment of system threaded interrupts according to the first aspect of the present application when executing the computer program.

[0054] Figure 4 As shown in the structural diagram of an electronic device according to an embodiment of the present application, Figure 4 the electronic device comprises a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The communication interface of the electronic device is configured to perform wired or wireless communication with an external terminal. The wireless communication can be achieved through WIFI, operator network, near field communication (NFC) or other technologies. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen. The input device of the electronic device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0055] Those skilled in the art can understand that, Figure 4 the structure shown in the above-mentioned figures is only a structural diagram of part related to the technical solution of the present disclosure, and does not constitute a limitation on the electronic device to which the technical solution of the present application is applied. The specific electronic device can include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.

[0056] According to a fourth aspect of the present application, a computer readable storage medium is provided, the computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the steps of any one of the methods for adaptive priority dynamic adjustment of system threaded interrupts according to the first aspect of the present application.

[0057] The above is the preferred embodiment of the present application. It should be noted that for those skilled in the art, without departing from the principle of the present application, a number of improvements and refinements can be made, which should also be considered as the protection scope of the present application.

Claims

1. An adaptive priority dynamic adjustment method for system threaded interrupts, characterized in that, The method includes: Step S1: Monitor all interrupted threads running in the real-time system and obtain the running statistics of all interrupted threads, wherein the running statistics include at least the interruption frequency and the average interruption execution time; Step S2: Analyze the acquired operational statistics based on the pre-built dynamic decision model to determine the processing method for each interrupted thread, wherein the processing method is either a hard interrupt or a threaded interrupt. Step S3: If it is determined that the processing method of the interrupted thread is a threaded interrupt method, the priority of the interrupted thread is adjusted based on the preset dynamic adjustment strategy of interrupted thread priority.

2. The adaptive priority dynamic adjustment method for system threaded interrupts according to claim 1, characterized in that, In step S1, the runtime statistics are recorded by expanding the kernel's interrupt descriptor structure.

3. The adaptive priority dynamic adjustment method for system threaded interrupts according to claim 1, characterized in that, In step S2, the dynamic decision model is a preset rule model or a machine learning model built based on historical load data and historical interruption operation data.

4. The adaptive priority dynamic adjustment method for system threaded interrupts according to claim 3, characterized in that, In step S2, when the dynamic decision model is a preset rule model, determining the processing method for each interrupted thread specifically includes: If the interruption frequency of the interrupted thread is higher than the first frequency threshold and the average execution time of the interrupted thread is lower than the first execution time threshold, then it is determined that the interrupted thread uses a hard interrupt method. If the interruption frequency of the interrupted thread is lower than the second frequency threshold and the average execution time of the interrupted thread is higher than the second execution time threshold, then it is determined that the interrupted thread adopts a threaded interruption method.

5. The adaptive priority dynamic adjustment method for system threaded interrupts according to claim 4, characterized in that, In step S2, when the dynamic decision model is a preset rule model, determining the processing method of each interrupted thread further includes: when the real-time system is in a high deterministic mode, reducing the second execution time threshold to increase the number of interrupted threads determined to use the threaded interrupt method.

6. The adaptive priority dynamic adjustment method for system threaded interrupts according to claim 1, characterized in that, In step S3, the dynamic adjustment strategy for interrupt thread priority is as follows: when it is detected that the current interrupt thread is in a ready state and is about to preempt the running real-time task, the priority of the current interrupt thread is adjusted according to the relationship between the current priority of the interrupt thread and the current priority of the running real-time task.

7. The adaptive priority dynamic adjustment method for system threaded interrupts according to claim 6, characterized in that, Step S3 specifically includes: When it is detected that the current interrupt thread is in a ready state and the wake-up source of the current interrupt thread is about to interrupt the running real-time task; Get the current priority of the running real-time task and the priority of the currently interrupted thread; If the current interrupt thread has a lower priority than the current priority of the running real-time task, then adjust the priority of the current interrupt thread to the current priority of the running real-time task. When the current interrupted thread finishes execution and is about to sleep, restore the current interrupted thread's priority to its original priority.

8. An adaptive priority dynamic adjustment system for threaded interrupts in a system, characterized in that, The system includes: The first processing module is configured to monitor all interrupted threads running in the real-time system and obtain the running statistics of all interrupted threads, wherein the running statistics include at least the interruption frequency and the average interruption execution time. The second processing module is configured to analyze the acquired operational statistics based on a pre-built dynamic decision model to determine the processing method for each interrupted thread, wherein the processing method is a hard interrupt method or a threaded interrupt method. The third processing module is configured to adjust the priority of the interrupted thread based on a preset dynamic adjustment strategy for interrupted thread priority if it is determined that the processing method of the interrupted thread is a threaded interruption method.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the adaptive priority dynamic adjustment method for system threaded interrupts according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the adaptive priority dynamic adjustment method for system threaded interrupts according to any one of claims 1 to 7.