Device state-based interrupt mask dynamic switching method and related device

CN119883540APending Publication Date: 2025-04-25天固信息安全系统(深圳)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411762854.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-03
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The traditional interrupt management mechanism cannot be dynamically adjusted according to changes in device status, making it difficult to balance system performance and power consumption in power consumption sensitive scenarios.

Method used

By obtaining the real-time state parameters of the target device, dynamically determine the device's operating mode, and switch the interrupt mask configuration according to the operating mode to optimize system performance and power consumption.

Benefits of technology

It realizes dynamic adjustment of interrupt mask according to device status, optimizes the balance of system performance and power consumption, and improves the performance and efficiency of equipment under different load conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883540A_ABST
    Figure CN119883540A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to an interrupt mask dynamic switching method based on a device state and a related device, the working mode of the device is judged according to the current working parameter of the device by obtaining the state parameter of the device at the current moment, and when it is detected that the working mode of the device is switched, the device is switched. And the interrupt mask switching is triggered, and the interrupt processing strategy can be flexibly adjusted according to different working modes and equipment states, so that the system performance and the power consumption are optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method for dynamically switching interrupt masks based on device status and related devices. Background Art

[0002] In power-sensitive scenarios such as embedded devices, Internet of Things (IoT) devices, and mobile terminals, devices often need to balance high performance and low power consumption. For example, when the device is in standby mode, power consumption should be reduced as much as possible; while when processing a large number of tasks, performance needs to be improved. Traditional interrupt management mechanisms usually use fixed priorities or simple IRQ / FIQ modes, which cannot be dynamically adjusted according to changes in device status. Summary of the invention

[0003] In order to overcome the deficiencies of the prior art, the present invention provides a method for dynamically switching interrupt masks based on device status and related devices, which dynamically adjust the interrupt mask according to the real-time status of the device to optimize system performance and power consumption.

[0004] A first aspect of the present application provides a method for dynamically switching an interrupt mask based on a device state, the method comprising: Get the status parameters of the target device at the current moment; Determining a first operating mode of the target device at the current moment based on the state parameter; Determine the second working mode of the target device at a previous moment; When it is detected that the target device switches from the second working mode to the first working mode, the interrupt mask configuration of the target device at the current moment is switched.

[0005] In an optional implementation, the switching of the interrupt mask configuration of the target device at the current moment includes: Determining a first interrupt mask corresponding to the first operating mode; Performing a logical OR operation on the first interrupt mask and a predefined critical interrupt mask to obtain a new interrupt mask value; Locking the new interrupt mask value; The locked new interrupt mask value is written into the interrupt control register of the ARM processor of the target device, so that the first interrupt mask updates the second interrupt mask corresponding to the second working mode.

[0006] In an optional implementation, after writing the locked new interrupt mask value into the interrupt control register of the ARM processor of the target device, the method further includes: Verifying the mask state of the new interrupt mask value to determine whether the new interrupt mask value is switched successfully; When it is determined that the switching of the new interrupt mask value fails, the new interrupt mask value is rolled back to the second interrupt mask.

[0007] In an optional implementation, the state parameters include CPU usage, task queue length, and temperature data, and determining the first working mode of the target device at the current moment based on the state parameters includes: When the CPU usage is greater than a first high threshold of a preset usage threshold interval, and the task queue length is greater than a second high threshold of a preset length threshold interval, and the temperature data is greater than a third high threshold of a preset temperature threshold interval, determining that the first working mode is a high load mode; When the CPU usage is less than a first low threshold of the preset usage threshold interval, the task queue length is less than a second low threshold of the preset length threshold interval, and the temperature data is less than a third low threshold of the preset temperature threshold interval, determining that the first working mode is a low power consumption mode; When the target device is not in the high load mode and the low power consumption mode, it is determined that the first operating mode is a normal mode.

[0008] In an optional implementation, the state parameter further includes battery power, and determining the first working mode of the target device at the current moment based on the state parameter includes: When the CPU usage rate is greater than the first high threshold, and the task queue length is greater than the second high threshold, and the temperature data is greater than the third high threshold, and the battery power is greater than the fourth high threshold of the preset power threshold interval, it is determined that the first working mode is a high load mode; When the CPU usage is less than the first low threshold, and the task queue length is less than the second low threshold, and the temperature data is less than the third low threshold, and the battery power is less than the fourth low threshold of the power threshold interval, the first operating mode is determined to be a low power consumption mode.

[0009] In an optional embodiment, the method further comprises: Identifying historical interruption data according to a preset time period to determine whether a target interruption is a high-frequency interruption or a critical interruption, wherein the historical interruption data includes multiple interruptions, and the target interruption is any one of the multiple interruptions; When it is determined that the target interrupt is a high-frequency interrupt and a critical interrupt, increasing the interrupt priority of the target interrupt in the high-load mode; When it is determined that the target interrupt is a high-frequency interrupt, the target interrupt is masked in the low power consumption mode.

[0010] In an optional embodiment, the method further comprises: Determining the triggering number and processing time of the target interrupt; determining an importance score of the target interruption based on the triggering number and the processing time; An interrupt priority level of the target interrupt is adjusted based on the importance score.

[0011] A second aspect of the present application provides an interrupt mask dynamic switching device based on device status, the device comprising: The status monitoring module is used to obtain the status parameters of the target device at the current moment; The state monitoring module is further used to determine the first working mode of the target device at the current moment based on the state parameter; The state monitoring module is further used to determine the second working mode of the target device at a previous moment; The dynamic switching mechanism module is used to switch the interrupt mask configuration of the target device at the current moment when it is detected that the target device switches from the second working mode to the first working mode.

[0012] The third aspect of the present application provides a target device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for dynamically switching interrupt masks based on device status when executing the computer program.

[0013] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for dynamically switching interrupt masks based on device status.

[0014] In summary, the device status-based interrupt mask dynamic switching method and related devices provided in the present application obtain the status parameters of the target device at the current moment to determine the first working mode of the target device at the current moment, and at the same time determine the second working mode of the target device at the previous moment. When it is detected that the target device switches from the second working mode at the previous moment to the first working mode at the current moment, the switching of the interrupt mask configuration will be triggered. By monitoring the device status in real time and dynamically adjusting the interrupt mask configuration accordingly, a balance between system performance and power consumption is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a functional module diagram of a device state-based interrupt mask dynamic switching system shown in an embodiment of the present application; Figure 2 It is a schematic diagram of data flow between modules of a dynamic switching system of interrupt mask based on device status shown in an embodiment of the present application; Figure 3 It is a flowchart of a method for dynamically switching interrupt masks based on device status shown in an embodiment of the present application; Figure 4 is another flow chart of a method for dynamically switching interrupt masks based on device status shown in an embodiment of the present application; Figure 5 It is a functional module diagram of a device state-based interrupt mask dynamic switching device shown in an embodiment of the present application; Figure 6 It is a schematic diagram of the structure of a target device shown in an embodiment of the present application. DETAILED DESCRIPTION

[0016] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0017] The following will clearly and completely describe the concept, specific structure and technical effects of the present invention in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, other embodiments obtained by technicians in this field without creative work are all within the scope of protection of the present invention. In addition, all the connection / connection relationships involved in the patent do not refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features in the invention can be combined interchangeably without conflicting with each other.

[0018] Reference Figure 1 , which is a structural diagram of a device status-based interrupt mask dynamic switching system shown in an embodiment of the present application.

[0019] In an embodiment of the present application, the device status-based interrupt mask dynamic switching system is arranged in the ARM Linux kernel of a target device (e.g., an embedded device, an Internet of Things (IoT) device, an industrial control device, and a computer hardware device, etc.), and includes an interrupt mask dynamic management module. The interrupt mask dynamic management module includes a status monitoring module, a mask preset configuration module, a dynamic switching mechanism module, and a historical data optimization module.

[0020] Combined Figure 2The state monitoring module is used to monitor the state parameters of the device in real time, such as CPU usage, temperature sensor data, and battery power, etc., and can determine the working mode of the device at the current moment based on the monitored state parameters, and send the current working mode to the dynamic switching mechanism mode, so that the dynamic switching mechanism module performs the switching of the corresponding interrupt mask based on the current working mode. Specifically, after determining the current working mode, the dynamic switching mechanism module obtains the interrupt mask corresponding to the current working mode from the mask preset configuration module, and uses the interrupt mask corresponding to the current working mode to update the interrupt mask corresponding to the previous working mode.

[0021] The historical data optimization module is used to record, store and process the CPU's working status data over a period of time in the past, including interrupt processing data, working mode switching, etc. After the interrupt processing data is obtained, the interrupt mask configuration can be optimized based on the interrupt processing data to improve the efficiency of interrupt processing and the stability of the system. Furthermore, the historical data optimization module can also write the updated interrupt mask into the mask preset configuration module, so that the dynamic switching mechanism mode can obtain the interrupt mask corresponding to the current working mode from the mask preset configuration module. The device status-based interrupt mask dynamic switching system also includes an interrupt controller for processing interrupt events in the CPU. When receiving an interrupt request from the CPU, record relevant information about the interrupt, such as the interrupt type, interrupt time, etc., and send the interrupt data to the dynamic switching mechanism module so as to optimize the interrupt processing strategy according to the current working mode and interrupt data. Refer to Figure 3 , which is a flow chart of a method for dynamically switching interrupt masks based on device status according to an embodiment of the present application, the method for dynamically switching interrupt masks based on device status includes the following steps.

[0022] S31, obtaining the state parameters of the target device at the current moment.

[0023] The target device refers to a device that needs to dynamically switch the interrupt mask. The target device may be an embedded device, an Internet of Things (IoT) device, an industrial control device, a computer hardware device, etc.

[0024] In some embodiments, the target device can periodically read the state parameters of the target device through the state monitoring module using the timer mechanism of the Linux kernel, the system monitoring interface (e.g., / proc, / stat, etc.) or the file system (e.g., / sys, / class, / thermal, etc.). For example, the state parameters of the target device are collected every 500 milliseconds. The state parameters may include, but are not limited to: CPU usage, temperature sensor data (hereinafter referred to as temperature data), task queue length, battery power, etc.

[0025] Since the acquired state parameters are directly used for working mode determination, frequent state switching may occur due to instantaneous data fluctuations, causing system instability. In an embodiment of the present application, after the state parameters of the target device are obtained, the target device can filter the state parameters. Specifically, the target device first uses the moving average method to smooth the state parameters of multiple sampling periods to reduce the impact of accidental high and low peaks. After the moving average is executed, low-pass filtering is performed to further eliminate noise and small fluctuations. At the same time, the filter window size is dynamically adjusted according to the current load of the system. For example, a shorter window is used in high-load mode for rapid response, and a longer window is used in low-load mode to reduce fluctuations. In addition, an exponential smoothing filter (EMA) can be introduced to give more weight to recent state parameters, so as to find a better balance between data smoothing and real-time response. When the system is complex and requires higher-precision monitoring, a Kalman filter can also be used to predict and adjust data fluctuations to reduce the impact of sudden changes on the determination. In addition, a hysteresis control is added to the state determination, that is, the mode switching is triggered only when the data exceeds the threshold for multiple consecutive times, reducing the situation of frequent switching due to single data fluctuations.

[0026] S32: Determine a first working mode of the target device at the current moment based on the state parameter.

[0027] The target device can pre-set multiple groups of thresholds based on device performance and resource usage to determine the current working mode of the target device, which can include high-load mode, normal mode and low-power mode. That is, when the state parameter of the target device is obtained, the actual value of the state parameter can be compared with the preset threshold to determine whether the target device is in high-load mode, normal mode or low-power mode at the current moment.

[0028] In an embodiment of the present application, the state parameters include CPU usage task queue length and temperature data. The target device can set a high threshold (called the first high threshold) and a low threshold (called the first low threshold) of CPU usage based on the normal working load and peak load of the target device, and generate a usage threshold interval based on the first high threshold and the first low threshold; set a high threshold (called the second high threshold) and a low threshold (called the second low threshold) of the task queue length at the same time, and generate a length threshold interval based on the second high threshold and the second low threshold; and set a high threshold (called the third high threshold) and a low threshold (called the third low threshold) of the temperature data, and generate a temperature threshold interval based on the third high threshold and the third low threshold. The target device monitors the state parameters of the target device in real time through the state monitoring module. When the CPU usage of the target device is obtained, the CPU usage at the current moment is compared with the usage threshold interval; when the task queue length of the target device is obtained, the task queue length is compared with the length threshold interval; when the temperature data of the target device is obtained, the temperature data at the current moment is compared with the temperature threshold interval.

[0029] When it is determined that the CPU usage is greater than the first high threshold of the usage threshold interval, the task queue length is greater than the second high threshold of the length threshold interval, and the temperature data is greater than the third high threshold of the temperature threshold interval, it can be determined that the current working mode of the target device is a high load mode. When it is determined that the CPU usage is less than the first low threshold of the usage threshold interval, the task queue length is less than the second low threshold of the length threshold interval, and the temperature data is less than the third low threshold of the temperature threshold interval, it can be determined that the current working mode of the target device is a low power consumption mode. When it is determined that the current working mode of the target device is neither a high load mode nor a low power consumption mode, it can be determined that the current working mode of the target device is a normal mode.

[0030] Exemplarily, for a mobile device, the first high threshold may be set to 80%, the first low threshold may be set to 20%, the second high threshold may be set to 10 tasks, the second low threshold may be set to 2 tasks, the third high threshold may be set to 70°C, and the third low threshold may be set to 40°C. That is, when the CPU usage is greater than 80%, the task queue length is greater than 10 tasks, and the temperature data is greater than 70°C, it is determined that the mobile device is in high-load mode; when the CPU usage is less than 20%, the task queue length is less than 2 tasks, and the temperature data is less than 40°C, it is determined that the mobile device is in low-power mode. When it is determined that the mobile device neither meets the high-load mode nor the low-power mode, it is determined that the mobile device is in normal mode.

[0031] The normal mode means that the target device is in a balanced state, that is, it runs under normal load, without excessively high or low resource requirements, and without aggressive energy-saving measures or load optimization. In some embodiments, the target device can monitor the operating parameters of the target device in real time to re-evaluate whether the target device should switch to a high-load loss or low-power mode.

[0032] In other embodiments, the state parameter also includes battery power, and the target device can set a corresponding fourth high threshold and fourth low threshold based on the battery power, and generate a power threshold interval based on the fourth high threshold and the fourth low threshold. When it is determined that the CPU usage is greater than the first high threshold of the usage threshold interval, the task queue length is greater than the second high threshold of the length threshold interval, and the temperature data is greater than the third high threshold of the temperature threshold interval, and the battery capacity is greater than the fourth high threshold, it can be determined that the current working mode of the target device is a high load mode. When it is determined that the CPU usage is less than the first low threshold of the usage threshold interval, the task queue length is less than the second low threshold of the length threshold interval, and the temperature data is less than the third low threshold of the temperature threshold interval, and the battery power is less than the fourth low threshold, it can be determined that the current working mode of the target device is a low power consumption mode. When it is determined that the current working mode of the target device is neither a high load mode nor a low power consumption mode, it can be determined that the current working mode of the target device is a normal mode.

[0033] Exemplarily, for embedded IoT devices, the first high threshold can be set to 60%, the first low threshold can be set to 20%, the second high threshold can be set to 8, the second low threshold can be set to 3, the third high threshold can be set to 60°C, the third low threshold can be set to 40°C, the fourth high threshold can be set to 50%, and the fourth low threshold can be set to 15%. That is, when the CPU usage is greater than 60%, the task queue length is greater than 8 tasks, the temperature data is greater than 60°C, and the battery power is greater than 50%, it is determined that the embedded IoT device is in high load mode; when the CPU usage is less than 20%, the task queue length is less than 3 tasks, the temperature data is less than 40°C, and the battery power is less than 15%, it is determined that the embedded IoT device is in low power consumption mode. When it is determined that the target device does not meet neither the high load mode nor the low power consumption mode, it is determined that the embedded IoT device is in normal mode.

[0034] In some embodiments, the target device can analyze the normal working load and peak load of the device. For example, on a mobile device, the low power mode can set the CPU usage rate to 20% as the first low threshold, and the high load mode can set the CPU usage rate to 80% as the first high threshold. The target device can also analyze the typical length and distribution of the task queue and set it in the length threshold interval. For example, the low power mode is triggered when the second low threshold is shorter, such as the task queue length is less than 3; when the task queue length continues to exceed 10, the system can be identified as a high load mode. The target device can also set the temperature threshold interval through the thermal management characteristics of the device. For example, if the safe operating temperature range of the device is 30°C to 80°C, the low power mode can be triggered when it is lower than 40°C, that is, the third low threshold is set to 40°C, and the high load mode can be triggered when it exceeds 70°C, that is, the third high threshold is set to 70°C. The target device can also set the power threshold interval according to the power policy of the device. For example, when the battery power is less than 15%, the low power mode is triggered; the high load mode can ignore the battery power to ensure performance. In other embodiments, the target device may also obtain the device hardware and platform characteristics of the target device, and adjust the usage rate threshold interval, and / or the length threshold interval, and / or the temperature threshold interval, and / or the power threshold interval based on the device hardware and platform characteristics. For example, on a high-performance processor, the first high threshold of the high-load mode can be set higher, such as 90%, while on a low-power processor, the first high threshold can be set to 70% to avoid overheating and reduced energy efficiency; for devices without active radiators, the third high threshold of the temperature threshold interval needs to be set lower to protect the hardware; for devices with smaller battery capacity, the fourth low threshold of the power threshold interval is set higher (for example, 30%) to enter the low power mode in advance. At the same time, the target device may also obtain the external and environmental factors of the target device, and adjust the usage rate threshold interval, and / or the length threshold interval, and / or the temperature threshold interval, and / or the power threshold interval based on the external and environmental factors. For example, when the ambient temperature is high, the temperature threshold interval can be adjusted to allow the target device to enter the low power mode earlier to avoid overheating; in devices that need to maintain a continuous network connection, the triggering threshold of the low power mode may take into account factors such as network data traffic. Alternatively, the target device may adjust the usage threshold interval, and / or length threshold interval, and / or temperature threshold interval, and / or power threshold interval based on the device's application scenario and user needs. For example, embedded systems or mobile devices have different application scenarios, where the low-power mode of an IoT device may have a stricter threshold (such as CPU usage below 10%), while in applications with high performance requirements (such as streaming media or games), the threshold of the high-load mode may be set lower (such as more than 60%), and users are also allowed to manually adjust or select preset mode thresholds in the configuration file to meet specific application needs.Alternatively, the target device can adjust the usage rate threshold interval, and / or length threshold interval, and / or temperature threshold interval, and / or power threshold interval based on historical data and automated adjustment mechanisms. For example, by recording the device's past operating status and interruption data, analyzing the device's response time and power consumption under different load conditions, and adjusting the threshold. If historical data shows that the CPU load often soars to 90% when the task queue length exceeds 8, the high threshold of the high-load mode can be set to a task queue length greater than 8. Similarly, the threshold can be automatically adjusted by analyzing device usage over a period of time (such as weekly or monthly). For example, if it is detected that the device has not reduced its frequency in time under multiple high-temperature conditions, the temperature threshold can be adjusted to lower the trigger point of the high-load mode.

[0035] Refer to Figure 4 As shown, in some embodiments, when the threshold interval corresponding to each working mode is set, the target device can control the target device to load the corresponding high threshold and low threshold in the threshold interval when the system is initialized. Specifically, through a configuration file (such as / etc / device_mode_thresholds.conf) or hard coding in the system, the state monitoring module reads the threshold interval when obtaining the state parameter, compares it with the threshold interval each time the state parameter is collected, and triggers different interrupt mask switching according to the judgment result.

[0036] In some embodiments, the target device introduces a threshold smoothing zone so that when the data slightly exceeds or falls below the threshold, the device does not switch immediately but waits for subsequent data confirmation. That is, after obtaining the state parameters and determining that it is no longer within the threshold interval, the operating mode is not switched immediately but waits for the state parameters to arrive at the next moment and re-judges. When it is still not within the threshold interval, the operating mode is switched.

[0037] In order to distinguish the working mode at the previous moment, the working mode at the current moment is called the first working mode, and the working mode at the previous moment is called the second working mode.

[0038] S33, determining the second working mode of the target device at the previous moment.

[0039] The previous moment and the current moment are two adjacent moments. The target device can monitor the state parameters of the target device at the previous moment in real time based on the same implementation method as the above steps S31 and S32, and determine the working mode of the target device at the previous moment based on the state parameters of the previous moment, that is, the second working mode.

[0040] S34: when it is detected that the target device switches from the second working mode to the first working mode, using an interrupt mask switching function to switch the interrupt mask configuration of the target device at the current moment.

[0041] The interrupt mask is a set of bit flags (bitmask) used to mark whether the interrupt source is allowed to pass. Each bit corresponds to a specific interrupt source. If the bit is 1, it means that the interrupt is allowed to pass; if it is 0, it means that the interrupt is masked. In some embodiments, the target device can also set the bit mask structure of the interrupt mask, for example, setting the bit mask structure to a 32-bit or larger bit width value, each bit represents the state of an interrupt source.

[0042] In some embodiments, the target device can pre-configure different interrupt masks based on different operating modes through a mask preset configuration module, and each interrupt mask configuration determines which interrupts are blocked or allowed in different operating modes. Among them, the operating modes may include low power consumption mode, normal mode and high load mode, and the interrupt mask corresponding to the low power consumption mode is called the low power consumption interrupt mask, the interrupt mask corresponding to the normal mode is called the normal interrupt mask, and the interrupt mask corresponding to the high load mode is called the high load interrupt mask. The low power consumption interrupt mask only allows interrupts for the most critical events, such as power management and emergency event interrupts. The low power consumption interrupt mask is set to allow the corresponding interrupt bit to be set to 1, and the remaining bits are 0. The normal interrupt mask allows interrupts required for daily operations, such as user interaction and network communication. The normal interrupt mask can set the corresponding interrupt bit to 1 to allow it to pass. The high load interrupt mask allows all interrupts to pass, and all bits in the high load interrupt mask are 1 to ensure optimal performance under high load. Exemplary, kernel_interrupt_mask=LOW_POWER_MASK=0b00001011; # Allow interrupts at bit 0, 1, and 3, and mask the others kernel_interrupt_mask=NORMAL_MASK=0b00111111; # Allow interrupts from bit 0 to 5 kernel_interrupt_mask=HIGH_LOAD_MASK=0b11111111; # Allow all interrupts In some embodiments, the target device may set and maintain a global mapping table or array to associate the operating mode with the corresponding interrupt mask. In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an embodiment to illustrate how to associate, and the code example used is as follows: struct interrupt_mask { unsigned int low_power_mask; unsigned int normal_mask; unsigned int high_load_mask; } mask_presets = { .low_power_mask = 0b00001011, .normal_mask = 0b00111111, .high_load_mask = 0b11111111 }; Refer to Figure 4 In some embodiments, when the target device system is initialized, a preset interrupt mask configuration is loaded through a configuration file or a kernel parameter. When the target device detects that the working mode of the target device has changed through the status monitoring module, that is, the first working mode at the current moment is compared with the second working mode at the previous moment. When it is determined that the first working mode and the second working mode are inconsistent, it is determined that the working mode of the target device has changed, and the second interrupt mask corresponding to the second working mode is switched to the first interrupt mask corresponding to the first working mode. Specifically, the corresponding interrupt mask is loaded according to different working modes to control which interrupts are allowed or blocked. For example, in low power consumption mode, most interrupts are blocked, and only power management and emergency interrupts are allowed.

[0043] In an optional implementation, the switching of the interrupt mask configuration of the target device at the current moment includes: Determining a first interrupt mask corresponding to the first operating mode; Performing a logical OR operation on the first interrupt mask and a predefined critical interrupt mask to obtain a new interrupt mask value; Locking the new interrupt mask value; The locked new interrupt mask value is written into the interrupt control register of the ARM processor of the target device, so that the first interrupt mask updates the second interrupt mask corresponding to the second working mode.

[0044] In some embodiments, the target device predefines a mask value as a critical interrupt mask, such as CRITICAL_INTERRUPTS_MASK, which indicates a critical interrupt bit that must always be enabled. At the same time, a data structure can be set and maintained to store the current interrupt mask and the interrupt mask corresponding to each working mode. When the module is started, the initialization function (such as init_module()) can be used to load the interrupt mask and store it in the preset data structure.

[0045] When it is determined that the working mode of the target device has changed, the target device can obtain the first interrupt mask corresponding to the current working mode from the interrupt vector table through the dynamic switching mechanism module, and pre-process the first interrupt mask, such as identifying whether multiple interrupts in the first interrupt mask will be triggered or compete for resources at the same time. The conflict is resolved by masking the low priority part of the conflicting interrupt and retaining the high priority part. If the conflict is difficult to avoid, the non-core interrupt is temporarily disabled. Exemplarily, in the high load mode, if there are network request interrupts and sensor data interrupts at the same time, the sensor data interrupt is retained first to ensure real-time performance, and the network request interrupt is masked. Then the first interrupt mask is logically ORed with the critical interrupt mask CRITICAL_INTERRUPTS_MASK to ensure that the critical interrupt bit is always 1. For example, if the first interrupt mask is new_mask, the operation of new_mask |= CRITICAL_INTERRUPTS_MASK is performed to ensure that the critical interrupt always remains unmasked. The interrupt mask after the logical OR operation is called the new interrupt mask value. Further, the target device can use an interrupt mask switching function, such as update_interrupt_mask(new_mask) or load_interrupt_mask(mode), to write a new interrupt mask value into an interrupt control register (such as ICCPMR) through the interrupt mask switching function, that is, to update the second interrupt mask of the second working mode in the interrupt controller of the ARM processor using the first interrupt mask corresponding to the first working mode (such as LOW_POWER_MODE, NORMAL_MODE, HIGH_LOAD_MODE). Among them, the interrupt mask switching function is a function for updating the mask value in the processor interrupt control register, and switches to a suitable interrupt mask according to the working mode of the current device and the preset interrupt mask value.

[0046] Among them, the interrupt vector table is a data structure used to store the address to which the processor jumps when an interrupt occurs. Each entry corresponds to an interrupt source. When an interrupt occurs, the processor finds the corresponding interrupt handler entry by searching the vector table. In the ARM architecture, the interrupt vector table is usually located in a fixed memory location. The processor enters the table according to the interrupt number index and jumps to the appropriate interrupt service routine (ISR). Each entry includes the address of the interrupt handler or a pointer to the handler. The interrupt vector table can include the interrupt number (used to identify different types of interrupts (such as external device interrupts, software interrupts)), the interrupt handler address (used to point to the memory address of the corresponding interrupt service routine) or the interrupt priority (used to determine the order in which interrupts are processed).

[0047] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an interrupt vector table example, and the code example used is as follows: typedef void (*isr_t)(void); isr_t interrupt_vector_table[NUM_INTERRUPTS]; / / Initialize the interrupt vector table void init_interrupt_vector_table() { interrupt_vector_table[0] =&power_management_isr; interrupt_vector_table[1] =&network_isr; / / Initialize other interrupt service routines } In some embodiments, before writing the new interrupt mask value to the interrupt controller, the target device can use a spin lock or a mutex lock to protect the switching operation to avoid race conditions, such as calling spin_lock_irqsave() to lock the operation and save the current interrupt state to ensure the atomicity of the switching process. After writing the new interrupt mask value to the interrupt controller, the target device can call spin_unlock_irqrestore() to unlock and restore the interrupt state to ensure that the system continues to run normally.

[0048] The interrupt control register of the ARM processor is used to store the interrupt priority mask. After the new interrupt mask is written, the ARM processor controls which interrupts can be accepted and processed by the processor in real time according to the new interrupt mask, that is, determines which interrupts are allowed to pass and which interrupts are shielded.

[0049] In some embodiments, after determining that the new interrupt mask value is written to the interrupt control register, the target device can record the operation information corresponding to the interrupt mask for subsequent debugging and system monitoring. For example, printk() or other log functions can be used to record the switching event in the system log, including the time of the interrupt mask switching, the interrupt mask value and the switching reason.

[0050] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an embodiment to illustrate how to obtain the corresponding interrupt mask from the kernel data structure according to the current working mode. The code example used is as follows: if (mode == HIGH_LOAD_MODE) { new_mask = mask_presets.high_load_mask; / / Get the mask value of high load mode } else if (mode == LOW_POWER_MODE) { new_mask = mask_presets.low_power_mask; / / Get the mask value of low power mode } In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application also provides an embodiment to illustrate how to update the interrupt mask according to the current working mode. The code example used is as follows: void switch_mode(int mode) { unsigned int new_mask; switch (mode) { case LOW_POWER_MODE: new_mask = LOW_POWER_MASK; / / For example: 0b00001011, only critical interrupts are allowed break; case NORMAL_MODE: new_mask = NORMAL_MASK; / / For example: 0b00111111, normal interrupts are allowed break; case HIGH_LOAD_MODE: new_mask = HIGH_LOAD_MASK; / / For example: 0b11111111, all interrupts are allowed break; default: return; / / unknown mode, do not switch } update_interrupt_mask(new_mask); / / Write the new mask value to the register } Or update the interrupt control register through a function interface. The code example used is as follows: void update_interrupt_mask(unsigned int new_mask) { / / Lock protection to ensure safety in a multi-threaded environment spin_lock_irqsave(&mask_lock, flags); write_iccpmr(new_mask); / / Write the new mask value to the ARM interrupt control register spin_unlock_irqrestore(&mask_lock, flags); } This application monitors the device status in real time to determine whether the interrupt mask needs to be switched. It selects the corresponding interrupt mask and pre-processes it based on the current working mode of the device to ensure that the critical interrupt bit is not masked. It then locks and executes the switch, writes the new interrupt mask to the interrupt control register, and finally releases the lock and records the log to ensure the integrity of the system operation.

[0051] In an optional implementation, after writing the locked new interrupt mask value into the interrupt control register of the ARM processor of the target device, the method further includes: Verifying the mask state of the new interrupt mask value to determine whether the new interrupt mask value is switched successfully; When it is determined that the switching of the new interrupt mask value fails, the new interrupt mask value is rolled back to the second interrupt mask.

[0052] In some embodiments, after writing the new interrupt mask to the interrupt control register, the target device needs to verify whether the new interrupt mask has been written correctly, that is, to verify the mask status to ensure that the critical interrupt bit is correctly set. Specifically, the target device can use WARN_ON() or a kernel error detection mechanism to detect whether there is an abnormality in the switching process of the new interrupt mask value. If an abnormality is detected in the switching process, a fallback mechanism is executed, that is, to fall back to the second interrupt mask corresponding to the previous moment, and the abnormality is recorded in a diary and a warning is issued to notify the system administrator to take further action.

[0053] In some embodiments, during the interrupt mask switching process, if performance degradation or system instability is detected, the system automatically falls back to the default mask configuration, such as the normal interrupt mask corresponding to the normal mode.

[0054] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an embodiment to illustrate falling back to the conventional interrupt mask, and the code example used is as follows: if (WARN_ON(update_interrupt_mask_failed)) { printk(KERN_ERR "Interrupt mask update failed, reverting to normalmode\n"); load_interrupt_mask(NORMAL_MODE); } Through the above optional implementation method, through the exception detection and fallback mechanism, the system stability is guaranteed when the mask switching fails or an exception is detected, the alarm is triggered by WARN_ON() or the kernel error detection mechanism, and the interrupt mask value of the normal mode is immediately fallen back when the switching fails, ensuring that the system maintains a safe state and enhancing the reliability and stability of the system.

[0055] In an optional embodiment, the method further comprises: Identifying historical interruption data according to a preset time period to determine whether a target interruption is a high-frequency interruption or a critical interruption, wherein the historical interruption data includes multiple interruptions, and the target interruption is any one of the multiple interruptions; When it is determined that the target interrupt is a high-frequency interrupt and a critical interrupt, increasing the interrupt priority of the target interrupt in the high-load mode; When it is determined that the target interrupt is a high-frequency interrupt, the target interrupt is masked in the low power consumption mode.

[0056] Among them, high-frequency interrupts refer to interrupts that are triggered more than the preset threshold within a preset time period, reflecting the activity level of certain tasks or devices in the system. Critical interrupts refer to interrupts that are critical to system stability, functionality or security and need to be given priority in any case, such as power management interrupts, emergency interrupts and timer interrupts.

[0057] In some embodiments, the target device can count the number of times each interruption is triggered in a preset time period (e.g., every hour, every day, etc.) based on the historical interruption data in the record, and compare the number with a preset threshold (e.g., 100 times per minute). When it is determined that the number of times an interruption is triggered meets the preset threshold, the interruption is considered to be a high-frequency interruption. In other embodiments, the target device can also analyze the triggering frequency of the interruption through a rolling time window. For example, if the triggering frequency of an interruption in multiple consecutive time windows is higher than the threshold, it can be defined as a high-frequency interruption. Exemplarily, if a network interruption is triggered 1,000 times in a day, and most other interruptions are triggered no more than 100 times, the network interruption can be determined to be a high-frequency interruption. In addition, the target device can determine whether each interrupt meets the critical interrupt judgment criteria based on the historical interrupt data in the record. The critical interrupt judgment criteria include: 1) whether the interrupt is used to maintain the core functions of the system (such as power management, system timers, memory error correction, etc.); 2) whether the interrupt is used to handle emergency events or protect system resources (such as overheating alarms, low battery, device failure, etc.); 3) whether there are interrupts that are considered critical in specific application scenarios, for example, interrupts in real-time audio processing may be marked as critical interrupts in audio applications; 4) critical interrupts pre-set during system design, such as power management interrupts, timer interrupts, etc.

[0058] The target device records the interrupt events that occur in the system in real time and stores these interrupt events as historical interrupt data in the historical data optimization module. The historical data optimization module determines whether each target interrupt in the historical interrupt data is a high-frequency interrupt or a critical interrupt. For target interrupts that are both high-frequency interrupts and critical interrupts, the target device can increase its interrupt priority in high-load mode to ensure that the target interrupt can still be processed in time when the system is busy. For target interrupts that are high-frequency interrupts but non-critical interrupts, the target device can shield these target interrupts in low-power mode to reduce system power consumption.

[0059] It should be noted that in order to ensure system stability, critical interrupts are set to the highest priority bit in the interrupt mask configuration, that is, no matter which working mode is switched to, the relevant bit is 1, allowing the interrupt to pass.

[0060] Through the above-mentioned optional implementation method, by identifying high-frequency interrupts and critical interrupts in historical interrupt data, the priority of both high-frequency and critical interrupts is increased in high-load mode to ensure timely processing by the system; in low-power mode, high-frequency but non-critical interrupts are shielded to reduce power consumption, optimize the interrupt processing strategy, improve system stability and efficiency, and at the same time reduce unnecessary power consumption and enhance the performance of the target device.

[0061] In an optional embodiment, the method further comprises: Determining the triggering number and processing time of the target interrupt; determining an importance score of the target interruption based on the triggering number and the processing time; An interrupt priority level of the target interrupt is adjusted based on the importance score.

[0062] In some embodiments, when it is determined that the interrupt mask has switched, the target device can add a kernel module, which can use a hook function (e.g., irq_handler_t) to capture the interrupt trigger event and record information such as the interrupt type, timestamp, and processing time into a log. A data structure is allocated in the kernel module to store interrupt trigger statistics, such as the number of times each interrupt is triggered and the processing time, and a counter array or hash table is used to store the number of times the interrupt type is triggered and the average processing time. The log format example is as follows: RQ_TYPE: 5, TIMESTAMP: 1624559305, DURATION: 10us IRQ_TYPE: 7, TIMESTAMP: 1624559306, DURATION: 15us Furthermore, the target device can use kernel threads or user space scripts to periodically read and analyze log data, where the log data records the trigger time, trigger times, processing time, etc. of historical interrupt data. When it is determined that a target interrupt occurs multiple times, the mean of the processing time is calculated to obtain the average processing time. Then, based on the trigger times and the average processing time, the importance score of each target interrupt is calculated using a weight formula.

[0063] The importance score is determined by the following weight formula: importance_score = (frequency_weight * num_triggers) + (duration_weight * avg_duration); Among them, is the importance score importance_score, num_triggers is the number of triggers, avg_duration is the average processing time, frequency_weight is the weight corresponding to the number of triggers, and duration_weight is the weight corresponding to the processing time.

[0064] After determining the importance score of each target interrupt, the higher the importance score, the higher the interrupt priority can be set, and according to the priority mapping table, the priority mapping table is pre-set, and the priority mapping table associates the interrupt type with its priority, which is convenient for updating the interrupt priority record and dynamically adjusting the interrupt mask configuration. Next, traverse the priority mapping table and generate a new interrupt mask according to the interrupt priority. For example, the high-frequency and high-priority interrupt bit is set to 1 to ensure that it is processed in high-load mode, and the low-frequency and low-priority interrupt is masked (set to 0) in low-power mode. Finally, the new interrupt mask is applied to the kernel module.

[0065] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an embodiment to modify the interrupt mask preset value in the kernel data structure to reflect the new interrupt priority adjustment. The code example used is as follows: mask_presets.high_load_mask = generate_new_mask(high_priority_irq_list); mask_presets.low_power_mask = generate_new_mask(low_priority_irq_list); In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an embodiment to illustrate that when the interrupt mask switching function is called, the specific conditions triggering the switching are recorded in the log as the switching reason. The code example used is as follows: if (cpu_load>HIGH_LOAD_THRESHOLD) { reason = "CPU load exceeded 80%"; } else if (temperature>TEMP_THRESHOLD) { reason = "Temperature exceeded 70°C"; } printk(KERN_INFO "Interrupt mask switched due to: %s at %lu\n",reason, jiffies); It should be noted that no matter what the importance score of each target interrupt in the historical interrupt data is, for target interrupts that are critical interrupts, such as power management and emergency interrupts, they always maintain the highest priority in the interrupt mask adjustment, that is, in the mask generation function, the CRITICAL_INTERRUPTS_MASK bit is forced to be kept as 1.

[0066] Through the above optional implementation, by dynamically adjusting the interrupt priority and interrupt mask, the system response efficiency and stability are improved, while ensuring the priority processing of critical interrupts, effectively balancing system performance and power consumption, and providing detailed logging for easy problem tracking.

[0067] Reference Figure 4 , which is another flow chart of a method for dynamically switching interrupt masks based on device status shown in an embodiment of the present application.

[0068] When the target device system starts, the status monitoring module and the mask preset configuration module are loaded, and the status parameter monitoring frequency, the high threshold and low threshold of the threshold interval, and the preset value of the interrupt mask corresponding to each working mode are set through the configuration file or startup parameters. For example, the interrupt mask in low power mode only allows power management and emergency interrupts to pass; the normal mode allows user interaction and network communication interrupts to pass; and the high load mode allows all interrupts to pass. According to the preset interrupt mask configuration, the interrupt vector table and interrupt control register of the ARM processor are initialized to ensure that the system runs according to the set interrupt strategy in the initial state.

[0069] Among them, the configuration file refers to a text file or a structured file that contains the parameters required for system operation. It is usually located in a path in the file system, such as / etc / config.conf, / etc / interrupt_masks.conf, etc., and is used to store settings such as the status parameter monitoring frequency, the high and low thresholds of the threshold range, and the preset values ​​of the interrupt mask. The startup parameter refers to the command line parameter passed to the kernel when the system starts, which is used to set the configuration of the system when it is running. For example, in the configuration of a boot program (such as GRUB), kernel command line parameters can be added.

[0070] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides a configuration file example, and the code example used is as follows: # / etc / interrupt_config.conf monitor_frequency=500# Status monitoring frequency (milliseconds) low_power_threshold=20# CPU usage threshold for low power mode (%) high_load_threshold=80# CPU usage threshold for high load mode (%) low_power_mask=0b00001011# Interrupt mask for low power mode normal_mask=0b00111111# Normal mode interrupt mask high_load_mask=0b111111111# Interrupt mask for high load mode Example startup parameters: In the configuration file of GRUB or other boot programs, you can pass startup parameters through the following statements: kernel / boot / vmlinuz- <version>root= / dev / sda1 monitor_frequency=500low_power_threshold=20 high_load_threshold=80 Specifically, during system initialization, the target device can use file I / O functions (such as fopen, fscanf) to read configuration files and load parameters through kernel modules or user space scripts. When the kernel starts, the command line parameters can be parsed through the __setup() or parse_args() function and stored in the kernel data structure. According to the read configuration files and startup parameters, global variables or kernel data structures are set to control the behavior of the status monitoring module and the interrupt mask configuration module.

[0071] For example: int monitor_frequency = get_config_value("monitor_frequency"); / / Read from the configuration file int low_power_threshold = get_kernel_param("low_power_threshold"); / / Read from startup parameters In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an example of reading configuration file parameters, and the code example used is as follows: / / Read configuration file parameters FILE *config_file = fopen(" / etc / interrupt_config.conf", "r"); if (config_file != NULL) { fscanf(config_file, "monitor_frequency=%d",&monitor_frequency); fscanf(config_file, "low_power_threshold=%d",&low_power_threshold); fscanf(config_file, "high_load_threshold=%d",&high_load_threshold); fclose(config_file); } In some embodiments, the target device may allocate memory space in the kernel for storing an interrupt vector table to initialize the interrupt vector table, define a corresponding handler for each interrupt (such as power_management_isr, network_isr), map each interrupt number with the corresponding handler address, fill it into the interrupt vector table, and write the base address of the interrupt vector table into the interrupt control register of the processor so as to jump when an interrupt occurs.

[0072] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an example of initializing an interrupt vector table, and the code example used is as follows: void init_vector_table() { interrupt_vector_table[0] =&power_management_isr; interrupt_vector_table[1] =&network_isr; / / Continue to add other interrupt service routines set_interrupt_vector_base((unsigned int)interrupt_vector_table); } During system initialization, the target device also loads a set of preset values ​​for interrupt masks and stores them in the kernel data structure. Each interrupt mask corresponds to a different working mode, such as low power mode, normal mode, and high load mode.

[0073] The status monitoring module determines the current working mode based on the status parameters of the current device (such as CPU load, temperature data, and task queue length). When it is detected that the status parameter crosses the preset threshold (such as switching from low power mode to normal mode or high load mode), the system selects the corresponding interrupt mask value from the preset interrupt mask configuration and switches the interrupt mask value through the dynamic switching mechanism module. At the same time, the kernel's jiffies or timestamps are used to record the switching time and switching reason of the interrupt mask switching, which is helpful for subsequent analysis and optimization of system behavior, ensuring the stability and performance of the system, and analyzing whether there are too many switching events concentrated in a certain time period or a certain system state. For example, if it is found that the switching from low power mode to high load mode is frequent, it may be necessary to adjust the threshold or optimize the status monitoring module. In a multi-core or multi-threaded environment, spin locks or atomic operations are used to ensure the atomicity of the switching process and avoid race conditions. At the same time, the time and reason of the interrupt mask switching are recorded to facilitate subsequent analysis and optimization.

[0074] When an interrupt is determined to have occurred, the processor will jump to the entry address specified in the interrupt vector table and start executing the interrupt handling process. Specifically, the interrupt entry function is used to perform initial settings, such as saving context, checking interrupt priority and interrupt mask configuration, and the interrupt handling function is used to perform specific interrupt services, such as processing external device requests, timer interrupts or other system events. For example, when an interrupt occurs, the processor jumps to the corresponding entry address in the interrupt vector table and starts executing the interrupt entry function. In the interrupt entry function, check whether the current interrupt number is allowed by the current interrupt mask. If the interrupt mask allows the interrupt, the interrupt entry function continues to call the actual interrupt handling function. If the interrupt mask masks the interrupt, the interrupt entry function terminates the processing and returns control to the system without executing subsequent processing logic.

[0075] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an interrupt mask processing example, and the code example used is as follows: void interrupt_entry_function(int interrupt_number) { if (is_interrupt_allowed(interrupt_number, current_mask)) { call_interrupt_handler(interrupt_number); / / Call the actual interrupt handling function } else { return; / / Abort processing and return to interrupt } } For the lowest priority interrupt set, when determining whether the current interrupt is allowed, the logic in the interrupt entry function or interrupt handling function will ignore the mask of the lowest priority interrupt set, ensuring that the lowest priority interrupt set can always pass. Among them, the lowest priority interrupt set refers to some critical interrupts in the system, which need to be allowed to pass under any circumstances and will not be masked due to changes in the interrupt mask configuration. They can include power management interrupts, emergency interrupts, and core system interrupts. Specifically, a constant value CRITICAL_INTERRUPTS_MASK is pre-set in the interrupt mask configuration, and its bits correspond to critical interrupts that need to be always allowed.

[0076] In order to facilitate understanding of the inventive concept of the embodiment of the present application, the present application provides an example of a logic protection clock allowing a set of interrupts with the lowest priority to pass through, and the code example used is as follows: if ((interrupt_number&CRITICAL_INTERRUPTS_MASK) || is_interrupt_allowed(interrupt_number, current_mask)) { call_interrupt_handler(interrupt_number); } else { return; } In addition, the historical data optimization module records interrupt data, including the number of times each type of interrupt is triggered, the processing time, and the impact, and writes the interrupt data to the kernel log or a dedicated log file. It also regularly analyzes these historical interrupt data to identify high-frequency and critical interrupts and optimizes the interrupt mask configuration accordingly. For example, it increases the priority of high-frequency critical interrupts to ensure that they are processed in a timely manner in high-load mode; and shields high-frequency non-critical interrupts in low-power mode to reduce power consumption.

[0077] Reference Figure 5 , which is a functional module diagram of an interrupt mask dynamic switching device based on device status shown in an embodiment of the present application.

[0078] In some embodiments, the device state-based interrupt mask dynamic switching device 50 may include a plurality of functional modules composed of computer program segments. The computer program of each program segment of the device state-based interrupt mask dynamic switching device 50 may be stored in the memory of the target device and executed by at least one processor to perform (see Figure 3 The invention relates to a function of dynamically switching the interrupt mask based on the device status. According to the functions performed by the function, it can be divided into multiple functional modules. The functional modules may include a status monitoring module 501, a dynamic switching mechanism module 502 and a historical data optimization module 503. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0079] The state monitoring module 501 is used to obtain the state parameters of the target device at the current moment.

[0080] The state monitoring module 501 is further configured to determine the first working mode of the target device at the current moment based on the state parameter.

[0081] The state monitoring module 501 is further used to determine the second working mode of the target device at a previous moment.

[0082] The dynamic switching mechanism module 502 is used to switch the interrupt mask configuration of the target device at the current moment when it is detected that the target device switches from the second working mode to the first working mode.

[0083] The dynamic switching mechanism module 502 is also specifically used to: determine the first interrupt mask corresponding to the first working mode; perform a logical OR operation on the first interrupt mask and a predefined key interrupt mask to obtain a new interrupt mask value; lock the new interrupt mask value; and write the locked new interrupt mask value into the interrupt control register of the ARM processor of the target device so that the first interrupt mask updates the second interrupt mask corresponding to the second working mode.

[0084] The dynamic switching mechanism module 502 is further used to: verify the mask state of the new interrupt mask value to determine whether the new interrupt mask value is switched successfully; when it is determined that the new interrupt mask value fails to switch, roll back the new interrupt mask value to the second interrupt mask.

[0085] The status monitoring module 501 is also specifically used to: when the CPU usage is greater than the first high threshold of the preset usage threshold interval, and the task queue length is greater than the second high threshold of the preset length threshold interval, and the temperature data is greater than the third high threshold of the preset temperature threshold interval, determine that the first working mode is a high load mode; when the CPU usage is less than the first low threshold of the preset usage threshold interval, and the task queue length is less than the second low threshold of the preset length threshold interval, and the temperature data is less than the third low threshold of the preset temperature threshold interval, determine that the first working mode is a low power consumption mode; when the target device is not in the high load mode and the low power consumption mode, determine that the first working mode is a normal mode.

[0086] The status monitoring module 501 is also specifically used to: when the CPU usage rate is greater than the first high threshold, and the task queue length is greater than the second high threshold, and the temperature data is greater than the third high threshold, and the battery power is greater than the fourth high threshold of the preset power threshold interval, determine that the first working mode is a high load mode; when the CPU usage rate is less than the first low threshold, and the task queue length is less than the second low threshold, and the temperature data is less than the third low threshold, and the battery power is less than the fourth low threshold of the power threshold interval, determine that the first working mode is a low power consumption mode.

[0087] The historical data optimization module 503 is used to: identify historical interrupt data according to a preset time period to determine whether a target interrupt is a high-frequency interrupt or a critical interrupt, the historical interrupt data includes multiple interrupts, and the target interrupt is any one of the multiple interrupts; when the target interrupt is determined to be a high-frequency interrupt and a critical interrupt, increase the interrupt priority of the target interrupt in the high-load mode; when the target interrupt is determined to be a high-frequency interrupt, shield the target interrupt in the low-power consumption mode.

[0088] The historical data optimization module 503 is further used to: determine the triggering number and processing time of the target interruption; determine the importance score of the target interruption based on the triggering number and the processing time; and adjust the interruption priority of the target interruption based on the importance score.

[0089] It should be understood that the various variations and specific embodiments of the interrupt mask dynamic switching method based on device status provided in the above-mentioned embodiments are also applicable to the interrupt mask dynamic switching device based on device status in the present embodiment. Through the above-mentioned detailed description of the interrupt mask dynamic switching method based on device status, those skilled in the art can clearly know the implementation method of the interrupt mask dynamic switching device based on device status in the present embodiment. For the sake of brevity of the specification, it will not be described in detail here.

[0090] See also Figure 6 FIG. 2 is a schematic diagram of the structure of the target device shown in the embodiment of the present application. In a preferred embodiment of the present application, the target device 6 includes a memory 61 , at least one processor 62 and at least one communication bus 63 .

[0091] Those skilled in the art should understand that Figure 6 The structure of the target device 6 shown does not constitute a limitation of the embodiments of the present application, and may be either a bus structure or a star structure. The target device 6 may also include more or less other hardware or software than shown in the figure, or a different component arrangement.

[0092] In some embodiments, the target device 6 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices.

[0093] In the above embodiments provided in the present application, it should be understood that the disclosed methods, devices, computer-readable storage media, and target devices can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple components or modules can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or components or modules, which can be electrical, mechanical or other forms.

[0094] The components described as separate components may or may not be physically separated, and the components shown as components may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the components may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0095] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each component may exist physically separately, or two or more modules may be integrated into one module. The above integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0096] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0097] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0098] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0099] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.< / version>

Claims

1. A method for dynamically switching interrupt masks based on device status, characterized in that: The method comprises: Get the status parameters of the target device at the current moment; Determining a first operating mode of the target device at the current moment based on the state parameter; Determine the second working mode of the target device at a previous moment; When it is detected that the target device switches from the second working mode to the first working mode, the interrupt mask configuration of the target device at the current moment is switched.

2. The interrupt mask dynamic switching method based on device status according to claim 1 is characterized in that: The switching of the interrupt mask configuration of the target device at the current moment includes: Determining a first interrupt mask corresponding to the first operating mode; Performing a logical OR operation on the first interrupt mask and a predefined critical interrupt mask to obtain a new interrupt mask value; Locking the new interrupt mask value; The locked new interrupt mask value is written into the interrupt control register of the ARM processor of the target device, so that the first interrupt mask updates the second interrupt mask corresponding to the second working mode.

3. The interrupt mask dynamic switching method based on device status according to claim 2 is characterized in that: After writing the locked new interrupt mask value into the interrupt control register of the ARM processor of the target device, the method further includes: Verifying the mask state of the new interrupt mask value to determine whether the new interrupt mask value is switched successfully; When it is determined that the switching of the new interrupt mask value fails, the new interrupt mask value is rolled back to the second interrupt mask.

4. The interrupt mask dynamic switching method based on device status according to claim 1, characterized in that: The state parameters include CPU usage, task queue length, and temperature data, and determining the first working mode of the target device at the current moment based on the state parameters includes: When the CPU usage is greater than a first high threshold of a preset usage threshold interval, and the task queue length is greater than a second high threshold of a preset length threshold interval, and the temperature data is greater than a third high threshold of a preset temperature threshold interval, determining that the first working mode is a high load mode; When the CPU usage is less than a first low threshold of the preset usage threshold interval, the task queue length is less than a second low threshold of the preset length threshold interval, and the temperature data is less than a third low threshold of the preset temperature threshold interval, determining that the first working mode is a low power consumption mode; When the target device is not in the high load mode and the low power consumption mode, it is determined that the first operating mode is a normal mode.

5. The interrupt mask dynamic switching method based on device status according to claim 4 is characterized in that: The state parameter also includes battery power, and determining the first working mode of the target device at the current moment based on the state parameter includes: When the CPU usage rate is greater than the first high threshold, and the task queue length is greater than the second high threshold, and the temperature data is greater than the third high threshold, and the battery power is greater than the fourth high threshold of the preset power threshold interval, it is determined that the first working mode is a high load mode; When the CPU usage is less than the first low threshold, and the task queue length is less than the second low threshold, and the temperature data is less than the third low threshold, and the battery power is less than the fourth low threshold of the power threshold interval, the first operating mode is determined to be a low power consumption mode.

6. The interrupt mask dynamic switching method based on device status according to claim 4 is characterized in that: The method further comprises: Identifying historical interruption data according to a preset time period to determine whether a target interruption is a high-frequency interruption or a critical interruption, wherein the historical interruption data includes multiple interruptions, and the target interruption is any one of the multiple interruptions; When it is determined that the target interrupt is a high-frequency interrupt and a critical interrupt, increasing the interrupt priority of the target interrupt in the high-load mode; When it is determined that the target interrupt is a high-frequency interrupt, the target interrupt is masked in the low power consumption mode.

7. The interrupt mask dynamic switching method based on device status according to claim 6, characterized in that: The method further comprises: Determining the triggering number and processing time of the target interrupt; determining an importance score of the target interruption based on the triggering number and the processing time; An interrupt priority level of the target interrupt is adjusted based on the importance score.

8. A device for dynamically switching interrupt masks based on device status, characterized in that: The device comprises: The status monitoring module is used to obtain the status parameters of the target device at the current moment; The state monitoring module is further used to determine the first working mode of the target device at the current moment based on the state parameter; The state monitoring module is further used to determine the second working mode of the target device at a previous moment; The dynamic switching mechanism module is used to switch the interrupt mask configuration of the target device at the current moment when it is detected that the target device switches from the second working mode to the first working mode.

9. A target device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for dynamic switching of interrupt masks based on device status described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for dynamically switching interrupt masks based on device status according to any one of claims 1 to 7 are implemented.