A timeout task positioning method, device and electronic equipment

By quantifying the CPU load when a task times out, the source of the timeout task can be quickly identified, solving the problem of low efficiency in existing technologies. This achieves efficient task timeout cause localization, reducing manual operation costs and system risks.

CN123157495APending Publication Date: 2026-11-24BYD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611208514.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-10
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In vehicle systems with extremely high real-time requirements, such as intelligent driving, existing technologies use the callback function mechanism of AUTOSAR OS to locate tasks that time out, resulting in an excessively wide coverage area, leading to a large amount of debugging work and low positioning efficiency.

Method used

When a task timeout is detected, the actual CPU load of the executing task is quantified to identify the source task causing the timeout. The source timeout task is quickly identified by using the ratio of actual CPU load to average CPU load and the load increase value.

Benefits of technology

It significantly improves the efficiency of locating the cause of task timeouts, reduces the manual troubleshooting costs for operations and maintenance personnel, avoids system stability risks caused by code modifications, and improves the level of automation in locating the cause.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157495A_ABST
    Figure CN123157495A_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, and electronic device for locating timeout tasks, applied in the field of data processing technology. It aims to improve the efficiency of locating the cause of task timeouts in real-time systems such as intelligent driving. The method for locating timeout tasks includes: upon detecting a timeout of a first task, determining the actual CPU load of a second task currently executing during the timeout period of the first task; wherein the timeout period is the time interval between the start time of the first task and the current time; the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period; based on the actual CPU load, determining the source timeout task that caused the first task to time out, enabling rapid location of the source timeout task when timeout tasks exist in an intelligent cockpit system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus and electronic device for locating timeout tasks. Background Technology

[0002] In vehicle systems with extremely high real-time requirements, such as intelligent driving, the operating system (AUTOmotive OpenSystem Architecture Operating System, AUTOSAR OS), as the underlying software foundation, is a core component that ensures task scheduling and functional safety, and its importance is self-evident.

[0003] In existing technologies, systems typically rely on the AUTOSAR OS's callback function (Error Hook) mechanism to capture task timeout events. Once a timeout is triggered, the system reads the currently running tasks and then investigates the true source of the timeout by instrumenting code and measuring the time of each task and interrupt with a higher priority than the current task. However, this investigation method has an overly broad scope, involving a large number of irrelevant tasks and interrupt paths, which leads to a sharp increase in debugging workload and low localization efficiency. Summary of the Invention

[0004] The purpose of this application is to provide a method, apparatus, and electronic device for locating timed-out tasks, aiming to improve the efficiency of locating the cause of task timeout in real-time systems such as intelligent driving.

[0005] In a first aspect, this application provides a method for locating timeout tasks, comprising: upon detecting a timeout of a first task, determining the actual central processing unit (CPU) load of a second task currently executing during the timeout period of the first task; wherein the timeout period is the time between the start time of the first task and the current time; the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period; and based on the actual CPU load, determining the source timeout task that caused the timeout of the first task.

[0006] The timeout task location method adopted in this application can quantify the contribution of the second task to the system's CPU resources by measuring the actual CPU load of the second task being executed during the timeout period of the first task when the first task is detected to have timed out. This can accurately and quickly identify the source timeout task, significantly improve the efficiency of locating the cause of system task timeouts, and reduce the manual troubleshooting costs for operation and maintenance personnel.

[0007] Optionally, based on the actual CPU load, the source timeout task that caused the first task to time out is determined, including: determining the average CPU load of the second task; the average CPU load is the average of the statistical CPU load corresponding to each sampling period during the timeout period; the statistical CPU load is the ratio between the net execution time of the second task in each sampling period and the total duration of each sampling period; and determining the source timeout task based on the average CPU load and the actual CPU load.

[0008] Optionally, the source timeout task is determined based on the average CPU load and the actual CPU load, including: determining the CPU load increase value of the second task based on the load difference between the actual CPU load and the average CPU load; and determining the source timeout task based on the CPU load increase value.

[0009] Optionally, determining the source timeout task based on the CPU load growth value includes: sorting the second task in descending order according to the CPU load growth value to obtain a task descending sequence; and taking the first preset number of second tasks in the task descending sequence as the source timeout task.

[0010] Optionally, the method further includes: after determining the source timeout task, locating the target runnable entity function that caused the timeout based on the execution duration of each runnable entity function in the source timeout task.

[0011] Optionally, based on the execution time of each runnable entity function in the source timeout task, the target runnable entity function causing the timeout is located, including: determining the time consumption contribution of each runnable entity function based on the ratio of the execution time of each runnable entity function to the net execution time of the source timeout task; and locating the target runnable entity function based on the time consumption contribution.

[0012] Optionally, based on the contribution of time consumption, the target runnable entity function is located, including: sorting the executable entity functions in descending order according to their contribution of time consumption to obtain a descending sequence of entity functions; and determining the second-most preset number of executable entity functions in the descending sequence of entity functions as the target runnable entity functions.

[0013] Optionally, checkpoint functions are set at the beginning and end of the source timeout task and between each runnable entity function; the process of determining the execution duration of each runnable entity function includes: determining the execution duration of each runnable entity function based on the two adjacent checkpoint functions of each runnable entity function.

[0014] Secondly, this application provides a timeout task location device, including: a first determining module and a second determining module; the first determining module is used to determine the actual central processing unit (CPU) load of a second task being executed during the timeout period of the first task when a timeout of the first task is detected; wherein, the timeout period is the period between the start time of the first task and the current time; the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period; the second determining module is used to determine the source timeout task that caused the timeout of the first task based on the actual CPU load.

[0015] Optionally, the second determining module is specifically used to determine the average CPU load of the second task; the average CPU load is the average of the statistical CPU load corresponding to each sampling period during the timeout period; the statistical CPU load is the ratio between the net execution time of the second task in each sampling period and the total duration of each sampling period; based on the average CPU load and the actual CPU load, the source timeout task is determined.

[0016] Optionally, the second determining module is specifically used to determine the CPU load increase value of the second task based on the load difference between the actual CPU load and the average CPU load; and to determine the source timeout task based on the CPU load increase value.

[0017] Optionally, the second determining module is specifically used to sort the second tasks in descending order according to the CPU load growth value to obtain a task descending sequence; and to take the first preset number of second tasks in the task descending sequence as the source timeout tasks.

[0018] Optionally, the timeout task location device further includes: a location module; the location module is used to locate the target runnable entity function that caused the timeout after determining the source timeout task, based on the execution duration of each runnable entity function in the source timeout task.

[0019] Optionally, the localization module is specifically used to determine the time consumption contribution of each executable entity function based on the ratio of the execution time of each executable entity function to the net execution time of the source timeout task; and to locate the target runnable entity function based on the time consumption contribution.

[0020] Optionally, the positioning module is specifically used to sort the executable entity functions in descending order according to their time contribution to obtain a descending sequence of entity functions; and to determine the second-to-last preset number of executable entity functions in the descending sequence of entity functions as the target runnable entity functions.

[0021] Optionally, checkpoint functions are set at the beginning and end of the source timeout task and between each runnable entity function; the process of determining the execution duration of each runnable entity function includes: determining the execution duration of each runnable entity function based on the two adjacent checkpoint functions of each runnable entity function.

[0022] Thirdly, this application provides an electronic device comprising: a processor and a memory; the memory storing processor-executable instructions; when the processor is configured to execute the instructions, causing the electronic device to implement the method of the first aspect described above.

[0023] Fourthly, this application provides a vehicle that includes the electronic equipment described in the third aspect.

[0024] Fifthly, this application provides a computer-readable storage medium comprising: computer software instructions; which, when executed in an electronic device, cause the electronic device to implement the method described in the first aspect.

[0025] Sixthly, this application provides a computer program product comprising a computer program; when the computer program is run in an electronic device, it causes the electronic device to implement the method described in the first aspect.

[0026] The beneficial effects of the second to sixth aspects mentioned above are described in the corresponding description of the first aspect and will not be repeated here. Attached Figure Description

[0027] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 1 ; Figure 2 A schematic diagram illustrating a data storage process provided in an embodiment of this application; Figure 3 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 2 ; Figure 4 A schematic diagram illustrating a process for determining average CPU load, provided in an embodiment of this application; Figure 5 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 3 ; Figure 6 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 4 ; Figure 7 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 5 ; Figure 8 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 6 ; Figure 9 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 7 ; Figure 10 A flowchart illustrating a method for locating timeout tasks provided in this application embodiment. Figure 8 ; Figure 11 A schematic diagram illustrating the composition of a timeout task positioning device provided in an embodiment of this application; Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0029] In embodiments of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0030] In the AUTOSAR OS multi-task preemptive scheduling environment, the root cause of task timeouts is often not the timed-out task itself. Due to high-priority tasks occupying the CPU for extended periods, frequent interruptions by interrupt service routines disrupting the execution window, and cascading blocking caused by shared resource contention, timeouts typically manifest as problems with the "blocked" task, while the true resource consumers are hidden within higher-priority tasks or interrupts. However, AUTOSAR OS itself does not provide a task-level CPU usage statistics mechanism. When ErrorHook is triggered, it can only detect the occurrence of a timeout event and cannot directly trace back to the source task causing other timeouts. This implicit cross-task dependency and lack of observation capabilities mean that troubleshooting naturally requires covering all high-priority tasks and interrupts, resulting in a wide scope, a large workload, and a lack of automated methods to narrow down the scope.

[0031] Even after identifying a suspect task, it typically contains multiple runnable entities with unevenly distributed execution times. AUTOSAR OS also doesn't record function-level execution times, meaning a timeout might be caused by a single function stalling during a call. Current methods rely on instrumenting all functions one by one to locate critical code, multiplying the investigation steps from task to function. Even more challenging is the fact that instrumentation requires code modification and recompilation, altering the system's original execution sequence, potentially distorting investigation results or introducing new timeouts, and significantly lengthening the localization cycle due to repeated debugging. These factors collectively constitute the core engineering obstacle hindering the efficient localization of task timeout causes.

[0032] To address the aforementioned technical issues, this application provides a method for locating timeout tasks. When a timeout is detected in a first task, the actual CPU load of the second task can be quantified by the proportion of the net execution time of the second task running during the timeout period. This allows for accurate and rapid identification of the source timeout task based on the actual CPU load of the second task, thereby improving the efficiency of locating the source of the timeout.

[0033] The embodiments provided in this application will now be described in detail with reference to the accompanying drawings.

[0034] In some embodiments, the execution subject of the timeout task location method provided in this application may be a server cluster composed of multiple servers, a single server, a computer, or any device or equipment capable of locating the source of timeout, such as a processor or processing chip in a server or computer. This application embodiment does not limit this.

[0035] See Figure 1 This is a flowchart illustrating a method for locating timeout tasks provided in an embodiment of this application. Figure 1 As shown, the method for locating timeout tasks provided in this application specifically includes the following steps S101~S103: S101. If the first task times out, determine the actual CPU load of the second task being executed during the timeout period of the first task.

[0036] As a feasible implementation method, the ErrorHook task timeout mechanism provided by AUTOSAR OS can be used to detect whether the first task has timed out.

[0037] In an exemplary embodiment, when AUTOSAR OS detects that the execution time of the first task exceeds its corresponding preset threshold, it triggers the ErrorHook error response mechanism to indicate that the first task has timed out.

[0038] As a feasible implementation method, when the first task times out, the start time of the first task is determined, and the time period between the current time and the start time is determined as the timeout period. Based on the relative position of the start time of each task on the time axis, all the second tasks that have run in the timeout period are selected, and the net execution time of each second task in the timeout period is calculated. The ratio between the net execution time and the total time of the timeout period is determined as the actual CPU load of the second task.

[0039] The timeout period is the time between the start time of the first task and the current time.

[0040] The start execution time, also known as the activation time of the first task, refers to the specific point in time when the task is activated by the AUTOSAR OS scheduler and begins to execute its own logic. It is used to define the time range of task execution and provide a time reference for subsequent CPU load calculation and timeout period screening.

[0041] The actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period, which reflects the load contribution of each second task during the timeout period.

[0042] Net execution time refers to the pure time consumed by a single task during the timeout period solely for its own logical execution, excluding irrelevant time such as task scheduling waits, interrupt service routine usage, system idle time, and blocking waits caused by competing with other tasks for shared resources. This parameter accurately reflects the computational intensity and execution efficiency of a task and is a core fundamental indicator for measuring the actual CPU resource usage of each task.

[0043] In the exemplary embodiment, the net execution time can be determined as follows: a first timestamp is recorded at the start of the task's execution, and a second timestamp is recorded before the task exits. The difference between the two timestamps is the total execution time of the task. During the execution of the task, the time overhead (i.e., non-self-execution overhead) caused by interrupt nesting or preemption by higher priority tasks is accumulated and recorded. The total execution time of the task is then subtracted from the non-self-execution overhead to obtain the net execution time of the task in the corresponding runtime segment.

[0044] It should be understood that in real-time operating systems such as AUTOSAR, obtaining the precise "seconds" of actual CPU load for a single task often requires complex timestamp collection and recording. However, using a "duration percentage" approach only requires comparing the ratio deviation between the theoretical and actual duration (e.g., the actual net execution time is 2.5 times the theoretical time) to directly determine whether the actual CPU load is abnormal. This method avoids absolute "duration" measurement errors, making the judgment standard more portable across hardware platforms with different clock speeds.

[0045] Optionally, such as Figure 2 As shown, at the end position of each task, obtain the net execution time and the start execution time of the current task in this cycle; save the net execution time and the start execution time into array B1.

[0046] The B1 array is a circular buffer (or ring array) used to store key time information for each task within a single execution cycle. Specifically, each element of the B1 array corresponds to one execution record of a task, containing two fields: the net execution time of the task within the current cycle and the start time of the current cycle, used to track the historical execution status of each task.

[0047] S102. Based on the actual CPU load, determine the source timeout task that caused the first task to time out.

[0048] As a feasible implementation method, a theoretical CPU load is preset for each task; the difference between the actual CPU load and the theoretical CPU load of the second task is determined; and the second task with a difference greater than or equal to the preset difference is identified as the source timeout task.

[0049] The theoretical CPU load is determined based on the theoretical net execution time and theoretical cycle of each task. Specifically, theoretical CPU load = theoretical net execution time / theoretical cycle, which is used to characterize the expected CPU resource utilization of the task under ideal conditions (i.e., no interruption preemption, no resource contention blocking, and scheduling proceeding exactly as expected). It is a benchmark value for measuring whether the actual running state of the task deviates from the expectation.

[0050] A source-timeout task refers to a task whose actual CPU load is significantly higher than the theoretical expectation, resulting in excessive consumption of system resources and causing the first task to time out due to insufficient scheduling time. When the difference between the actual CPU load and the theoretical CPU load of the second task is greater than or equal to a preset difference, it indicates that the task has abnormal excessive consumption of CPU resources, and it is identified as the actual source of resource consumption and the root cause of the first task's timeout.

[0051] The timeout task location method adopted in this application can quantify the contribution of the second task to the system's CPU resources by measuring the actual CPU load of the second task being executed during the timeout period of the first task when the first task is detected to have timed out. This can accurately and quickly identify the source timeout task, significantly improve the efficiency of locating the cause of system task timeouts, and reduce the manual troubleshooting costs for operation and maintenance personnel.

[0052] As a feasible implementation method, such as Figure 3 As shown, step S102 above can also be implemented as the following steps: S301. Determine the average CPU load of the second task.

[0053] The average CPU load is the average of the statistical CPU load for each sampling period during the timeout period. It can accurately quantify the average CPU load of a task, thereby accurately assessing the resource usage trend of the task during the timeout period.

[0054] The statistical CPU load is the ratio between the net execution time of the second task in each sampling period and the total duration of each sampling period.

[0055] For example, such as Figure 4 As shown, with a preset time period as the sampling period, the current cumulative net execution time is recorded at the end of each task; the net execution time of each task in the previous sampling period is calculated, and the ratio of the net execution time to the total time of the previous sampling period is calculated. The resulting ratio is the statistical CPU load of the task in the current sampling period; the average of the statistical CPU load of all sampling periods in the timeout period is taken to obtain the average CPU load of the task.

[0056] The sampling period can be set based on system load strategies or fixed time intervals; for example, the sampling period can be 1 second.

[0057] The net execution time of each task within the sampling period can be the difference between the current cumulative net execution time and the cumulative net execution time of the previous sampling period.

[0058] S302. Determine the source timeout task based on average CPU load and actual CPU load.

[0059] As a feasible implementation method, the load difference between the average CPU load and the actual CPU load is calculated; the second task whose load difference is greater than or equal to a preset difference is identified as the source timeout task.

[0060] It should be understood that actual CPU load reflects the proportion of CPU resources actually used by a task in the current instant or within a very short window; it represents the task's current true running state. Average CPU load, on the other hand, is a statistical result based on historical data within the timeout period, representing the resource usage benchmark of the task under normal historical performance or expected running level. When the load difference between average CPU load and actual CPU load increases significantly (i.e., greater than or equal to a preset difference), it indicates that the task's resource usage at the current moment has experienced unexpected and drastic fluctuations. Such drastic positive fluctuations (actual load much higher than average load) usually mean that the task has encountered abnormal resource contention, deadlock waiting, or a sudden drop in execution efficiency at the current moment, causing it to instantly occupy a large amount of CPU resources and fail to progress as expected, thus triggering a timeout. Therefore, by identifying tasks with load differences exceeding a preset threshold as "source timeout tasks," the root cause of timeout failures can be accurately located from among many tasks, rather than merely focusing on the superficial symptoms of timeout.

[0061] As a feasible implementation method, such as Figure 5 As shown, step S302 above can also be implemented as the following steps: S501. Based on the load difference between the actual CPU load and the average CPU load, determine the CPU load increase value for the second task.

[0062] For example, the CPU load increase value can satisfy: CPU load increase value = actual CPU load - average CPU load.

[0063] It should be understood that the load difference between the actual CPU load and the average CPU load can accurately quantify the degree of load abnormality of each second task. When the CPU load growth value is positive and the value is large, it indicates that the resource utilization rate of the task at the current moment is much higher than its historical average level. It is very likely that it has encountered severe resource contention, infinite loop or abnormal calculation, which leads to a sharp drop in its execution efficiency, thus becoming the source of the timeout of the first task.

[0064] S502. Based on the CPU load growth value, determine the source timeout task.

[0065] In the exemplary embodiment, a preset growth threshold is set; the second task whose CPU load growth value exceeds the preset growth threshold is identified as the source timeout task.

[0066] The preset growth threshold can be dynamically adjusted based on the task type, business priority, historical load characteristics, or current system load status of the second task.

[0067] For example, for tasks with high real-time requirements (such as video encoding and decoding), the allowable range of load fluctuations is small, so a lower preset growth threshold can be set to quickly capture minor anomalies; for background batch processing tasks (such as log archiving), the load fluctuations may be large, so a higher preset growth threshold can be set to avoid misjudgments.

[0068] It should be understood that by using the load difference between the actual CPU load and the average CPU load, the current load abnormality of each second task can be accurately quantified. Based on the CPU load growth value, the source timeout task that caused the first task to time out can be accurately located from among many concurrent tasks.

[0069] As a feasible implementation method, such as Figure 6 As shown, step S502 above can also be implemented as the following steps: S601. Sort the second task in descending order according to the CPU load increase value to obtain the task descending sequence.

[0070] It should be understood that the descending order of tasks can reflect the relative ranking and priority of the abnormal load of each second task in a way that is intuitive.

[0071] The tasks at the top of the descending task sequence (i.e., the tasks with the largest CPU load increase) represent the tasks with the most drastic deviation from historical benchmarks and the highest degree of abnormality. They are very likely to be the core source or primary suspect that caused the first task to time out. The tasks at the bottom of the descending task sequence have relatively gentle load increases and are more likely to be secondary victims affected by the source task or interference items with normal fluctuations.

[0072] S602, take the second task in the first preset number of tasks in the descending task sequence as the source timeout task.

[0073] The first preset quantity can be dynamically determined based on factors such as the system's concurrency scale, historical fault characteristics, business fault tolerance rate, or maintenance personnel configuration. For example, the first preset quantity can be two.

[0074] It should be understood that by directly designating the second task in the first preset number of tasks in the descending task sequence as the source timeout task, the system or operations personnel can concentrate limited resources on the few most suspicious tasks by limiting the scope of investigation (focusing only on the Top K), significantly shortening the time to locate faults (MTTR), and avoiding frequent changes in judgment results due to small fluctuations in thresholds.

[0075] In some embodiments, when the source timeout task is identified, in order to accurately locate the specific code logic that caused the timeout, perform root cause analysis of the fault, and assist in repair, it is necessary to further identify the key code in the source timeout task.

[0076] As a feasible implementation method, such as Figure 7 As shown, after step S102, the method for locating timeout tasks further includes: S701, after determining the source timeout task, locating the target runnable entity function that caused the timeout based on the execution time of each runnable entity function in the source timeout task.

[0077] Among them, a runnable entity function refers to an independent code unit that constitutes the task execution logic. It has complete input and output logic and is the smallest functional unit for task execution. Its execution time directly affects the overall execution efficiency of the task and is also the core object for locating critical timeout code.

[0078] In the exemplary embodiment, the theoretical execution time (or baseline execution time) of each runnable entity function is obtained, and the time difference (or deviation value) between the actual execution time and the theoretical execution time is calculated; runnable entity functions whose time difference is greater than or equal to a preset time difference threshold are identified as target runnable entity functions that cause timeouts.

[0079] It should be understood that by measuring the execution time of each runnable entity function in the source timeout task, the contribution of each function to the overall task time can be accurately quantified, thereby quickly and accurately locating the target runnable entity function that caused the timeout, significantly improving the granularity and efficiency of timeout code location.

[0080] As a feasible implementation method, the execution time of each runnable entity function can also be determined based on the following method: the execution time of each runnable entity function is determined based on the two adjacent checkpoint functions.

[0081] In an exemplary embodiment, checkpoint functions are set at the beginning and end of the source timeout task and between each runnable entity function; the execution duration of each runnable entity function is determined by the triggering time interval between two adjacent checkpoint functions.

[0082] Checkpoint functions are time-capture functions preset between the task start node, the end node, and each runnable entity function. Their core function is to record the current timestamp and obtain the execution time of the corresponding runnable entity function by calculating the difference between the timestamp and the previous checkpoint timestamp. Time consumption statistics can be achieved without modifying the original task code.

[0083] It should be understood that by using two adjacent checkpoint functions for each runnable entity function (i.e., the entry checkpoint and exit checkpoint of the function, or the upper and lower level checkpoints that call the function), the execution time of each runnable entity function can be accurately and quickly determined without the need for full code instrumentation, high-frequency sampling, or deep intrusive monitoring of the system's running status. This significantly improves the efficiency of locating critical code and minimizes the impact of monitoring on the performance of the business system.

[0084] As a feasible implementation method, such as Figure 8 As shown, step S701 above can also be implemented as the following steps: S801. Based on the ratio of the execution time of each executable entity function to the net execution time of the source timeout task, determine the time consumption contribution of each executable entity function.

[0085] The time consumption contribution ratio reflects the proportion of each runnable entity function in the total execution time of the source timeout task, that is, the degree to which the function contributes to the overall execution time of the task. This ratio allows for a clear identification of which runnable entity functions constitute the main components of the task's execution time.

[0086] It should be understood that determining the time contribution of each executable entity function by the ratio of its execution time to the net execution time of the source timed-out task can quantify the weight of that function in the total execution time of the source task, thereby quickly locating the key function hotspots that cause task timeouts.

[0087] S802. Based on the contribution of time consumption, locate the target runnable entity function.

[0088] In the exemplary embodiment, the time consumption contribution of each executable entity function is compared with a preset contribution threshold, and the executable entity functions whose time consumption contribution is greater than or equal to the preset contribution threshold are determined as target runnable entity functions.

[0089] The preset contribution threshold can be dynamically set based on the historical average time contribution of different executable entity functions, or it can be pre-configured based on the expected time contribution ratio of each executable entity function in the task.

[0090] It should be understood that, based on the ratio of the execution time of each executable entity function to the net execution time of the source timeout task, locating the target runnable entity function can start from the internal perspective of the source task, further refining the investigation granularity from "task level" to "function level", and accurately pinpointing the specific code unit that causes the task's net execution time to be too long.

[0091] As a feasible implementation method, such as Figure 9As shown, step S802 above can be specifically implemented as follows: S901. Sort the executable entity functions in descending order according to their time consumption contribution to obtain a descending sequence of entity functions.

[0092] In an exemplary embodiment, all executable entity functions are sorted in descending order of their time contribution to form a descending sequence of entity functions, so that target runnable entity functions can be selected based on this sequence.

[0093] S902. The first second preset number of executable entity functions in the descending sequence of entity functions are determined as the target runnable entity functions.

[0094] The second preset number can be determined based on the total number of executable entity functions in the second task. For example, the second preset number is 2.

[0095] Generally, multiple executable entity functions with similar execution times are grouped into the same batch or the same scheduling group for simultaneous execution. Therefore, the executable entity function with the highest execution time contribution can be directly identified as the target runnable entity function based on the ranking results.

[0096] It should be understood that executable functions within the same batch or scheduling group are closely related in their execution timing, and their cumulative execution time directly affects the net execution time of the task. When the overall execution time of a batch is significantly longer than usual, the functions with the highest time contribution are the most likely sources of the anomaly. Therefore, sorting and locating high-contribution functions can quickly narrow down the scope of investigation and improve the efficiency of troubleshooting.

[0097] In some embodiments, such as Figure 10 As shown, the method for locating timeout tasks can be implemented in the following steps: S1001. Determine the net execution time for each run of all tasks.

[0098] S1002. Calculate the average CPU load for each task at the end of each task.

[0099] S1003. If the first task times out, determine the actual CPU load of the second task being executed during the timeout period of the first task.

[0100] The timeout period is the time between the start time of the first task and the current time; the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period.

[0101] S1004. Based on the load difference between the actual CPU load and the average CPU load of the second task, determine the CPU load increase value of the second task.

[0102] S1005. Based on the CPU load growth value, determine the source timeout task.

[0103] S1006. After determining the source timeout task, determine the execution duration of each runnable entity function in the source timeout task.

[0104] S1007. Based on the ratio of the execution time of each executable entity function to the net execution time of the source timeout task, determine the time consumption contribution of each executable entity function.

[0105] S1008. Based on the contribution of time consumption, locate the target runnable entity function.

[0106] It should be understood that, compared to existing technologies that require manual reading of currently running tasks and code modification to add time measurements after an ErrorHook task exceeds its limits in AUTOSAR OS, and then systematically checking all tasks and interrupts with higher priority than the current task to determine the source task, this application eliminates the need for manual code modification and the need to systematically check all related tasks and interrupts. It innovatively calculates the CPU load growth value of each related task by pre-setting the net execution time of all tasks, establishing an average CPU load benchmark, and quantitatively analyzing the actual CPU load at the time of timeout. This allows for the rapid identification of the two tasks with the largest instantaneous CPU load growth as the source timeout tasks. This location method based on load growth quantification is not a conventional improvement easily conceived by those skilled in the art; it breaks through the inherent thinking of manual investigation in existing technologies and possesses outstanding substantive characteristics.

[0107] The timeout task location method provided in this application avoids the tedious manual intervention and code modification required by existing technologies, significantly narrows the scope of source task investigation, eliminates the need to investigate all high-priority tasks and interrupts one by one, significantly improves the efficiency of source task location, reduces manual operation costs, and avoids the system stability risks that may be caused by code modification.

[0108] Compared to existing technologies that require individual time measurements or manual checks of all runnable functions within a task after a timeout to pinpoint the critical code causing the timeout and reset, this application innovatively pre-sets checkpoint functions among the runnable functions in the task. This allows for advance statistics on the execution time of each runnable function. Upon detecting a timeout, the application calculates the percentage of each runnable function's execution time during the timeout period and identifies the two functions with the highest percentages as the critical code. The comprehensive checkpoint function design allows for time statistics to be completed without modifying the original task code, solving the pain point of manual measurement required in existing technologies. This represents a fundamental difference from the existing troubleshooting methods and is a conventional improvement not applicable to those skilled in the art.

[0109] The timeout task location method provided in this application eliminates the need to check or measure all runnable entity functions within the task one by one, accurately narrowing down the scope of critical code investigation, achieving rapid and accurate location of critical code, further improving the overall timeout location efficiency, reducing the manpower and time costs of software maintenance, providing a clear direction for subsequent problem rectification, and shortening the problem resolution cycle.

[0110] Compared to existing technologies where the entire localization process relies heavily on manual intervention, from reading the currently running task and modifying the code to checking tasks, interrupts and functions one by one, all require manual operation and have a very low degree of automation, this application achieves fully automated localization from the source task to the key code through preset calculation logic, checkpoint functions and quantitative analysis methods, without the need for manual operation step by step.

[0111] The location method for timeout tasks provided in this application completely solves the shortcomings of existing technologies, such as cumbersome location processes and reliance on manual labor. It significantly improves the automation level of the location process, reduces human error, further improves location accuracy and efficiency, reduces manual maintenance costs, adapts to the engineering application needs of AUTOSAR OS, and enhances the practicality and feasibility of the technical solution.

[0112] In this application, a task refers to a basic execution unit under the scheduling and management of the AUTOSAR OS, that is, the smallest code execution entity that the operating system can schedule. Each task has an independent priority, stack space, and execution context, and its state is uniformly managed by the operating system, including multiple states such as ready, running, blocked, and suspended. The execution duration of a task refers to the time span from when the task acquires CPU resources and begins execution to when it voluntarily releases the CPU or the task ends.

[0113] Optionally, the timeout task localization method provided in this application can be applied to intelligent cockpit systems. In intelligent cockpit scenarios, AUTOSAR OS runs on a microcontroller unit (MCU) and is responsible for managing hard real-time tasks such as instrument display, vehicle control, and power management. It coexists with a rich operating system (such as Android or Linux) running on a high-performance system-on-chip (SoC), and is managed uniformly through a hypervisor or service-oriented architecture. When critical tasks such as instrument rendering and vehicle control command response time out, the timeout task localization method provided in this application can quickly determine whether the timeout is caused by abnormal CPU usage of high-priority tasks or by abnormal time consumption of specific runnable entities, thereby ensuring the real-time performance and functional safety of the cockpit system.

[0114] The foregoing primarily describes the solutions of the embodiments of this disclosure from a methodological perspective. It is understood that, in order to achieve the aforementioned functions, the vehicle communication device includes at least one of the hardware structures and software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, the embodiments of this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware 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 beyond the scope of the embodiments of this disclosure.

[0115] This disclosure embodiment can divide the vehicle communication device into functional modules according to the above method embodiment. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one functional module. The integrated module can be implemented in hardware or software. It should be noted that the module division in this disclosure embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods. The following description uses the example of dividing each functional module according to each function.

[0116] For example, Figure 11 This is a schematic diagram illustrating the composition of a timeout task positioning device provided in an embodiment of this application. Figure 12 As shown, the timeout task location device 1100 includes: a first determining module 1101 and a second determining module 1102; the first determining module 1101 is used to determine the actual central processing unit (CPU) load of the second task being executed during the timeout period of the first task when the first task is detected to have timed out; wherein, the timeout period is the period between the start time of the first task and the current time; the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period; the second determining module 1102 is used to determine the source timeout task that caused the first task to time out based on the actual CPU load.

[0117] Optionally, the second determining module 1102 is specifically used to determine the average CPU load of the second task; the average CPU load is the average of the statistical CPU load corresponding to each sampling period during the timeout period; the statistical CPU load is the ratio between the net execution time of the second task in each sampling period and the total duration of each sampling period; based on the average CPU load and the actual CPU load, the source timeout task is determined.

[0118] Optionally, the second determining module 1102 is specifically used to determine the CPU load growth value of the second task based on the load difference between the actual CPU load and the average CPU load; and to determine the source timeout task based on the CPU load growth value.

[0119] Optionally, the second determining module 1102 is specifically used to sort the second tasks in descending order according to the CPU load growth value to obtain a task descending sequence; and to take the first preset number of second tasks in the task descending sequence as the source timeout tasks.

[0120] Optionally, the timeout task location device 1100 further includes: a location module 1103; the location module 1103 is used to locate the target runnable entity function that caused the timeout after determining the source timeout task, based on the execution time of each runnable entity function in the source timeout task.

[0121] Optionally, the location module 1103 is specifically used to determine the time consumption contribution of each executable entity function based on the ratio of the execution time of each executable entity function to the net execution time of the source timeout task; and to locate the target runnable entity function based on the time consumption contribution.

[0122] Optionally, the positioning module 1103 is specifically used to sort the executable entity functions in descending order according to their time contribution to obtain a descending sequence of entity functions; and to determine the second-to-last preset number of executable entity functions in the descending sequence of entity functions as the target runnable entity functions.

[0123] Optionally, checkpoint functions are set at the beginning and end of the source timeout task and between each runnable entity function; the process of determining the execution duration of each runnable entity function includes: determining the execution duration of each runnable entity function based on the two adjacent checkpoint functions of each runnable entity function.

[0124] In the case of implementing the functions of the integrated modules described above in hardware, this embodiment of the invention provides a possible structural schematic diagram of the electronic device involved in the above embodiments. For example... Figure 12 As shown, the electronic device 1200 includes: a processor 1202, a communication interface 1203, and a bus 1204. Optionally, the electronic device 1200 may also include a memory 1201.

[0125] Processor 1202 may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 1202 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 1202 may also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0126] The communication interface 1203 is used to connect to other devices via a communication network. This communication network can be Ethernet, wireless access network, wireless local area network (WLAN), etc.

[0127] The memory 1201 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0128] As one possible implementation, the memory 1201 can exist independently of the processor 1202. The memory 1201 can be connected to the processor 1202 via a bus 1204 and is used to store instructions or program code. When the processor 1202 calls and executes the instructions or program code stored in the memory 1201, it can implement the timeout task location method provided in this embodiment of the invention.

[0129] In another possible implementation, the memory 1201 can also be integrated with the processor 1202.

[0130] Bus 1204 can be an extended industry standard architecture (EISA) bus, etc. Bus 1204 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0131] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the service calling device can be divided into different functional modules to complete all or part of the functions described above.

[0132] This application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be instructed by computer program instructions to be completed by related hardware. This program can be stored in the aforementioned computer-readable storage medium. When the computer program instructions are executed on a computer, they cause the computer to perform the timeout task location method as described in any of the above embodiments.

[0133] Exemplary examples of computer-readable storage media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks, or magnetic tapes), optical discs (e.g., compact disks (CDs), digital versatile disks (DVDs), etc.), smart cards, and flash memory devices (e.g., erasable programmable read-only memory (EPROMs), cards, sticks, or key drives, etc.). The various computer-readable storage media described in this disclosure may represent one or more devices and / or other machine-readable storage media for storing information. The term "machine-readable storage medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing, and / or carrying instructions and / or data.

[0134] This application also provides a computer program product comprising a computer program that, when run on a computer, causes the computer to execute any of the timeout task location methods provided in the above embodiments.

[0135] In the description of the embodiments of this application, specific features, structures, materials or characteristics may be combined in any suitable manner in one or more embodiments or examples.

[0136] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for locating timeout tasks, characterized in that, The method includes: If a timeout is detected in the first task, the actual CPU load of the second task being executed during the timeout period of the first task is determined; wherein, the timeout period is the period between the start time of the first task and the current time; and the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period. Based on the actual CPU load, the source timeout task that caused the first task to time out is determined.

2. The method for locating timeout tasks according to claim 1, characterized in that, The step of determining the source timeout task that caused the first task to time out based on the actual CPU load includes: Determine the average CPU load of the second task; the average CPU load is the average of the statistical CPU load corresponding to each sampling period in the timeout period; the statistical CPU load is the ratio between the net execution time of the second task in each sampling period and the total duration of each sampling period; The source timeout task is determined based on the average CPU load and the actual CPU load.

3. The method for locating timeout tasks according to claim 2, characterized in that, The step of determining the source timeout task based on the average CPU load and the actual CPU load includes: The CPU load increase value of the second task is determined based on the load difference between the actual CPU load and the average CPU load. The source timeout task is determined based on the CPU load growth value.

4. The method for locating timeout tasks according to claim 3, characterized in that, The process of determining the source timeout task based on the CPU load increase value includes: Sort the second task in descending order according to the CPU load increase value to obtain the task descending sequence; The first preset number of second tasks in the descending sequence of tasks are taken as the source timeout tasks.

5. The method for locating timeout tasks according to claim 1, characterized in that, The method further includes: After identifying the source timeout task, the target runnable entity function that caused the timeout is located based on the execution time of each runnable entity function in the source timeout task.

6. The method for locating timeout tasks according to claim 5, characterized in that, The step of locating the target runnable entity function causing the timeout based on the execution time of each runnable entity function in the source timeout task includes: The time contribution of each executable entity function is determined based on the ratio of the execution time of each executable entity function to the net execution time of the source timeout task. Based on the time consumption contribution, the target runnable entity function is located.

7. The method for locating timeout tasks according to claim 6, characterized in that, The step of locating the target runnable entity function based on the time consumption contribution includes: The executable entity functions are sorted in descending order according to their time consumption contribution to obtain a descending sequence of entity functions. The first second preset number of executable entity functions in the descending sequence of entity functions are determined as the target runnable entity functions.

8. The method for locating timeout tasks according to claim 5 or 6, characterized in that, Checkpoint functions are set at the beginning and end of the source timeout task and between each runnable entity function; the process of determining the execution duration of each runnable entity function includes: The execution duration of each runnable entity function is determined based on the two checkpoint functions adjacent to each runnable entity function.

9. A positioning device for a timeout task, characterized in that, The location device for the timeout task includes: a first determining module and a second determining module; The first determining module is configured to determine the actual CPU load of a second task being executed during the timeout period of the first task when a timeout of the first task is detected; wherein, the timeout period is the period between the start time of the first task and the current time; and the actual CPU load is the ratio between the net execution time of the second task during the timeout period and the total duration of the timeout period. The second determining module is used to determine the source timeout task that caused the first task to time out, based on the actual CPU load.

10. An electronic device, characterized in that, The device includes a processor and a memory, the processor being coupled to the memory; the memory is used to store computer instructions, which are loaded and executed by the processor to enable the computer device to implement the location method for a timeout task as described in any one of claims 1 to 8.