System task scheduling abnormity monitoring and positioning method and device and storage medium
By detecting the operating cycle and status of embedded system tasks, scheduling anomalies in automotive embedded systems are located, solving the problems of excessive CPU load and frequent interruptions, and achieving fast and accurate anomaly location and processing.
Patent Information
- Application Number
- CN202510885621.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-10-24
AI Technical Summary
In automotive embedded systems, problems such as excessive CPU load, frequent interruptions, and memory overflows lead to task scheduling anomalies that are difficult to detect and locate in a timely manner, affecting system stability and performance.
By detecting the actual running cycle of the task, triggering the abnormal monitoring and positioning process, and using the number of interrupt executions, the running status of higher-priority tasks and the status of runnable entities, the cause of the scheduling abnormality is accurately located, the abnormal information is recorded and an early warning is issued.
Quickly and accurately locate system task scheduling anomalies, reduce manpower and time consumption, improve processing capabilities, and ensure safe system operation.
Smart Images

Figure CN120832289A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of embedded systems, and in particular to a system task scheduling exception monitoring and positioning method, device and storage medium. BACKGROUND
[0002] Embedded operating systems are widely used in industrial control, automotive electronics and many other fields. In its running mechanism, it mainly relies on clock interrupt driven scheduling, priority preemption mechanism and task state management to ensure the normal operation of tasks. Clock interrupt driven scheduling sends signals at preset time intervals to control the start and stop of each task. The priority preemption mechanism ensures that when multiple tasks compete for resources at the same time, high-priority tasks can have priority to obtain execution rights, avoiding low-priority tasks from occupying resources for a long time and affecting the overall performance of the system. Task state management is responsible for monitoring and converting various states of tasks (such as ready, running, blocking, etc.), so that the tasks in the system can proceed in an orderly manner. In a task, there are usually multiple runnable entities, each of which undertakes different functions, and their running periods are scheduled based on software counters under the task. According to the preset rules, each runnable entity is allocated running time, so as to ensure that each part of the task can work in coordination.
[0003] With the rapid development of automatic driving technology, the intelligence level of vehicles is getting higher and higher, and at the same time, the complexity of domain controllers is also increasing, and the algorithms used are becoming more and more complex. A series of problems have been exposed in the development, testing and running of vehicle embedded systems, such as: due to the need to process a large amount of data and complex algorithms, the CPU load is too high, affecting the stability of the system; frequent interrupt triggering, too many interrupts will interrupt the execution flow of normal tasks, so that the tasks cannot proceed in the predetermined time sequence; memory overflow and some redundant algorithms and excessive packet communication, which frequently interfere with the scheduling timing sequence of periodic tasks; causing the system task and runnable entity period to be inaccurate or abnormal. In the software development and testing process of vehicle embedded systems or when the vehicle fails, it is necessary to timely find the system task with abnormal running period and position and analyze the abnormality, so that the technical personnel can lock the system abnormality as soon as possible to quickly solve the problem and improve the processing capacity, which is the problem to be solved at present. SUMMARY
[0004] The present application provides a system task scheduling exception monitoring and positioning method, device and storage medium to solve the above technical problems.
[0005] The method comprises the following steps: detecting an actual running period of a current system task; triggering an abnormal monitoring and positioning process when the actual running period of the current system task is greater than a first preset time threshold; wherein the abnormal monitoring and positioning process locates the cause of the abnormal scheduling of the current system task according to the execution frequency of each interrupt in a preset period, the running state of a system task with a higher priority than the current system task, and the running state of a runnable entity in the current system task, and records the corresponding abnormal information.
[0006] In the present scheme, the actual running period of a task is detected and compared with a first preset time threshold to trigger abnormal monitoring in real time. Once the period exceeds the limit, the abnormal monitoring and positioning process is started. The cause of the abnormal actual running period of the system task is located quickly and accurately by diagnosing at least one of the three dimensions of the execution frequency of the interrupt in the system, the running state of the system task with a higher priority, and the running state of the runnable entity in the current system task, and the corresponding abnormal information is recorded. This can help technical personnel to promptly discover and locate system abnormalities during the software development and testing process of an embedded system or when a device using the embedded system, such as a vehicle, fails, and to analyze and handle abnormal phenomena in detail, thereby avoiding the need to check each interrupt, system task, and runnable entity one by one, and improving the technical personnel's ability to handle abnormal tasks of the embedded system in a timely and efficient manner.
[0007] Further, the method for locating the abnormal scheduling of the system task according to the execution frequency of each interrupt in a preset period comprises: detecting the execution frequency of each interrupt in a preset period; if the execution frequency of the interrupt is greater than a first preset execution frequency threshold, the interrupt frequently preoccupies resources, causing the abnormal scheduling of the current system task, and the interrupt information of the interrupt greater than the first preset execution frequency threshold is recorded in the log.
[0008] In the present scheme, the execution frequency of each interrupt in a preset period is counted and compared with a first preset execution frequency threshold to quantitatively locate the source of resource preoccupation. For the interrupt that preoccupies resources, the type code, trigger frequency, timestamp, and priority of the abnormal interrupt are recorded to form a structured log. The interrupt type code can distinguish between an interrupt storm caused by a peripheral fault and abnormal scheduling triggered by software logic, avoiding misjudgment. The frequency trend of the interrupt in the log can assist in determining whether the abnormality is occasional or persistent, such as a periodic hardware fault, providing a basis for optimizing the threshold setting.
[0009] Further, the type of the current system task and the type of the system task with a higher priority at least include event type or periodic type.
[0010] Event-type tasks are triggered by specific events, i.e., external events (such as sensor abnormal signals, hardware interrupts, interactive instructions, etc.), and the execution time is unpredictable and completely depends on the timing of the event. Periodic tasks are tasks that are repeatedly executed at a predetermined time interval, such as periodic data acquisition and system state polling, which have strict periodicity and are executed in a fixed time window, and the execution time and resource occupation can be estimated in advance. According to different task types, different abnormal monitoring and positioning methods are executed to improve the abnormal positioning capability.
[0011] Further, the abnormal monitoring and positioning process locates the system task scheduling exception according to the running state of the system task with a higher priority than the current system task in a preset period, including: if the type of the system task with a higher priority is periodic, detecting the actual running period of the runnable entity in the system task with a higher priority, if the actual running period of the runnable entity in the system task with a higher priority is greater than a second preset time threshold, the internal function logic of the runnable entity in the system task with a higher priority is abnormal, causing the current system task scheduling exception, and recording the information of the runnable entity in the system task with a higher priority to the log.
[0012] High-priority periodic tasks usually play a key role in the core function and performance of the system. By monitoring the state of these tasks, we can quickly focus on the tasks that may have scheduling exceptions among many tasks, reducing the time and workload of troubleshooting. High-priority periodic tasks have fixed execution periods and predictable behavior patterns. By analyzing the state of the runnable entity, such as the start time, end time, and execution duration of the task, we can accurately determine whether the scheduling exception is caused by resource competition, unreasonable task priority setting, or abnormal internal function logic of the runnable entity. For example, an abnormal internal function logic of the runnable entity may cause it to stay in a certain function for a long time, resulting in an actual running period of the runnable entity exceeding a second preset time threshold, causing system resource occupation and affecting the normal operation of low-priority system tasks. The information of the runnable entity in the system task with a higher priority includes the name of the runnable entity, the trigger condition of the runnable entity, the specific function and role of the runnable entity, etc.
[0013] Further, the abnormal monitoring and positioning process locates the system task scheduling exception according to the running state of the system task with a higher priority than the current system task in a preset period, including: if the type of the system task with a higher priority is periodic, detecting the actual running period of the runnable entity in the system task with a higher priority, if the actual running period of the runnable entity in the system task with a higher priority is greater than a second preset time threshold, the internal function logic of the runnable entity in the system task with a higher priority is abnormal, causing the current system task scheduling exception, and recording the information of the runnable entity in the system task with a higher priority to the log.
[0014] In the scheme, by detecting the execution times of the event type task, it can be directly judged whether the system task with higher priority is frequently activated due to external event overload (such as sensor false triggering) or internal logic defect (such as interrupt flag not cleared), which causes the abnormal scheduling of the system task. The information of the system task with higher priority is recorded, including task name, task priority, stack resource size of the task, etc.
[0015] Further, the abnormal monitoring and positioning flow according to the running state of the executable entity in the current system task within the preset period to position the system task scheduling abnormality, including: if the type of the current system task is event type, detecting the execution times of each executable entity in the current system task, if there is an executable entity in the current system task whose execution times is greater than a third preset execution times threshold, the executable entity in the current system task is frequently activated, which causes the current system task scheduling abnormality, and the information of the executable entity in the current system task greater than the third preset execution times threshold is recorded to the log. If the execution times of the executable entity in the current system task is less than or equal to the third preset execution times threshold, detecting the actual execution period of the executable entity in the current system task, if the actual execution period of the executable entity in the current system task is greater than a third preset time threshold, the internal function logic of the executable entity in the current system task is abnormal, which causes the current system task scheduling abnormality, and the information of the executable entity in the current system task is recorded to the log.
[0016] According to the event type system task executable entity state positioning scheduling abnormality technology, it is an event-driven system monitoring and fault diagnosis method. Each executable entity has its specific running state and behavior mode in the system task. Through real-time monitoring and analysis of the state of the executable entity in the system task, the specific position of the abnormality can be accurately judged. If the execution times of the executable entity in the current system task is greater than the third preset execution times threshold, that is, the number and times of calling the executable entity when running a task is less, and the task execution time is short, and due to the frequent activation of multiple executable entities, multiple and multiple executable entities need to be called when running a task, and the task execution time is long, which indicates that the executable entity in the current system task is frequently activated, which causes the current system task scheduling abnormality, and the information of the executable entity in the current system task greater than the third preset execution times threshold is recorded, including the name of the executable entity, the trigger condition of the executable entity, the specific function and effect of the executable entity, etc.
[0017] If the execution times of the executable entities in the current system are within the normal range, it is necessary to consider whether the actual execution cycle of the executable entity in the current system task is abnormal. By analyzing the state of the executable entity, such as the start time, end time, and execution duration of the task, it is determined whether the current system task scheduling is abnormal due to the abnormality of the internal function logic of the executable entity. The abnormality of the internal function logic of the executable entity causes the executable entity to stay in a certain function for a long time, resulting in the actual running cycle of the executable entity exceeding the third preset time threshold, thereby causing the current system task to run abnormally. The information of the executable entity in the current system task is recorded, including the name of the executable entity, the trigger condition of the executable entity, the specific function and role of the executable entity, etc.
[0018] Further, the abnormality monitoring and positioning process according to the method of positioning the system task scheduling abnormality according to the running state of the executable entity in the current system task within a preset period includes: if the type of the current system task is periodic, detecting the actual execution cycle of the executable entity in the system task, and if the actual execution cycle of the executable entity in the current system task is greater than the fourth preset time threshold, the internal function logic of the executable entity in the current system task is abnormal, causing the current system task to be abnormal. The information of the executable entity in the current system task is recorded to the log.
[0019] If the type of the current system task is periodic, it is determined whether the current system task scheduling is abnormal due to the abnormality of the internal function logic of the executable entity by analyzing the state of the executable entity, such as the start time, end time, and execution duration of the task. The abnormality of the internal function logic of the executable entity causes the executable entity to stay in a certain function for a long time, resulting in the actual running cycle of the executable entity exceeding the fourth preset time threshold, thereby causing the current system task to run abnormally. The information of the executable entity in the current system task is recorded, including the name of the executable entity, the trigger condition of the executable entity, the specific function and role of the executable entity, etc.
[0020] Further, after positioning the cause of the current system task scheduling abnormality, a warning information or prompt information is issued to alert system maintenance.
[0021] The warning information or prompt information should include the system task that appears abnormal, the brief information of the cause of the system task abnormality, and the possible coping strategy. To help users handle the abnormality and ensure the safe operation of the system. In addition, the warning level can be set according to the abnormality cause and the abnormality influence degree. When issuing the warning information or prompt information, the warning level is given, including high-level warning, medium-level warning, and low-level warning. For different warning levels, the corresponding handling time is given.
[0022] Based on the same concept, the application also provides a system task scheduling exception monitoring and positioning device, comprising: a detection module for detecting the actual running period of a system task and a runnable entity; a processing module for analyzing the cause of the system task scheduling exception according to the data detected by the detection module; and a storage module for storing the relevant data recording the cause of the system task scheduling exception.
[0023] Based on the same concept, the application also provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the system task scheduling exception monitoring and positioning method.
[0024] Compared with the prior art, the application has the following beneficial effects: In the above technical solution, the actual running period of the task is detected and compared with the first preset time threshold to realize instant triggering of the exception monitoring, and once the period exceeds the limit, the exception monitoring and positioning process is started, and at least one of the three dimensions of the number of interruption executions in the system, the running state of the system task with a higher priority, and the running state of the runnable entity in the current system task is diagnosed to quickly and accurately locate the specific cause of the abnormal actual running period of the system task and record the corresponding exception information. After the exception monitoring and positioning process is completed, a warning information or a prompt information is actively sent to notify the user to maintain the system in time to help the user to handle the exception and ensure the safe operation of the system. For example, when applied in the embedded system of a vehicle, the output warning information or prompt information can make the user go to the vehicle maintenance point in time for maintenance, which can help the technical personnel to discover and locate the system exception in time during the software development and testing process of the embedded system of the vehicle or during the vehicle maintenance, and to analyze and handle the abnormal phenomenon in detail, thereby avoiding the waste of manpower and time to check each interruption, system task and runnable entity one by one, and improving the timely handling ability and handling efficiency of the technical personnel for the abnormal task of the embedded system. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 Flowchart of system task execution in the embedded system Figure 2 Flowchart of the system task scheduling exception monitoring and positioning method.
[0026] Figure 3 Flowchart of the method for positioning the system task scheduling exception according to the number of executions of each interruption in the preset period.
[0027] Figure 4A flow chart of a method for locating a system task scheduling exception according to a running state of a system task with a higher priority than a current system task within a preset period.
[0028] Figure 5 A flow chart of a method for locating a system task scheduling exception according to a running state of a running entity within a current system task within a preset period.
[0029] Figure 6 A schematic diagram of a system task scheduling exception monitoring and locating device. DETAILED DESCRIPTION
[0030] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0031] An embedded system is a special-purpose computer system used for controlling, monitoring or assisting the operation of a machine or equipment, and is widely used in many fields such as industrial control and automotive electronics. In its operation mechanism, it mainly relies on clock interrupt-driven scheduling, priority preemption mechanism and task state management to ensure the normal operation of tasks. Clock interrupt-driven scheduling sends signals at preset time intervals to control the start and stop of each task. The priority preemption mechanism ensures that when multiple tasks compete for resources at the same time, the task with a high priority can obtain the execution right first, avoiding the low-priority task from occupying the resources for a long time and affecting the overall performance of the system. Task state management is responsible for monitoring and converting various states (such as ready, running, blocking, etc.) of tasks, so that the tasks in the system can proceed in an orderly manner. In a task, there are usually multiple runnable entities, each of which undertakes different functions, and their running periods are scheduled based on the software counter under the task. According to the preset rules, each runnable entity is allocated running time, so as to ensure that each part of the task can work in coordination.
[0032] System tasks in embedded systems exist priority division, when executing system tasks, according to the priority order. System task priority division needs to be considered comprehensively in combination with real-time requirements, task type and function, and resource constraints. For example, according to the division of real-time requirements, hard real-time tasks must be completed within a strict time limit, and the priority is the highest; soft real-time tasks allow limited delay, and the priority is second. According to the division of task type and function, IRQ task (Interrupt ReQuest) is triggered by interrupt handler, and the priority is the highest, which needs to respond to hardware events immediately; high-priority background task processes critical real-time events, and the priority is higher; low-priority task executes non-real-time operation (such as interface refreshing, log recording). Usually, the execution order of system tasks of different priorities is as shown in Figure 1 .
[0033] An interrupt refers to the corresponding hardware or software processing due to receiving an asynchronous signal from peripheral hardware (relative to central processor and memory) or a synchronous signal from software. In embedded systems, when CPU processes tasks, it interrupts the current task in response to emergency event instructions, saves the current task state (program counter, register value) to the stack, queries the interrupt vector table according to the interrupt number, jumps to the corresponding ISR (Interrupt Service Routine, interrupt service routine) entry address, and executes the interrupt handler.
[0034] Runnable in system task refers to the smallest functional unit in the system that can be scheduled and executed, which is the code logic unit that specifically executes operations within the task. Runnable is an independent functional module within the system task, representing a schedulable execution flow, such as a data processing function, an interrupt service routine (ISR), or a timer callback. A system task can contain multiple runnables, which share the stack and task control block of the system task, but each entity has independent execution logic.
[0035] System tasks can be divided into event-type tasks and periodic tasks. Event-type tasks are triggered by specific events, such as external events (such as sensor abnormal signals, hardware interrupts, interaction instructions, etc.), and their execution time is unpredictable and depends entirely on the timing of event occurrence. Periodic tasks are tasks that are executed repeatedly at a predetermined time interval, such as timed data acquisition and system state polling, which have strict periodicity and are executed in a fixed time window. The execution time and resource occupation can be estimated in advance. According to different task types, different abnormal monitoring and positioning methods are executed to achieve fine abnormal positioning capability.
[0036] The present application can execute abnormal monitoring and positioning methods according to different system task types to achieve fine abnormal positioning capability.
[0037] In order to make the system task scheduling exception monitoring and positioning method of the present application more clear, the following system tasks and runnable entities are taken as examples for illustration.
[0038] High priority system tasks: (1) Default_Event_High_Task (high priority event type task) Runnable entities: Runnable_CAN_Event (for processing CAN bus related events), Runnable_ETH_Event (for processing Ethernet related events); (2) Default_10ms_High_Task (high priority periodic task, period 10 ms) Runnable entities: Runnable_10ms_Asw1_Period (for processing application layer software periodic tasks, which need to be executed every 10 ms), Runnable_10ms_Asw2_Period (for processing application layer software periodic tasks, which need to be executed every 10 ms).
[0039] Medium priority system tasks: (1) Default_Event_Medium_Task (medium priority event type task) Runnable entities: Runnable_LIN_Event (for processing LIN bus related events), Runnable_Flex_Event (for processing FlexRay bus related events); (2) Default_20ms_Medium_Task (medium priority periodic task, period 20 ms) Runnable entities: Runnable_20ms_Asw1_Period (for processing application layer software periodic tasks, which need to be executed every 20 ms), Runnable_20ms_Asw2_Period (for processing application layer software periodic tasks, which need to be executed every 20 ms).
[0040] Low priority system tasks: (1) Default_Event_Low_Task (low priority event type task) Runnable entities: Runnable_Asw1_Event (for processing application layer software related events), Runnable_Asw2_Event (for processing application layer software related events); (2) Default_100ms_Low_Task (low priority periodic task, period 100 ms) Runnable entities: Runnable_100ms_Asw1_Period (periodic task for processing application layer software, needs to be executed every 100 ms), Runnable_100ms_Asw2_Period (periodic task for processing application layer software, needs to be executed every 100 ms). Embodiment I:
[0041] As shown in Figure 2 The embodiment provides a system task scheduling exception monitoring and positioning method, which comprises the following steps: detecting the actual running period of a current system task; and triggering an exception monitoring and positioning process when the actual running period of the current system task is greater than a first preset time threshold. The exception monitoring and positioning process locates the cause of the scheduling exception of the current system task according to the number of executions of each interrupt in a preset period, the running state of a system task with a higher priority than the current system task, and the running state of a runnable entity in the current system task, and records corresponding exception information.
[0042] The actual running period of the current system task is obtained by a counter, a time stamp Tstart at the beginning of the execution program of the current system task, a time stamp Tend at the end of the execution program, and the actual running period of the current system task is obtained by subtracting the two time stamps (Tend-Tstart). Then, it is judged whether the actual running period exceeds the first preset time threshold, and the cycle detection is repeated.
[0043] It should be noted that the first preset time threshold is set according to the type of the system task, and the first preset time threshold of different system tasks may be different.
[0044] Referring to the above examples of system tasks and runnable entities, the first preset time threshold of the running period of the low-priority system task Default_Event_Low_Task is 3 ms. When it is detected that the actual running period of Default_Event_Low_Task exceeds 3 ms, the exception monitoring and positioning process is triggered, and the cause of the scheduling exception of Default_Event_Low_Task is found from at least one of the three dimensions of the execution of the interrupt, the running state of the system task with a higher priority than the current system task, and the running state of the runnable entity in the current system task.
[0045] As shown in Figure 3As shown, the method for locating system task scheduling abnormalities according to the execution frequency of each interrupt in a preset period comprises: detecting the execution frequency of each interrupt in a preset period, if the execution frequency of an interrupt is greater than a first preset execution frequency threshold, the interrupt frequently preoccupies resources, causing the current system task scheduling to be abnormal, and recording the interrupt information of the interrupt greater than the first preset execution frequency threshold to a log. By counting the execution frequency of each interrupt in a preset period and comparing it with the first preset execution frequency threshold, the resource preoccupation source can be quantitatively located. For the interrupt that preoccupies resources, the type code, trigger frequency, timestamp, priority, and other information of the over-standard interrupt are recorded to form a structured log. Through the interrupt type code, it can be distinguished whether the interrupt storm is caused by peripheral failure or triggered by abnormal scheduling of software logic, avoiding misjudgment. The interrupt frequency trend in the log can assist in judging occasional or continuous abnormalities (such as periodic hardware failure), providing a basis for optimizing threshold setting.
[0046] It should be noted that the preset period is determined according to the actual situation, and is between 1s-15s. In this embodiment, the preset period is 10s.
[0047] For interrupts, a 32-bit unsigned data type software counter is created. When the interrupt handler is triggered, the software counter is incremented. In the normal case of task scheduling of an embedded system, the number of interrupts triggered in a preset period is recorded multiple times when the processor runs full functions and algorithms, and the maximum value is taken as the first preset execution frequency threshold with a certain allowance. Preferably, the allowance value is 10%, and the first preset execution frequency threshold of different interrupts may be different.
[0048] As shown in Figure 4 The abnormal monitoring and positioning process locates system task scheduling abnormalities according to the running state of a system task with a higher priority than the current system task in a preset period, which comprises: if the type of the system task with a higher priority is periodic, detecting the actual running period of the runnable entity in the system task with a higher priority, if the actual running period of the runnable entity in the system task with a higher priority is greater than a second preset time threshold, the internal function logic of the runnable entity in the system task with a higher priority is abnormal, causing the current system task scheduling to be abnormal, and recording the information of the runnable entity in the system task with a higher priority to a log.
[0049] The high-priority periodic task usually plays a key role in the core function and performance of the system. By monitoring the state of the task, the task that may have a scheduling exception can be quickly focused among a large number of tasks, and the time and workload of troubleshooting can be reduced. The high-priority periodic task has a fixed execution period and a predictable behavior pattern. By analyzing the state of the runnable entity of the task, such as the start time, end time, and execution duration of the task, it can be accurately judged that the scheduling exception is caused by resource competition, unreasonable setting of task priority, or abnormality of internal function logic of the runnable entity. For example, the abnormality of the internal function logic of the runnable entity causes the runnable entity to stay in a certain function for a long time, causing the actual running period of the runnable entity to exceed the second preset time threshold, causing system resource occupation and affecting the normal operation of low-priority system tasks. The information of the runnable entity in the system task with a higher priority is recorded, including the name of the runnable entity, the trigger condition of the runnable entity, the specific function and role of the runnable entity, and the like.
[0050] It should be noted that the second preset time threshold should be set according to the type of the specific periodic system task, and the second preset time threshold of different system tasks can be different.
[0051] Further, the method for locating the system task scheduling exception according to the running state of the system task with a higher priority in the preset period further comprises: if the type of the system task with a higher priority is event type, detecting the execution times of the system task with a higher priority, and if the execution times of the system task with a higher priority are greater than a second preset execution times threshold, the system task with a higher priority is frequently activated, causing the current system task to have a scheduling exception, and the information of the system task with a higher priority is recorded to the log.
[0052] By detecting the execution times of the event type task, it can be directly judged whether the system task scheduling exception is caused by the frequent activation of the system task with a higher priority due to external event overload (such as sensor false triggering) or internal logic defect (such as interrupt flag not cleared). The information of the system task with a higher priority is recorded, including the task name, task priority, stack resource size, and the like.
[0053] It should be noted that a 32-bit unsigned data type software counter is created for the execution times of the system task with a higher priority. When the system task with a higher priority is executed and triggered, the software counter is incremented by one. In the normal case of task scheduling of the embedded system, the maximum value of the number of times triggered in the preset period is recorded when the processor runs full function and algorithm, and a certain allowance is made on this basis as the second preset execution times threshold. Preferably, the allowance value is 10%, and the second preset execution times threshold of different system tasks with a higher priority can be different.
[0054] With reference to the above examples of system tasks and runnable entities, after triggering the abnormal monitoring positioning process, the medium priority system task and the high priority system task are checked one by one. For the periodic system tasks, i.e. Default_20ms_Medium_Task (the second preset time threshold is 20 ms) and Default_10ms_High_Task (the second preset time threshold is 10 ms), it is determined whether the actual running time of the two tasks is greater than the second preset time threshold. If yes, the internal functional logic of the runnable entity in the corresponding system task is abnormal, causing the current system task scheduling to be abnormal. For example, if the actual running period of Default_20ms_Medium_Task exceeds 20 ms, it indicates that the internal functional logic of the runnable entities Runnable_20ms_Asw1_Period and Runnable_20ms_Asw2_Period in the system task is abnormal. At this time, the relevant information of Runnable_20ms_Asw1_Period and Runnable_20ms_Asw2_Period is recorded in the log. For the event type system tasks, i.e. Default_Event_Medium_Task (the second preset execution frequency threshold is 3000 times) and Default_Event_High_Task (the second preset execution frequency threshold is 3000 times), it is determined whether the actual execution frequency of the two tasks is greater than the second preset execution frequency threshold. If yes, the corresponding system task is frequently activated, causing the current system task scheduling to be abnormal. For example, if the actual execution frequency of Default_Event_High_Task exceeds 3000 times, the task name, task priority, stack resource size, runnable entity information and other relevant information of the task are recorded in the log.
[0055] As shown in Figure 5 The abnormal monitoring positioning process according to the method for positioning system task scheduling abnormality according to the running state of the runnable entity in the current system task in a preset period, includes: if the type of the current system task is event type, detecting the execution frequency of each runnable entity in the current system task, if there is a runnable entity in the current system task whose execution frequency is greater than the third preset execution frequency threshold, the runnable entity in the current system task is frequently activated, causing the current system task scheduling to be abnormal, and the information of the runnable entity in the current system task whose execution frequency is greater than the third preset execution frequency threshold is recorded in the log.
[0056] The abnormality positioning scheduling technology according to the state of the executable entity in the event type system task is an event-driven system monitoring and fault diagnosis method. Each executable entity has a specific running state and behavior mode in the system task. Through real-time monitoring and analysis of the state of the executable entity in the system task, the specific position of the abnormality can be accurately determined. If the execution times of the executable entity in the current system task are greater than the third preset execution times threshold, that is, the number and times of the executable entity calling when running a task are less, and the task execution time is short, and because multiple executable entities are frequently activated, multiple and multiple executable entities need to be called when running a task, and the task execution time is long, it is indicated that the executable entity in the current system task is frequently activated, which leads to the abnormality of the current system task scheduling. The information of the executable entity in the current system task greater than the third preset execution times threshold is recorded, including the name of the executable entity, the trigger condition of the executable entity, the specific function and role of the executable entity, etc.
[0057] It should be noted that a 32-bit unsigned data type software counter is created for the execution times of the executable entity. When the executable entity is executed, the software counter is incremented by one. In the normal case of the task scheduling of the embedded system, the maximum value of the number of triggers in the preset period is recorded when the processor runs the full function and algorithm, and a certain width is released on this basis as the third preset execution times threshold. Preferably, the width value is 10%, and the third preset execution times threshold of different executable entities may be different.
[0058] Further, the abnormality monitoring positioning process is a method for positioning the system task scheduling abnormality according to the running state of the executable entity in the current system task in the preset period, which comprises: if the execution times of the executable entity in the current system task are less than or equal to the third preset execution times threshold, detecting the actual execution period of the executable entity in the system task, if the actual execution period of the executable entity in the current system task is greater than the third preset time threshold, the internal function logic of the executable entity in the current system task is abnormal, which leads to the abnormality of the current system task scheduling, and the information of the executable entity in the current system task is recorded to the log.
[0059] If the execution times of the executable entities in the current system are within the normal range, it is necessary to consider whether the actual execution cycle of the executable entity in the current system task is abnormal. By analyzing the state of the executable entity, such as the start time, end time, and execution duration of the task, it is determined whether the current system task scheduling is abnormal due to the abnormality of the internal function logic of the executable entity. The abnormality of the internal function logic of the executable entity causes the executable entity to stay in a certain function function for a long time, resulting in the actual running cycle of the executable entity exceeding the third preset time threshold, thereby causing the current system task to run abnormally. The information of the executable entity in the current system task is recorded, including the name of the executable entity, the trigger condition of the executable entity, the specific function and role of the executable entity, etc.
[0060] Further, the abnormal monitoring and positioning process according to the method of positioning the system task scheduling abnormality according to the running state of the executable entity in the current system task within a preset period includes: if the type of the current system task is periodic, detecting the actual execution cycle of the executable entity in the system task, if the actual execution cycle of the executable entity in the current system task is greater than the fourth preset time threshold, the internal function logic of the executable entity in the current system task is abnormal, causing the current system task to be abnormal, and recording the information of the executable entity in the current system task to the log.
[0061] If the type of the current system task is periodic, by analyzing the state of the executable entity, such as the start time, end time, and execution duration of the task, it is determined whether the current system task scheduling is abnormal due to the abnormality of the internal function logic of the executable entity. The abnormality of the internal function logic of the executable entity causes the executable entity to stay in a certain function function for a long time, resulting in the actual running cycle of the executable entity exceeding the fourth preset time threshold, thereby causing the current system task to run abnormally. The information of the executable entity in the current system task is recorded, including the name of the executable entity, the trigger condition of the executable entity, the specific function and role of the executable entity, etc.
[0062] Continuing with the above example of system tasks and runnable entities, after triggering the anomaly monitoring and location process, analyze Default_Event_Low_Task. Default_Event_Low_Task is an event-type task. The actual execution counts of Runnable_Asw1_Event (the third preset execution count threshold of 3000 times) and Runnable_Asw2_Event (the third preset execution count threshold of 3000 times) are detected. If the actual execution counts of either runnable entity exceed the third preset execution count threshold, it indicates that the runnable entities within Default_Event_Low_Task are frequently activated, resulting in a Default_Event_Low_Task scheduling anomaly. For example, if the actual execution count of Runnable_Asw1_Event exceeds 3000 times, relevant information about Runnable_Asw1_Event is recorded in the log, including the name of the runnable entity, the triggering conditions for the runnable entity, and the specific function and role of the runnable entity. If the actual execution times of the two runnable entities are both less than or equal to the third preset execution times threshold, detect the actual execution periods of Runnable_Asw1_Event (third preset time threshold 2ms) and Runnable_Asw2_Event (third preset time threshold 2ms). If the actual execution period of the runnable entity is greater than the third preset time threshold, the internal functional logic of the runnable entity is abnormal, resulting in the current system task scheduling abnormality. For example, the actual execution period of Runnable_Asw2_Event exceeds 2ms. Record the relevant information of Runnable_Asw2_Event in the log, including the name of the runnable entity, the triggering conditions of the runnable entity, the specific functions and roles of the runnable entity, etc.
[0063] It should be noted that the above abnormal monitoring and positioning process includes three sub-step monitoring and positioning processes for the execution status of interrupts in the system, the running status of higher priority system tasks, and the running status of runnable entities in the current system task. The three sub-step monitoring and positioning processes can be processed in parallel or serially according to the actual computing power of the processor. In the case of parallel processing, Figure 3 、 Figure 4 and Figure 5 The corresponding positioning process is carried out synchronously. In the case of serial processing, Figure 3 、 Figure 4 and Figure 5 The corresponding positioning process is executed in sequence and stops when an abnormality is found, or stops after all abnormalities are checked. Figure 3 、 Figure 4 and Figure 5At least one of the corresponding positioning procedures is detected and positioned, preferably all three.
[0064] Through the above-mentioned abnormal monitoring positioning procedure, after positioning the cause of the current system task scheduling exception, a warning information or prompt information is issued to alert system maintenance. Specifically, the warning information or prompt information should include the system task that appears abnormal, the brief information of the cause of the system task exception, and the possible coping strategy. To help users handle exceptions and ensure the safe operation of the system. In addition, the warning level can be set according to the abnormal reason, the abnormal influence degree, etc. When issuing the warning information or prompt information, the warning level is given, including high-level warning, medium-level warning, and low-level warning. For different warning levels, the corresponding processing time is given. The setting of the warning level is as follows: Based on the classification of abnormal reasons: According to the positioning of the cause of the current system task scheduling exception, different warning levels are set. For example, if the exception is caused by the failure of a key runnable entity, it can be set as a high-level warning; if the exception is caused by the temporary occupation of resources by a high-priority task, it can be set as a medium-level warning.
[0065] Combined with the classification of abnormal influence degree: Consider the influence degree of the exception on the whole system, such as whether it causes part of the function to be unable to normally use, whether it affects the stability of the system, etc. If the exception seriously affects the normal operation of the system, it is set as a high-level warning; if it only has a slight influence on the system performance, it is set as a low-level warning.
[0066] In this embodiment, the actual running period of the task is detected and compared with the first preset time threshold, the abnormal immediate triggering monitoring is realized, once the period is exceeded, the abnormal monitoring positioning procedure is started, the diagnosis is carried out from three dimensions of the number of interruption execution times in the system, the running state of the system task with higher priority, and the running state of the runnable entity in the current system task, the specific reason causing the abnormal actual running period of the system task is quickly and accurately positioned, and the corresponding abnormal information is recorded. After the end of the abnormal monitoring positioning procedure, the warning information or prompt information is actively issued to inform the user to maintain the system in time, to help the user handle the exception and ensure the safe operation of the system. For example, when applied in the embedded system of the vehicle, the output warning information or prompt information can let the user go to the vehicle maintenance point for maintenance in time, which can help the technical personnel to discover and position the system exception in time during the software development and testing process of the embedded system of the vehicle or during the vehicle maintenance, and to carry out fine analysis and processing on the abnormal phenomenon, avoiding the waste of manpower and time to check each interruption, system task and runnable entity one by one, and improving the timely processing ability and processing efficiency of the technical personnel on the abnormal task of the embedded system. Embodiment two:
[0067] As Figure 6As shown, the present application also provides a system task scheduling abnormality monitoring and positioning device, which mainly includes: a processing module 100 and a storage module 200 The detection module 100 is used to detect the actual operation cycle of system tasks and executable entities; it is used to detect the number of executions of system task interrupts, the number of executions of system tasks, and the number of executions of executable entities; the detection module 100 may include a microcontroller, a counter, an interrupt controller, etc., as well as necessary peripheral circuits to realize its functions.
[0068] The processing module 200 is used to detect the actual operating cycle of system tasks and executable entities, and when the actual operating cycle of the current system task is greater than the first preset time threshold, trigger the abnormality monitoring and positioning process described in Example 1. That is, based on the data detected by the detection module, the cause of the abnormality in system task scheduling is analyzed and located. The processing module 200 may include a processor chip and necessary peripheral circuits to realize its functions. The processing module 200 will also record the relevant data of the located cause of the abnormality in system task scheduling into the storage module 300, and output early warning information or prompt information to the user, notifying the user to maintain the system in time. The early warning information or prompt information should include brief information about the abnormal system task or entity and possible response strategies. This helps users deal with abnormalities and ensure the safe operation of the system.
[0069] The storage module 300 records the relevant data causing the abnormal reasons for the system task scheduling. The storage module 300 is a non-volatile memory. The abnormal factor information stored in the non-volatile memory can be read through the log command. Example 3:
[0070] The present application also provides a computer-readable storage medium, and the above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or can be implemented as a computer instruction code that can be recorded in a storage medium, or can be implemented as a computer instruction code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer instruction code. When the computer instruction code is accessed and executed by the computer, processor or hardware, the above-mentioned system task scheduling anomaly monitoring and positioning method is implemented.
[0071] Although example embodiments have been described herein with reference to the accompanying drawings, it is to be understood that the example embodiments are only exemplary and are not intended to limit the scope of the present application. Those skilled in the art can make various changes and modifications of the example embodiments without departing from the scope and spirit of the present application. All such changes and modifications are intended to be included within the scope of the present application as defined by the appended claims.
[0072] Those skilled in the art can realize the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be realized by electronic hardware, or a combination of computer software and electronic hardware. Whether the functions are performed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0073] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0074] The various component embodiments of the present application can be implemented in hardware, or implemented in software modules running on one or more processors, or implemented in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some modules according to the embodiments of the present application. The present application can also be implemented as a device program (for example, a computer program and a computer program product) for executing part or all of the methods described herein. Such program implementing the present application can be stored on a computer readable medium, or can have one or more signals in the form. Such signals can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0075] It is to be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting; it is not intended to exclude myriad other embodiments of the present application that other inventors can develop based on the description provided herein. It must be stressed, however, that any combination of the components or features taught according to any aspect of the present application can be important sufficient to confer "patentable" subject matter status on a single, stand-alone claim. It is therefore intended to embrace all such alternatives, modifications and variations that fall within the spirit and broad scope of the appended claims. One skilled in the art will appreciate that the application can be practiced with embodiments other than those described. The disclosed embodiments are illustrative only and not restrictive.
[0076] While the application has been described in connection with specific embodiments thereof, it will be understood that it is capable of further modifications and this application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended to cover and embrace all adaptations or modifications of the application.
Claims
1. A system task scheduling exception monitoring and locating method, characterized in that, The method comprises the following steps: detecting an actual running period of a current system task; triggering an abnormal monitoring positioning process when the actual running period of the current system task is greater than a first preset time threshold; wherein the abnormal monitoring positioning process locates a cause of scheduling abnormality of the current system task according to at least one of an execution frequency of each interrupt in a preset period, a running state of a system task with a higher priority than the current system task, and a running state of a runnable entity in the current system task, and records corresponding abnormal information.
2. The system task dispatch exception monitoring and locating method according to claim 1, characterized in that, The method of locating the cause of scheduling abnormality of the current system task according to the execution frequency of each interrupt in the preset period comprises: detecting the execution frequency of each interrupt in the preset period, and if the execution frequency of the interrupt is greater than a first preset execution frequency threshold, the interrupt frequently preoccupies resources to cause the scheduling abnormality of the current system task, and interrupt information of the interrupt greater than the first preset execution frequency threshold is recorded to a log.
3. The system task dispatch exception monitoring and locating method according to claim 1, characterized in that, The type of the current system task and the type of the system task with the higher priority at least include event type or period type.
4. The system task dispatch exception monitoring and locating method according to claim 3, characterized in that, The method of locating the cause of scheduling abnormality of the current system task according to the running state of the system task with the higher priority than the current system task in the preset period comprises: if the type of the system task with the higher priority is period type, detecting an actual running period of a runnable entity in the system task with the higher priority, and if the actual running period of the runnable entity in the system task with the higher priority is greater than a second preset time threshold, internal functional logic abnormality of the runnable entity in the system task with the higher priority causes the scheduling abnormality of the current system task, and information of the runnable entity in the system task with the higher priority is recorded to the log.
5. The system task dispatch exception monitoring and locating method according to claim 4, characterized in that, The method of locating the cause of scheduling abnormality of the current system task according to the running state of the system task with the higher priority than the current system task in the preset period comprises: if the type of the system task with the higher priority is event type, detecting an execution frequency of the system task with the higher priority, and if the execution frequency of the system task with the higher priority is greater than a second preset execution frequency threshold, the system task with the higher priority is frequently activated to cause the scheduling abnormality of the current system task, and information of the system task with the higher priority is recorded to the log.
6. The system task dispatch exception monitoring and locating method according to claim 3, characterized in that, The method of locating the cause of scheduling abnormality of the current system task according to the running state of the runnable entity in the current system task in the preset period comprises: if the type of the current system task is event type, detecting an execution frequency of each runnable entity in the current system task, and if the execution frequency of the runnable entity in the current system task is greater than a third preset execution frequency threshold, the runnable entity in the current system task is frequently activated to cause the scheduling abnormality of the current system task, and information of the runnable entity in the current system task greater than the third preset execution frequency threshold is recorded to the log. If the execution times of the runnable entity in the current system task is less than or equal to a third preset execution times threshold, the actual execution period of the runnable entity in the system task is detected, and if the actual execution period of the runnable entity in the current system task is greater than a third preset time threshold, the internal functional logic of the runnable entity in the current system task is abnormal, which leads to the abnormal scheduling of the current system task, and the information of the runnable entity in the current system task is recorded to the log.
7. The system task dispatch exception monitoring and locating method according to claim 6, characterized in that, The method for locating the cause of the abnormal scheduling of the current system task according to the running state of the runnable entity in the current system task within a preset period comprises: If the type of the current system task is periodic, the actual execution period of the runnable entity in the system task is detected, and if the actual execution period of the runnable entity in the current system task is greater than a fourth preset time threshold, the internal functional logic of the runnable entity in the current system task is abnormal, which leads to the abnormal scheduling of the current system task, and the information of the runnable entity in the current system task is recorded to the log.
8. The system task dispatch exception monitoring positioning method according to any one of claims 1-6, characterized in that, Further comprising: After locating the cause of the abnormal scheduling of the current system task, a warning information or a prompt information is sent to alert the system maintenance.
9. A system task scheduling exception monitoring and locating apparatus, characterized by comprising: Comprise: The processing module is used for monitoring the actual running period of the current system task, and triggering the abnormal monitoring and locating process when the actual running period of the current system task is greater than a first preset time threshold; wherein the abnormal monitoring and locating process locates the cause of the abnormal scheduling of the current system task according to at least one of the execution times of each interruption within a preset period, the running state of the system task with a higher priority than the current system task, and the running state of the runnable entity in the current system task, and records the corresponding abnormal information; And The storage module is used for storing the abnormal information.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the system task scheduling abnormal monitoring and locating method according to any one of claims 1 to 8.