Battery management task execution time adjustment method, system, apparatus, and device
Patent Information
- Application Number
- CN202510529360.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2026-10-27
AI Technical Summary
但是,目前对于任务执行时间是否过长的判定标准并不准确,导致无法实现系统状态的准确监控
[0055]本申请实施例基于异常代码段的内存访问次数对其进行分析,在其内存访问次数超过第一数量阈值的情况下,表征超时大概率是多次内存访问导致的。因此,可将将经常访问的数据,例如配置数据或关键数据等访问数据缓存到能够快速访问的预设内存区域,减少对较慢的原始内存区域的访问次数,进而提高整体访问速度。
Smart Images

Figure CN122985318A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of battery management technology, and in particular to a method, system, apparatus and device for adjusting the execution time of battery management tasks. Background Technology
[0002] During the operation of a battery management system, the deadlines of each task are crucial indicators for monitoring the system's status. By monitoring task deadlines, it's possible to determine if any tasks have excessively long execution times, thereby assessing the system's current state. However, current criteria for determining whether task execution times are too long are inaccurate, hindering accurate monitoring of the system's status. Summary of the Invention
[0003] This application provides a method for adjusting the execution time of battery management tasks, a battery management system, a battery device, and electrical equipment, which can accurately and promptly detect system anomalies and ensure system performance.
[0004] In a first aspect, this application provides a method for adjusting the execution time of a battery management task, comprising:
[0005] Obtain the task code of at least one battery management task in the battery management system and the actual deadline of each of the at least one battery management task;
[0006] For each of the battery management tasks, the predicted deadline for each of the at least one battery management task is determined based on the task code of the at least one battery management task.
[0007] For each of the battery management tasks, obtain the time difference between the actual deadline and the predicted deadline;
[0008] In response to a battery management task whose time difference is greater than a first time threshold, the execution time of the battery management task in the battery management system is adjusted so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold.
[0009] The battery management task execution time adjustment monitoring method provided in this application determines the corresponding predicted deadline based on the task code of at least one battery management task in the battery management system; then calculates the time difference between the actual deadline and the predicted deadline of the battery management task; if there is a battery management task with a time difference greater than a first time threshold, it is determined that the system operation is abnormal, indicating that the execution time of the battery management task needs to be adjusted at this time.
[0010] Thus, since this application is based on the analysis of task codes, it can accurately analyze the possible predicted deadlines of battery management tasks based on the task codes of different battery management tasks. By comparing the predicted deadlines with the actual deadlines of the tasks, it can be determined whether there are cases where the task execution time is too long, and then corresponding optimizations can be made to avoid such cases, thereby improving the stability of the battery management system.
[0011] In one possible implementation, for each of the battery management tasks, based on the task code of the at least one battery management task, the predicted deadline for each of the at least one battery management task is determined, including:
[0012] For each of the battery management tasks, perform the following steps:
[0013] The task code of the battery management task is analyzed by the deadline prediction model to determine the task execution time of the battery management task;
[0014] Obtain the start time of the battery management task;
[0015] Based on the task start time and the task execution time, the predicted deadline for the battery management task is determined.
[0016] By analyzing task code to determine the execution time of system tasks, and combining this with the predicted task start time, the corresponding deadline for each system task can be predicted. This method, based on a deadline prediction model, accurately determines task execution time through task code analysis, thus enabling the rapid and accurate determination of the predicted deadline for each system task.
[0017] In one possible implementation, the step of analyzing the task code of the battery management task through the deadline prediction model to determine the task execution time of the battery management task includes:
[0018] The task code of the battery management task is decomposed to obtain multiple sub-operation codes of the battery management task;
[0019] Determine the sub-execution time corresponding to each of the multiple sub-operation codes;
[0020] The task execution time is determined based on the execution time of each sub-task.
[0021] In this embodiment, the execution time of a task is calculated by decomposing the task. Specifically, a single task is broken down into multiple sub-operation codes, and the execution time of each sub-operation code is determined. Then, the execution time of the entire task is calculated based on these sub-execution times. This method accurately obtains the execution time of a single sub-operation code based on its instructions, thereby accurately determining the overall execution time of the task.
[0022] In one possible implementation, the task code of the battery management task is decomposed to obtain multiple sub-operation codes of the battery management task, including:
[0023] Based on the functions of the battery management task, the task code is decomposed to obtain the sub-operation code corresponding to each function of the battery management task.
[0024] This application embodiment specifically decomposes the task code based on the function of the battery management task, which can accurately divide the task code into multiple parts that perform different functions, such as sub-operation codes for different functions such as data writing, data processing, and data reading, and then analyze them separately to obtain a more accurate time.
[0025] In one possible implementation, determining the sub-execution time corresponding to each of the plurality of sub-operation codes includes:
[0026] For each of the sub-operation codes, perform the following steps:
[0027] The sub-execution time corresponding to the sub-operation code is determined based on the number of instructions in the sub-operation code and the instruction type of each instruction.
[0028] This application determines the accurate sub-execution time by analyzing the number and type of instructions in the sub-operation code. For a sub-operation code of a system task, the number of instructions and the type of each instruction are key factors affecting its execution time; therefore, this application combines these two pieces of information with system operating status parameter data to accurately determine the sub-execution time corresponding to the sub-operation code.
[0029] In one possible implementation, for each of the battery management tasks, based on the task code of the at least one battery management task, the predicted deadline for each of the at least one battery management task is determined, including:
[0030] Obtain the task priority of the at least one battery management task;
[0031] For each battery management task, the task code and task priority are analyzed to determine the predicted deadline, so that the predicted deadline corresponding to the battery management task with higher priority among the at least one battery management tasks is moved forward;
[0032] Correspondingly, after analyzing the corresponding task code based on the pre-trained deadline prediction model for each battery management task to obtain the predicted deadline for the battery management task, the method further includes:
[0033] Among the battery management tasks, the battery management task with the earlier predicted deadline is executed first.
[0034] In this application embodiment, the predicted deadline for battery management tasks is set in conjunction with task priority. When executing battery management tasks, battery management tasks with earlier predicted deadlines are executed first, thereby ensuring that higher-priority battery management tasks can be executed first and reducing the occurrence of task timeouts.
[0035] In one possible implementation, after determining the predicted deadline for each of the at least one battery management task based on its task code, the method further includes:
[0036] Obtain the operating status parameter data corresponding to each of the battery management systems when executing the at least one battery management task;
[0037] Based on the corresponding operating status parameter data, the prediction deadline is adjusted;
[0038] Correspondingly, for each battery management task, obtaining the time difference between the actual deadline and the predicted deadline includes:
[0039] Obtain the time difference between the actual deadline and the adjusted predicted deadline.
[0040] This application embodiment adjusts the predicted deadline of the task by combining the running status parameter data, that is, it adjusts the predicted deadline according to the actual status of the system, thereby improving the accuracy of the predicted deadline and avoiding misjudgment of the system status.
[0041] In one possible implementation, the battery management task is multiple;
[0042] For each of the battery management tasks, based on the task code of the at least one battery management task, determine the predicted deadline for each of the at least one battery management task, including:
[0043] Obtain the dependencies between the different battery management tasks; the dependencies between any two battery management tasks include: the execution prerequisites of one battery management task are related to the execution state of another battery management task;
[0044] For each of the battery management tasks, perform the following operations:
[0045] Based on the dependencies and the associated battery management tasks that have the dependencies with the battery management task, the predicted deadline for the battery management task is determined.
[0046] This application's embodiments combine the dependencies between tasks to achieve time prediction; if there are dependencies between different tasks, their deadlines will affect each other. Therefore, by combining the dependencies between different system tasks, the predicted deadlines of system tasks can be predicted more accurately, thereby better achieving system status monitoring.
[0047] In one possible implementation, adjusting the execution time of the battery management task in the battery management system so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold includes:
[0048] For each of the battery management tasks, obtain the code segment execution time of each code segment of the battery management task;
[0049] From each code segment of the battery management task, identify the abnormal code segment whose execution time exceeds a second time threshold;
[0050] The abnormal code segment is adjusted so that the execution time of the adjusted abnormal code segment is less than the second time threshold.
[0051] In this embodiment of the application, when a battery management task times out, the execution time of each code segment of the task is analyzed to identify the abnormal code segment causing the timeout, thus pinpointing the cause of the battery management task timeout. Further adjustments to this abnormal code segment can reduce the probability of the battery management task timeout.
[0052] In one possible implementation, adjusting the abnormal code segment to make its execution time less than the second time threshold includes:
[0053] Obtain the memory access count of the abnormal code segment;
[0054] If the number of memory accesses exceeds a first threshold, the access data corresponding to the abnormal code segment is moved to a preset memory region; the access speed of the preset memory region is higher than that of the original memory region.
[0055] This application analyzes the memory access count of abnormal code segments. When the number of memory accesses exceeds a first threshold, it indicates that the timeout is likely caused by multiple memory accesses. Therefore, frequently accessed data, such as configuration data or critical data, can be cached in a preset memory area that can be accessed quickly, reducing the number of accesses to the slower original memory area and thus improving the overall access speed.
[0056] In one possible implementation, adjusting the abnormal code segment to make its execution time less than the second time threshold includes:
[0057] Obtain the number of nested function calls in the exception code segment;
[0058] If the number of nested function calls exceeds a second threshold, the abnormal code segment will be expanded by function inlining.
[0059] This application's embodiments analyze the nested function calls of the abnormal code segment. If the nested function call count exceeds a second threshold, it indicates that the timeout is highly likely caused by multiple nested function calls. Therefore, for functions with long execution times, function inlining can be considered to reduce the overhead of function calls.
[0060] In one possible implementation, adjusting the execution time of the battery management task in the battery management system so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold includes:
[0061] Analyze the task operations of each of the battery management tasks described;
[0062] Identify multiple target battery management tasks that have the same task operations;
[0063] The multiple target battery management tasks are merged.
[0064] This application provides a specific task optimization method. By merging related task operations through this optimization scheme, the overall execution time of each system task is reduced, which can ensure the stable operation of the system and reduce the probability of anomalies.
[0065] In one possible implementation, before analyzing the corresponding task code based on a pre-trained deadline prediction model to obtain the predicted deadline for each battery management task, the method further includes:
[0066] For each of the battery management tasks, perform the following steps:
[0067] Obtain the execution time characteristics, historical execution time, and corresponding influencing factors of the battery management task; the influencing factors include the task attributes of the battery management task;
[0068] Based on the execution time characteristics, determine the model type of the deadline prediction model corresponding to the battery management task;
[0069] Based on the historical execution time and the corresponding influencing factors affecting the historical execution time, a target model of the model type is trained to obtain the deadline prediction model.
[0070] In this embodiment, before analyzing the task code based on the deadline prediction model, a suitable model type is selected and trained to obtain a deadline prediction model with better prediction performance. Specifically, the execution time characteristics of the battery management task are first obtained, such as whether the task execution time and influencing factors have a linear relationship, a phased linear relationship, or a random distribution. Then, the corresponding type of time model is adopted to improve the model's adaptability, thereby obtaining a more accurate predicted deadline.
[0071] In one possible implementation, based on the historical execution time and the corresponding influencing factors affecting the historical execution time, a target model of the model type is trained to obtain the deadline prediction model, including:
[0072] The influencing factors are input into the target model to obtain the predicted execution time;
[0073] The predicted execution time is compared with the corresponding historical execution time to obtain the difference value;
[0074] If the difference value does not meet the iteration stopping condition, adjust the target model; and return to the step of inputting the influencing factors into the target model to obtain the predicted execution time;
[0075] If the difference value satisfies the iteration stopping condition, the current target model is determined as the deadline prediction model.
[0076] In this embodiment, influencing factors are input as training samples into the target model to obtain the predicted execution time, and the corresponding historical execution time is used as the label value to train the target model. Through iterative training, a deadline prediction model that can accurately predict the results is obtained.
[0077] Secondly, this application provides a battery management system, including:
[0078] An information acquisition unit is used to acquire the task code of at least one battery management task in the battery management system and the actual deadline of each of the at least one battery management task.
[0079] The processor is configured to, for each of the battery management tasks, determine the predicted deadline for each of the at least one battery management task based on the task code of the at least one battery management task;
[0080] The processor is also configured to, for each of the battery management tasks, obtain the time difference between the actual deadline and the predicted deadline;
[0081] The processor is further configured to, in response to a battery management task whose time difference is greater than a first time threshold, adjust the execution time of the battery management task in the battery management system so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold.
[0082] Thirdly, this application provides a battery device, including the aforementioned battery and a battery management system.
[0083] Fourthly, this application provides an electrical device including the aforementioned battery device.
[0084] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0085] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiments below. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0086] Figure 1 A flowchart illustrating a method for adjusting the execution time of a battery management task, provided in an embodiment of this application;
[0087] Figure 2A schematic flowchart of step S102 provided in an embodiment of this application;
[0088] Figure 3 A flowchart illustrating step S1021 provided in an embodiment of this application;
[0089] Figure 4 A schematic diagram of another S102 provided for an embodiment of this application;
[0090] Figure 5 A flowchart illustrating step S104 provided in an embodiment of this application;
[0091] Figure 6 A flowchart illustrating a deadline prediction model training method provided in an embodiment of this application;
[0092] Figure 7 A flowchart illustrating another deadline prediction model training method provided in this application embodiment;
[0093] Figure 8 This is a schematic diagram of the structure of a battery management system provided in some embodiments of this application. Detailed Implementation
[0094] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.
[0095] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0096] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0097] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0098] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0099] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).
[0100] The battery management system of this application is used to perform at least one of the following functions for individual battery cells: state monitoring, state analysis, charge / discharge control, safety protection, information management, thermal management, and high-voltage power distribution. In addition, the battery management system of this application can also perform the functions of a controller in an electrical device, such as a vehicle control unit (VCU) or a motor control unit (MCU), etc., and this application does not impose any limitations on this.
[0101] It should be noted that the battery management system in this application can be integrated as a controller into the battery device, such as into the battery pack or energy storage box.
[0102] The battery management system in this application can also be integrated as a controller into electrical devices, such as in a vehicle or vehicle chassis.
[0103] The battery management system in this application can also be integrated into the charging device as a controller, such as into the charging device or the battery swapping device.
[0104] The battery management system in this application can also be deployed as control software on a server. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, such as vehicle networking cloud, application backends, etc.
[0105] During the operation of a battery management system, the deadlines of each task are crucial indicators for monitoring the system's status. By monitoring task deadlines, it's possible to determine if any tasks have excessively long execution times, thereby assessing the system's current state. However, current criteria for determining whether task execution times are too long are inaccurate, hindering accurate monitoring of the system's status.
[0106] For example, static analysis methods are commonly used to estimate task execution time. However, static analysis cannot account for dynamic factors during actual runtime, such as changes in input data, cache hit rates, and interruptions. These factors can lead to significant discrepancies between the actual task execution time and the results of static analysis. Consequently, inaccurate estimations of the actual task execution time and the contention for system resources result in unreasonable task execution deadlines—either too short or too long—leading to an inability to accurately monitor the system status.
[0107] Based on the above issues, and considering that the execution time of a task is closely related to its own task code, a deadline prediction model can be trained to analyze the task code of the battery management task and thus predict a relatively accurate deadline. By comparing this predicted deadline with the actual deadline of the battery management task, it can be determined whether the battery management task execution time is excessively long, thereby accurately assessing the current state of the battery management system.
[0108] Based on this, this application provides a method for adjusting the execution time of battery management tasks. Figure 1 This is a flowchart illustrating a method for adjusting the execution time of a battery management task, as provided in an embodiment of this application. Figure 1 As shown, the method may include the following steps: S101 to S104.
[0109] S101: Obtain the task code of at least one battery management task in the battery management system and the actual deadline of each of the at least one battery management task.
[0110] During operation, the battery management system (BMS) performs various battery management tasks, such as battery status monitoring, battery safety management, battery charge / discharge control, battery balancing management, and thermal management. To prevent these tasks from taking too long to complete and thus causing system instability, it is necessary to monitor them.
[0111] Specifically, in this application embodiment, the specific monitoring method for battery management tasks is to predict the predicted deadline of the battery management task and obtain the corresponding actual deadline, then compare the predicted deadline with the actual deadline of the battery management task, and determine the state of the battery management system based on the comparison result.
[0112] Therefore, it is necessary to first obtain the task code of at least one battery management task in the battery management system, so as to analyze the task through the task code and obtain the corresponding predicted deadline. As for obtaining the actual deadline of each battery management task, the task timestamp can be obtained; a timestamp is generated when the task starts, ends, etc., and the actual deadline of the battery management task can be obtained by obtaining the corresponding timestamp.
[0113] To obtain task-related times, operations can be performed using the system's time measurement interface. For example, `Ceos_GetTaskTime()` or similar functions (the specific function name may vary depending on the AUTOSAR implementation). When the task starts execution, the current timestamp is recorded, for example, using `StartTime = Ceos_GetSystemTime()`; (assuming `Ceos_GetSystemTime()` is the function to retrieve the current system time). When the task ends, the timestamp `EndTime = Ceos_GetSystemTime()` can be obtained again; then the task's execution time `ExecutionTime = EndTime - StartTime` can be calculated. Based on this, various relevant times for the battery management task can be obtained.
[0114] Task time can be monitored during the scheduled execution cycle of a task. For example, for a task that executes every 50 milliseconds, time can be monitored each time it is executed. Alternatively, monitoring can be performed at critical task nodes, such as after the task completes a significant operation.
[0115] S102: For each battery management task, based on the task code of at least one battery management task, determine the predicted deadline for each of the at least one battery management task.
[0116] The embodiments of this application do not limit the specific method of determining the prediction deadline; as some optional implementation methods, the task execution time of the battery management task can be determined by the task code, and the task start time of the battery management task can be obtained. Based on the task start time and the task execution time, the prediction deadline of the battery management task can be predicted.
[0117] The task start time is the exact time when the task begins execution. For example, a battery management task might start execution at x:x:x:x on a given day. The task execution time is the duration of the task's execution. For example, if a battery management task executes for 10ms, that duration is the task execution time. The predicted deadline is the deadline determined based on the task code; under normal circumstances, the task should complete before the predicted deadline.
[0118] It should be noted that this application does not limit the method for obtaining the task start time of battery management tasks, and can be determined according to the actual situation. For example, for timed tasks in the battery management system, which will start execution at a preset time, the task start time can be obtained directly from the preset information. As another example, in the case of multiple battery management tasks, for a target battery management task, other battery management tasks that execute before the target battery management task can be determined based on their execution priority. Based on the execution time of these other battery management tasks, the task start time of the target battery management task can be determined.
[0119] As an alternative implementation, the task code can be analyzed based on a pre-trained deadline prediction model to determine the predicted deadline for the battery management task. In practical applications, multiple battery management tasks may exist simultaneously, requiring the determination of a corresponding predicted deadline for each task.
[0120] The process of building a deadline prediction model involves obtaining the execution time characteristics, historical execution time, and corresponding influencing factors for each battery management task. Then, based on the execution time characteristics, the model type for the deadline prediction model corresponding to the battery management task is determined. Finally, the target model of the model type is trained to obtain the deadline prediction model.
[0121] Execution time characteristics can include any one of the following: a linear relationship between execution time and influencing factors, a phased linear relationship, or a random distribution; influencing factors include the task attributes of battery management tasks, such as the amount of data.
[0122] S103: For each battery management task, obtain the time difference between the actual deadline and the predicted deadline.
[0123] As mentioned above, the monitored battery management tasks may include one or more. In the case of multiple battery management tasks, multiple actual deadlines and multiple predicted deadlines will be obtained. For each battery management task, the time difference between the corresponding actual deadline and the predicted deadline will be obtained.
[0124] S104: In response to a battery management task whose time difference is greater than a first time threshold, adjust the execution time of the battery management task in the battery management system so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold.
[0125] If the time difference of a battery management task exceeds a first time threshold, it indicates that the task has timed out. The predicted deadline can be used as the standard deadline for the battery management task; if the task is not completed before the predicted deadline, it indicates a timeout. When the timeout exceeds the first time threshold (i.e., the time difference is greater than the first time threshold), the system state is considered abnormal, and the execution time of the battery management task needs to be adjusted to prevent system instability. The adjustment goal is to ensure that the time difference for the battery management task is less than or equal to the first time threshold, thus minimizing timeouts.
[0126] The initial time threshold is not fixed and can be set according to the actual situation. For critical tasks or tasks with high real-time requirements, the initial time threshold should be set accurately enough to ensure that the task can be completed within the specified time. For non-critical tasks, a more lenient initial time threshold can be set based on their impact on the overall system performance and the prediction of the time model. However, the interrelationship between tasks should also be considered to avoid a cascading delay in other tasks due to a delay in one task.
[0127] The battery management task execution time adjustment monitoring method provided in this application determines the corresponding predicted deadline based on the task code of at least one battery management task in the battery management system; then calculates the time difference between the actual deadline and the predicted deadline of the battery management task; if there is a battery management task with a time difference greater than a first time threshold, it is determined that the system operation is abnormal, indicating that the execution time of the battery management task needs to be adjusted at this time.
[0128] Thus, since this application is based on the analysis of task codes, it can accurately analyze the possible predicted deadlines of battery management tasks based on the task codes of different battery management tasks. By comparing the predicted deadlines with the actual deadlines of the tasks, it can be determined whether there are cases where the task execution time is too long, and then corresponding optimizations can be made to avoid such cases, thereby improving the stability of the battery management system.
[0129] In order to accurately obtain the predicted deadline for each battery management task, this application provides a specific implementation method. Figure 2 This is a schematic flowchart of step S102 provided in an embodiment of this application. Figure 2 As shown, S102 may include: for each battery management task, executing S1021 to S1023.
[0130] S1021: Analyze the task code of the battery management task using the deadline prediction model to determine the task execution time of the battery management task.
[0131] As mentioned above, the predicted deadline for battery management tasks is directly related to their execution time; therefore, it is necessary to determine the accurate task execution time first. Here, we provide a feasible implementation method. Figure 3 This is a schematic flowchart of step S1021 provided in an embodiment of this application. Figure 3 As shown, S1021 may include S10211 to S10213.
[0132] S10211: Decompose the task code of the battery management task to obtain multiple sub-operation codes of the battery management task.
[0133] Specifically, different parts of a battery management task may be used to perform different functions, such as data reading, data processing, and data writing. Therefore, as a feasible implementation method, the task code can be decomposed based on the functions of the battery management task to obtain the sub-operation codes corresponding to each function of the battery management task. That is, the code segments corresponding to data reading, data processing, and data writing are all sub-operation codes.
[0134] This embodiment decomposes a battery management task into multiple sub-operation codes (or multiple function calls), and then performs time characteristic analysis on each sub-operation code. In this way, the task code of the battery management task can be accurately divided into multiple separate parts, and further analysis of each part can yield accurate execution time.
[0135] S10212: Determine the sub-execution time corresponding to each of the multiple sub-operation codes.
[0136] The execution time of a task is directly related to the number of instructions that the task needs to execute, and the execution time varies greatly depending on the type of instruction. Therefore, in one possible implementation, the corresponding sub-execution time can be determined based on the number of instructions in the sub-operation code and the instruction type of each instruction.
[0137] This application embodiment can determine the accurate sub-execution time by analyzing the number and type of instructions in the sub-operation code. The instruction type of each instruction in the sub-operation code is specifically related to the function of the instruction. For example, in practical applications, assignment instructions, calculation instructions, and call instructions are commonly used, and the execution time of different types of instructions is different.
[0138] For a sub-operation code of a system task, the number of instructions and the instruction type of each instruction are key factors affecting its execution time. Therefore, by combining these two pieces of information with system running status parameter data, this application can accurately determine the sub-execution time corresponding to the sub-operation code.
[0139] S10213: Determine the task execution time based on the execution time of each sub-task using the deadline prediction model.
[0140] After obtaining the multiple sub-execution times corresponding to the multiple self-operations of the battery management task, the task execution time can be determined. As a feasible implementation method, the multiple sub-execution times can be added together, and the result of the addition is the task execution time.
[0141] In this embodiment, the deadline for a task is calculated by decomposing the task. Specifically, a single task is broken down into multiple sub-operation codes, and the execution time of each sub-operation code is determined. Then, the execution time of the entire task is calculated based on these sub-execution times. This method accurately obtains the execution time of a single sub-operation code based on its instructions, thereby accurately determining the overall execution time of the task.
[0142] S1022: Obtain the start time of the battery management task.
[0143] The embodiments of this application do not limit the method of obtaining the task start time, and can be determined according to the actual situation. For example, for a scheduled task, the preset start time can be directly obtained. As another example, when there are multiple battery management tasks, for a target battery management task, other battery management tasks that are executed before the target battery management task can be determined based on the priority of task execution, and the task start time of the target battery management task can be calculated based on the execution time of the other battery management tasks.
[0144] S1023: Determine the predicted deadline for the battery management task based on the task start time and task execution time.
[0145] By adding the task execution time to the start time of the battery management task, the predicted deadline for the battery management task can be obtained.
[0146] By analyzing task code to determine the execution time of system tasks, and combining this with the predicted task start time, the corresponding deadline for each system task can be predicted. This method, based on a deadline prediction model, accurately determines task execution time through task code analysis, thus enabling the rapid and accurate determination of the predicted deadline for each system task.
[0147] To reduce timeouts in battery management tasks, this application provides a possible implementation method. Figure 4 This is a schematic diagram of another S102 provided in an embodiment of this application. Figure 4 As shown, S102 may include S401 and S402.
[0148] S401: Obtain the task priority of at least one battery management task.
[0149] Task priority refers to the ranking of battery management tasks based on factors such as importance, urgency, and scope of impact. Battery management tasks with different priorities have varying degrees of importance; generally, higher-priority tasks should be executed first. Therefore, it is necessary to first obtain the task priority of at least one battery management task.
[0150] S402: For each battery management task, analyze the task code and task priority to determine the predicted deadline, so that the predicted deadline of the higher-priority battery management task is moved forward.
[0151] When determining the predicted deadline, the task priority and task code can be combined to analyze and obtain the predicted deadline, so that the predicted deadline of the battery management task with higher priority among at least one battery management task is placed earlier.
[0152] Correspondingly, after S102, this method may also include S503.
[0153] S403: Among the battery management tasks, prioritize the execution of the battery management task with the earlier predicted deadline.
[0154] In practice, task deadline information can be passed to the system's task scheduler. When scheduling tasks, the scheduler must consider the deadlines and prioritize tasks with closer deadlines to ensure timely completion. For example, the scheduler can use a priority- and deadline-based scheduling algorithm, prioritizing tasks with earlier deadlines for tasks of the same priority. Simultaneously, the scheduler must be able to handle task timeouts, such as triggering appropriate error handling mechanisms or adjusting the scheduling strategy for subsequent tasks.
[0155] In this application embodiment, the predicted deadline for battery management tasks is set in conjunction with task priority. When executing battery management tasks, battery management tasks with earlier predicted deadlines are executed first, thereby ensuring that higher-priority battery management tasks can be executed first and reducing the occurrence of task timeouts.
[0156] To ensure the accuracy of the predicted deadlines for battery management tasks, the predicted deadlines output by the deadline prediction model can be further adjusted. As one possible implementation, after analyzing the corresponding task code based on the pre-trained deadline prediction model to obtain the predicted deadline for each battery management task, the process can further include: acquiring the corresponding operating state parameter data of the battery management system when executing at least one battery management task; and adjusting the predicted deadline based on the corresponding operating state parameter data.
[0157] Correspondingly, when obtaining the time difference between the actual deadline and the predicted deadline, the specific steps include: obtaining the time difference between the actual deadline and the adjusted predicted deadline.
[0158] When performing battery management tasks, changes in operating status parameters (such as CPU utilization and memory usage) can affect the task's execution time. For example, high CPU utilization or insufficient memory can prolong the task's execution time. Therefore, during system operation, the predicted deadline can be dynamically adjusted based on actual conditions. If the system detects resource scarcity, the predicted deadline can be extended accordingly to avoid frequent timeouts due to resource contention.
[0159] At the same time, if the deadline prediction model changes (for example, due to application software upgrades, hardware replacements, etc., which change the execution time characteristics of the task), the deadline should be readjusted in a timely manner according to the new model.
[0160] This application embodiment adjusts the predicted deadline of the task by combining the running status parameter data, that is, it adjusts the predicted deadline according to the actual status of the system, thereby improving the accuracy of the predicted deadline and avoiding misjudgment of the system status.
[0161] As mentioned above, in practical applications, there can be multiple battery management tasks; and different battery management tasks may have dependencies on each other, which can affect their respective execution times. Therefore, in order to obtain a more accurate predicted deadline, this application provides a specific implementation method.
[0162] Specifically, for each battery management task, based on a pre-trained deadline prediction model, the corresponding task code is analyzed to obtain the predicted deadline for the battery management task, including:
[0163] First, obtain the dependencies between different battery management tasks; then, for each battery management task, perform the following operations: based on the dependencies and the associated battery management tasks that have dependencies on the battery management task, determine the prediction deadline corresponding to the battery management task.
[0164] If there are dependencies between different battery management tasks, the impact of these dependencies on task execution time needs to be considered. Dependencies between any two battery management tasks can include: the execution prerequisites of one battery management task being related to the execution status of another; for example, one task needs to wait for another task to complete certain data preparation work before it can begin execution; or the two tasks need to be executed simultaneously.
[0165] In practice, the impact of changes in the execution time of dependent tasks on the current target task can be analyzed to establish a dependency model. For example, if the execution time of dependent tasks is extended, the current task may need to wait longer, or it may need to adopt some alternative strategies (such as using cached data or reducing processing precision).
[0166] This application's embodiments combine the dependencies between tasks to achieve time prediction; if there are dependencies between different tasks, their deadlines will affect each other. Therefore, by combining the dependencies between different system tasks, the predicted deadlines of system tasks can be predicted more accurately, thereby better achieving system status monitoring.
[0167] To efficiently optimize battery management tasks, this application proposes analyzing code segments to identify the causes of anomalies, allowing for targeted adjustments to the problematic code segments. One possible implementation is provided below. Figure 5 This is a schematic flowchart of step S104 provided in an embodiment of this application. Figure 5 As shown, S104 may include S1041 to S1043.
[0168] S1041: For each battery management task, obtain the execution time of each code segment of the battery management task.
[0169] For a battery management task containing multiple code segments, the execution time of each segment can be obtained using an execution time acquisition function. Code profiling tools or manual analysis of the code logic can be used to identify code segments that might cause excessively long task execution times.
[0170] Common causes of anomalies include: 1. Frequent memory accesses, especially without effective data caching or memory management optimization. For example, constantly searching and reading large amounts of small data blocks from memory. 2. Excessive nesting of function calls, especially those with long execution times.
[0171] S1042: Identify the abnormal code segments from each code segment of the battery management task whose execution time exceeds the second time threshold.
[0172] An abnormal code segment is a code segment within the battery management task whose execution time is abnormal. For example, if the execution time of a certain code segment is significantly longer than the normal execution time, then this code segment can be identified as an abnormal code segment.
[0173] A second time threshold can be preset. Once the execution time of a code segment exceeds the second time threshold, the corresponding code segment can be identified as an abnormal code segment. The size of the second time threshold is not limited and can be set according to the actual situation. Different code segments can also be assigned different second time thresholds.
[0174] S1043: Adjust the exception code segment so that the execution time of the adjusted exception code segment is less than the second time threshold.
[0175] Once the abnormal code segment is identified, it can be adjusted to ensure its execution time is less than a second time threshold. This demonstrates that this method can quickly pinpoint the cause of task timeouts and allow for timely adjustments to the abnormal code segment, efficiently resolving the problem.
[0176] To address the issue of excessively long execution times for exception code segments, some specific solutions are provided here. As mentioned above, code segment timeouts may be due to frequent memory accesses. Therefore, after identifying the exception code segment, the memory access count of the exception code segment can be obtained first. If the memory access count exceeds a first threshold, the accessed data corresponding to the exception code segment is moved to a preset memory region. The access speed of the preset memory region is higher than that of the original memory region. The size of the first threshold is not limited and can be set according to the actual situation.
[0177] For frequently accessed data, this embodiment can use memory caching technology. For example, frequently used configuration data or critical data can be cached in a fast-access memory area to reduce the number of accesses to slower storage devices (such as random access memory).
[0178] Furthermore, in practical implementation, memory fragmentation can be avoided by allocating memory appropriately. The system's memory management interface is used to ensure that battery management tasks can quickly acquire the necessary memory during execution, and that execution time is not prolonged due to memory allocation failures.
[0179] This application analyzes the memory access count of abnormal code segments. When the number of memory accesses exceeds a first threshold, it indicates that the timeout is likely caused by multiple memory accesses. Therefore, frequently accessed data, such as configuration data or critical data, can be cached in a preset memory area that can be accessed quickly, reducing the number of accesses to the slower original memory area and thus improving the overall access speed.
[0180] Furthermore, as mentioned above, code segment timeouts may be due to excessive function call nesting. Therefore, after identifying the abnormal code segment, the number of function call nestings within that segment can be obtained. Then, if the number of nestings exceeds a second threshold, the abnormal code segment should be inlined. The size of the second threshold is not limited and can be set according to the actual situation.
[0181] This embodiment addresses timeout issues in abnormal code segments by reducing unnecessary function calls, especially those functions that significantly impact performance. Small, frequently called functions can be inlined to reduce overhead. However, it's important to note that inlining may increase code size, requiring a trade-off between code size and performance.
[0182] For functions that take a long time to execute, you can consider splitting their functionality, separating the parts that can be executed asynchronously, and using the system's inter-task communication mechanisms (such as message queues, semaphores, etc.) for coordination to avoid blocking the main thread of the task.
[0183] This application's embodiments analyze the nested function calls of the abnormal code segment. If the nested function call count exceeds a second threshold, it indicates that the timeout is highly likely caused by multiple nested function calls. Therefore, for functions with long execution times, function inlining can be considered to reduce the overhead of function calls.
[0184] In this embodiment of the application, when a battery management task times out, the execution time of each code segment of the task is analyzed to identify the abnormal code segment causing the timeout, thus pinpointing the cause of the battery management task timeout. Further adjustments to this abnormal code segment can reduce the probability of the battery management task timeout.
[0185] To ensure that the deadline prediction model can accurately output results, this application provides a feasible implementation method. Figure 6This is a flowchart illustrating a deadline prediction model training method provided in an embodiment of this application. Figure 6 As shown, prior to S102, this method can also execute S601 to S603 for each battery management task.
[0186] S601: Obtain the execution time characteristics, historical execution time, and corresponding factors affecting the historical execution time of the battery management task.
[0187] Execution time characteristics can include any one of the following: a linear relationship between execution time and influencing factors, a phased linear relationship, or a random distribution; influencing factors include the task attributes of battery management tasks, such as the amount of data, the number of task instructions, and the type of instructions;
[0188] S602: Determine the model type of the deadline prediction model corresponding to the battery management task based on the execution time characteristics.
[0189] For cases where the execution time and influencing factors have a linear relationship, a linear model can be used. That is, if the execution time of a battery management task has an approximately linear relationship with a certain influencing factor (such as the amount of data), a linear equation can be established to describe the execution time. For example, ExecutionTime = a * DataSize + b, where a and b are coefficients obtained through data analysis and DataSize is the amount of data processed by the task.
[0190] For cases where the execution time and influencing factors exhibit a phased linear relationship, a piecewise linear model can be used. When battery management tasks exhibit different execution time characteristics under varying conditions, a piecewise linear model can also be employed. For example, the relationship between task execution time and data volume differs depending on the data size; different linear equations can be established to describe the execution time at different stages.
[0191] When the execution time and influencing factors have a random distribution relationship, a probabilistic model can be used: If the execution time of a task has a certain degree of randomness, a probability distribution model can be used to describe it. For example, assuming that the task execution time follows a normal distribution ExecutionTime~N(μ,σ2), where μ is the mean and σ2 is the variance, the values of μ and σ can be estimated through statistical analysis of a large amount of execution time data.
[0192] S603: Based on the historical execution time and the corresponding influencing factors that affect the historical execution time, train the target model of the model type to obtain the deadline prediction model.
[0193] Once the required model type is determined, the target model of that model type can be trained to obtain the deadline prediction model.
[0194] As an optional implementation, the execution time of each sub-operation code of a task can be measured under different conditions, such as different data volumes and different system loads. Statistical information can be obtained by executing the task multiple times and recording the time data.
[0195] Figure 7 This is a flowchart illustrating another deadline prediction model training method provided in an embodiment of this application. Figure 7 As shown, S603 may include S6031 to S6035.
[0196] S6031: Input the influencing factors into the target model to obtain the predicted execution time.
[0197] After determining the required model type, the corresponding target model can be constructed. However, when the influencing factors of the battery management task are input into the target model, the output results may not be accurate. Therefore, the target model needs to be trained.
[0198] S6032: Compare the predicted execution time with the corresponding historical execution time to obtain the difference value.
[0199] First, input the influencing factors from historical data into the target model to obtain the predicted execution time. Then, compare the predicted execution time with the corresponding historical execution time to obtain the difference value, which determines whether the target model can accurately output the result.
[0200] S6033: Determine whether the difference value meets the iteration stopping condition; if the difference value does not meet the iteration stopping condition, proceed to S6034; if the difference value meets the iteration stopping condition, proceed to S6035.
[0201] S6034: Adjust the target model; and return to S6031.
[0202] S6035: Determine the current target model as the deadline prediction model.
[0203] In this embodiment, the accuracy of the target model's output is determined based on whether the difference value meets the iteration stopping condition. The iteration stopping condition can be that the difference value is less than a certain preset value. This preset value is a preset threshold, which can be determined based on model convergence and training efficiency. Setting the preset value too small may lead to excessively long training time or even overfitting; setting it too large may lead to insufficient model training and underfitting. Therefore, when setting the preset value, it is necessary to comprehensively balance both model convergence and training efficiency.
[0204] If the difference value does not meet the iteration stopping condition, it indicates that the predicted execution time output by the target model does not match the actual historical execution time, and the target model needs to be adjusted. If the difference value meets the iteration stopping condition, it indicates that the predicted execution time output by the target model matches the actual historical execution time; that is, it can output an accurate predicted execution time. In this case, the current target model will be determined as the deadline prediction model.
[0205] After training the deadline prediction model, its accuracy can be validated using actual task execution data. The model's performance is evaluated by calculating the error between the calculated execution time and the actual execution time. If the model error is large, adjustments are needed. This could involve adding more influencing factors to the model or adjusting its structure (e.g., changing the parameters of a linear model or choosing a more suitable probability distribution). For example, if task execution time is also found to be affected by system CPU utilization, CPU utilization can be included as an additional variable in the model.
[0206] In this embodiment, before analyzing the task code based on the deadline prediction model, a suitable model type is selected and trained to obtain a deadline prediction model with better prediction performance. Specifically, the execution time characteristics of the battery management task are first obtained, such as whether the task execution time and influencing factors have a linear relationship, a phased linear relationship, or a random distribution. Then, the corresponding type of time model is adopted to improve the model's adaptability, thereby obtaining a more accurate predicted deadline.
[0207] To avoid timeouts in battery management tasks, it's necessary to reduce the execution time of various system tasks. Below are some optimization algorithms and data structures to reduce execution time.
[0208] First, for complex algorithms, if possible, choose a more efficient implementation. For example, in sorting tasks, if bubble sort was originally used, for large datasets, consider switching to more efficient algorithms such as quicksort or mergesort.
[0209] Secondly, it can optimize the use of data structures. For example, if a task requires frequent element lookups, a hash table can be used instead of a linear search array to improve lookup efficiency.
[0210] Third, reduce unnecessary data copying and conversion. For example, if a task requires converting a large amount of data from one format to another, consider optimizing the data format at the source to avoid frequent intermediate conversions.
[0211] In addition to the methods mentioned above, here are some solutions to reduce task switching frequency, thereby reducing the execution time of each system task. Items 1 to 3 below are for optimizing task scheduling strategies, items 4 to 6 are for reducing synchronization and communication overhead between tasks, and items 7 to 9 are for optimizing task code execution logic.
[0212] 1. Set appropriate task priorities. Assign reasonable priorities to each battery management task based on its importance and real-time requirements. Critical tasks and tasks with high real-time requirements should have higher priorities to ensure timely execution. Furthermore, unnecessary priority inversion should be avoided. For example, use a priority inheritance mechanism to resolve priority inversion issues caused by high-priority tasks waiting for resources held by low-priority tasks. When a low-priority task holds a resource required by a high-priority task, temporarily raise the low-priority task's priority to the same as the high-priority task until it releases the resource.
[0213] 2. Select a scheduling algorithm suitable for system requirements. For example, for a battery management system, a fixed-priority preemptive scheduling algorithm can be used to ensure that high-priority tasks can preempt the execution of low-priority tasks at any time. Simultaneously, a round-robin scheduling algorithm can be combined, where tasks with the same priority are executed in turn according to time slices, ensuring that each task gets a certain execution opportunity and preventing one task from occupying the CPU for an extended period, thus preventing other tasks from being unable to execute. Furthermore, scheduling parameters, such as the size of the time slice, can be adjusted. For tasks with short execution times and frequent switching, the time slice size can be appropriately reduced to improve task response speed; for tasks with longer execution times, the time slice size can be appropriately increased to reduce the number of task switching.
[0214] 3. Task Grouping and Scheduling. Related tasks can be grouped, for example, multiple tasks within a functional module can be grouped together. During scheduling, these task groups can be considered holistically to reduce switching overhead between tasks. For a group of tasks, a group priority can be set; when a task within the group needs to be executed, it will be scheduled according to the group priority. Furthermore, relative priorities can be further set within the group based on specific circumstances to ensure a reasonable execution order for tasks within the group.
[0215] 4. Optimize inter-task communication mechanisms. Efficient inter-task communication methods can be selected. In battery management systems, common communication methods include message queues, semaphores, and event flags. Choose the appropriate communication method based on the task's communication needs and real-time requirements. For example, if tasks need to transfer large amounts of data, message queues can be used, and the message queue size and caching mechanism should be set appropriately to avoid task blocking and frequent switching caused by message loss or queue overflow. For simple synchronization needs, semaphores or event flags can be used, but care should be taken to avoid overuse that could lead to frequent task waiting and switching. For example, when multiple tasks access shared resources mutually exclusively, semaphores can be used for control, but it is essential to ensure that semaphore acquisition and release operations are efficient to avoid long waiting times.
[0216] 5. Avoid unnecessary task wake-ups. Tasks enter a blocked state while waiting for certain conditions to be met, and are woken up when the conditions are satisfied. To reduce task switching, avoid unnecessary task wake-ups. For example, when using event flags for task synchronization, ensure that event flags are only set when a task truly needs to be woken up, avoiding accidental or premature task wake-ups. Before setting event flags, thoroughly check and judge the relevant conditions. For periodic tasks with long cycles, consider checking if there is actual work to be done when the task cycle arrives, rather than immediately waking the task. If there is no actual work, continue waiting until there is work to be done before waking the task, thus reducing unnecessary task execution and switching.
[0217] 6. Data Sharing and Synchronization Optimization. If multiple tasks need to share data, ensure efficient data access and synchronization mechanisms. Mutexes or atomic operations can be used to protect access to shared data, avoiding data races and inconsistencies. For frequently accessed shared data, consider using a replication mechanism to copy the data to each task's local memory for operation, reducing access conflicts and synchronization overhead. However, pay attention to maintaining data consistency; for example, promptly synchronize updated data to local copies on other tasks when updates are made.
[0218] 7. Reduce blocking operations in tasks. In task code, minimize operations that could cause blocking, such as long-running I / O waits or indefinite waits for a condition. For I / O operations, use asynchronous I / O or timeout mechanisms. For example, when reading a file, asynchronous I / O allows the task to continue executing other tasks after initiating the read operation, instead of blocking indefinitely. When the read operation completes, notify the task via a callback function or event for further processing. If a task needs to wait for a condition, set a reasonable timeout to prevent the task from being blocked for extended periods. If the condition is not met by the timeout period, implement appropriate error handling or backup strategies instead of waiting indefinitely.
[0219] 8. Combine related task operations. Combine related task operations together to reduce the number of task executions and switching frequency. For example, if a task needs to read and process the same data multiple times, consider completing all related operations in a single task execution, instead of switching and processing the task every time a small amount of data is read. For tasks that can be processed in batches, multiple small operations can be combined into one large operation. For example, in a network data receiving task, multiple small data packets can be received and processed at once, instead of switching and processing the task every time a data packet is received.
[0220] Specifically, the task operations of each battery management task can be analyzed, and then multiple target battery management tasks with related task operations can be identified; finally, the multiple target battery management tasks are merged. Through the above operations, the time difference corresponding to the adjusted battery management task can be made less than or equal to a first time threshold. This application embodiment provides a specific task optimization method. Through the optimization scheme of this solution, related task operations are merged, thereby reducing the overall execution time of each system task, ensuring stable system operation, and reducing the probability of anomalies.
[0221] 9. Task Prefetching and Preprocessing. For tasks that may require a long time to prepare data, data prefetching and preprocessing can be performed before task execution. For example, in a data analysis task, data can be read and preprocessed in advance, so that the prepared data can be used directly when the task is actually executed, reducing waiting time and task switching during task execution. Background tasks or dedicated preprocessing threads can also be used for data prefetching and preprocessing. These background tasks or threads can work when the system is idle, storing the prepared data in shared memory or other suitable locations for use by the main task. At the same time, attention should be paid to data synchronization and consistency issues to ensure that the data is ready and up-to-date when the main task uses it.
[0222] To better illustrate this solution, a specific embodiment is provided here.
[0223] Before monitoring and adjusting the execution time of battery management tasks, we can obtain the execution time characteristics, historical execution times, and corresponding influencing factors of the historical execution time of the battery management tasks. Then, based on the execution time characteristics, we can determine the model type of the deadline prediction model corresponding to the battery management tasks. Furthermore, based on the historical execution times and corresponding influencing factors of the historical execution times, we can train the target model of the corresponding model type to obtain the deadline prediction model.
[0224] Then, battery management tasks are monitored based on a deadline prediction model. First, the task code and actual deadline are obtained. For each battery management task, the predicted deadline is obtained by analyzing the task code using the deadline prediction model. In practical applications, the predicted deadline can be adjusted based on runtime parameter data and dependencies between tasks. Further, the time difference between the actual and predicted deadlines is obtained. If a battery management task has a time difference greater than a first time threshold, the execution time of the battery management task in the battery management system is adjusted.
[0225] To determine the predicted deadline, the task code of the battery management task can be analyzed using a deadline prediction model to determine the task execution time; the task start time of the battery management task can also be obtained; then, based on the task start time and task execution time, the predicted deadline for the battery management task can be determined.
[0226] When obtaining the task execution time, the task code of the battery management task can be decomposed into multiple sub-operation codes. Then, the sub-execution time corresponding to each sub-operation code can be determined. The task execution time can then be determined based on the sub-execution times. For each sub-operation code, the number of instructions and the instruction type of each instruction can be analyzed. Based on the number of instructions and the instruction type, the sub-execution time corresponding to the sub-operation code can be determined.
[0227] In practical applications, the predicted deadline can be determined by combining the task priority of the battery management task, so that the predicted deadline of the higher-priority battery management task is earlier; when executing tasks, the battery management task with the earlier predicted deadline can be executed first.
[0228] In practical applications, when adjusting the execution time of battery management tasks in a battery management system, abnormal code segments can be identified by analyzing the execution time of each code segment. Then, the execution time of battery management tasks can be adjusted by moving accessed data to a preset memory area with high speed and by inlining and expanding functions.
[0229] Based on the battery management task execution time adjustment method provided in the above embodiments, this application also provides a battery management system. Figure 8 This is a schematic diagram of the structure of a battery management system provided in some embodiments of this application. For example... Figure 8 As shown, the battery management system includes:
[0230] Information acquisition unit 801 is used to acquire the task code of at least one battery management task in the battery management system and the actual deadline time corresponding to each of the at least one battery management task.
[0231] The processor 802 is configured to determine, for each battery management task, a predicted deadline corresponding to at least one battery management task based on the task code of at least one battery management task;
[0232] The processor 802 is also used to obtain the time difference between the actual deadline and the predicted deadline for each battery management task;
[0233] The processor 802 is also configured to, in response to a battery management task whose time difference is greater than a first time threshold, adjust the execution time of the battery management task in the battery management system so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold.
[0234] The battery management system provided in this application analyzes task codes based on a deadline prediction model. It can accurately analyze the possible predicted deadlines of battery management tasks based on the task codes of different battery management tasks. By comparing the predicted deadlines with the actual deadlines of the tasks, it can be determined whether there are cases where the task execution time is too long, and then corresponding optimizations can be made to avoid such cases, thereby improving the stability of the battery management system.
[0235] The battery management system provided in this application has the same embodiments and beneficial effects as the battery health status determination method provided above, and will not be repeated here.
[0236] To address the aforementioned technical problems, this application also provides a battery device, which includes the battery and battery management system mentioned in the above embodiments. The battery device provided in this application has the same embodiments and beneficial effects as the battery management system described above, and will not be repeated here.
[0237] To address the aforementioned technical problems, this application also provides an electrical device, including the battery device mentioned above. The electrical device provided in this application has the same embodiments and beneficial effects as the battery device described above, and will not be repeated here.
[0238] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0239] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable-ROM (E-ROM), floppy disks, compact disc-ROMs (CD-ROMs), optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0240] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0241] The foregoing flowcharts and / or block diagrams of methods, apparatus (systems) according to embodiments of this application have described various aspects of the present application. It should be understood that each block in the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to create a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowcharts and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0242] Although this application has been described with reference to preferred embodiments, various modifications can be made thereto and components can be replaced with equivalents without departing from the scope of this application. In particular, the technical features mentioned in the various embodiments can be combined in any manner, provided there is no structural conflict. This application is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A method for adjusting the execution time of a battery management task, characterized in that, include: Obtain the task code of at least one battery management task in the battery management system and the actual deadline of each of the at least one battery management task; For each of the battery management tasks, the predicted deadline for each of the at least one battery management task is determined based on the task code of the at least one battery management task. For each of the battery management tasks, obtain the time difference between the actual deadline and the predicted deadline; In response to a battery management task whose time difference is greater than a first time threshold, the execution time of the battery management task in the battery management system is adjusted so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold.
2. The method for adjusting the execution time of battery management tasks according to claim 1, characterized in that, For each of the battery management tasks, based on the task code of the at least one battery management task, determine the predicted deadline for each of the at least one battery management task, including: For each of the battery management tasks, perform the following steps: The task code of the battery management task is analyzed by the deadline prediction model to determine the task execution time of the battery management task; Obtain the start time of the battery management task; Based on the task start time and the task execution time, the predicted deadline for the battery management task is determined.
3. The method for adjusting the execution time of battery management tasks according to claim 2, characterized in that, The step of analyzing the task code of the battery management task using the deadline prediction model to determine the task execution time of the battery management task includes: The task code of the battery management task is decomposed to obtain multiple sub-operation codes of the battery management task; Determine the sub-execution time corresponding to each of the multiple sub-operation codes; The task execution time is determined based on the execution time of each sub-task.
4. The method for adjusting the execution time of battery management tasks according to claim 3, characterized in that, The task code of the battery management task is decomposed to obtain multiple sub-operation codes of the battery management task, including: Based on the functions of the battery management task, the task code is decomposed to obtain the sub-operation code corresponding to each function of the battery management task.
5. The method for adjusting the execution time of a battery management task according to claim 3 or 4, characterized in that, The step of determining the sub-execution time corresponding to each of the plurality of sub-operation codes includes: For each of the sub-operation codes, perform the following steps: The sub-execution time corresponding to the sub-operation code is determined based on the number of instructions in the sub-operation code and the instruction type of each instruction.
6. The method for adjusting the execution time of a battery management task according to any one of claims 1 to 5, characterized in that, For each of the battery management tasks, based on the task code of the at least one battery management task, determine the predicted deadline for each of the at least one battery management task, including: Obtain the task priority of the at least one battery management task; For each battery management task, the task code and task priority are analyzed to determine the predicted deadline, so that the predicted deadline corresponding to the battery management task with higher priority among the at least one battery management tasks is moved forward; Correspondingly, after analyzing the corresponding task code based on the pre-trained deadline prediction model for each battery management task to obtain the predicted deadline for the battery management task, the method further includes: Among the battery management tasks, the battery management task with the earlier predicted deadline is executed first.
7. The method for adjusting the execution time of a battery management task according to any one of claims 1 to 6, characterized in that, After determining the predicted deadline for each of the at least one battery management task based on its task code, the method further includes: Obtain the operating status parameter data corresponding to each of the battery management systems when executing the at least one battery management task; Based on the corresponding operating status parameter data, the prediction deadline is adjusted; Correspondingly, for each battery management task, obtaining the time difference between the actual deadline and the predicted deadline includes: Obtain the time difference between the actual deadline and the adjusted predicted deadline.
8. The method for adjusting the execution time of a battery management task according to any one of claims 1 to 7, characterized in that, The battery management tasks are multiple; For each of the battery management tasks, based on the task code of the at least one battery management task, determine the predicted deadline for each of the at least one battery management task, including: Obtain the dependencies between the different battery management tasks; the dependencies between any two battery management tasks include: the execution prerequisites of one battery management task are related to the execution state of another battery management task; For each of the battery management tasks, perform the following operations: Based on the dependencies and the associated battery management tasks that have the dependencies with the battery management task, the predicted deadline for the battery management task is determined.
9. The method for adjusting the execution time of a battery management task according to any one of claims 1 to 8, characterized in that, Adjusting the execution time of battery management tasks in the battery management system so that the time difference corresponding to the adjusted battery management tasks is less than or equal to the first time threshold includes: For each of the battery management tasks, obtain the code segment execution time of each code segment of the battery management task; From each code segment of the battery management task, identify the abnormal code segment whose execution time exceeds a second time threshold; The abnormal code segment is adjusted so that the execution time of the adjusted abnormal code segment is less than the second time threshold.
10. The method for adjusting the execution time of a battery management task according to claim 9, characterized in that, Adjusting the abnormal code segment so that its execution time is less than the second time threshold includes: Obtain the memory access count of the abnormal code segment; If the number of memory accesses exceeds a first threshold, the access data corresponding to the abnormal code segment is moved to a preset memory region; the access speed of the preset memory region is higher than that of the original memory region.
11. The method for adjusting the execution time of a battery management task according to any one of claims 9, characterized in that, Adjusting the abnormal code segment so that its execution time is less than the second time threshold includes: Obtain the number of nested function calls in the exception code segment; If the number of nested function calls exceeds a second threshold, the abnormal code segment will be expanded by function inlining.
12. The method for adjusting the execution time of a battery management task according to any one of claims 1 to 11, characterized in that, Adjusting the execution time of battery management tasks in the battery management system so that the time difference corresponding to the adjusted battery management tasks is less than or equal to the first time threshold includes: Analyze the task operations of each of the battery management tasks described; Identify multiple target battery management tasks that have the same task operations; The multiple target battery management tasks are merged.
13. The method for adjusting the execution time of a battery management task according to any one of claims 1 to 11, characterized in that, Before obtaining the predicted deadline for each battery management task by analyzing the corresponding task code based on a pre-trained deadline prediction model, the method further includes: For each of the battery management tasks, perform the following steps: Obtain the execution time characteristics, historical execution time, and corresponding influencing factors of the battery management task; the influencing factors include the task attributes of the battery management task; Based on the execution time characteristics, determine the model type of the deadline prediction model corresponding to the battery management task; Based on the historical execution time and the corresponding influencing factors affecting the historical execution time, a target model of the model type is trained to obtain the deadline prediction model.
14. The method for adjusting the execution time of a battery management task according to claim 13, characterized in that, Based on the historical execution time and the corresponding influencing factors affecting the historical execution time, a target model of the model type is trained to obtain the deadline prediction model, including: The influencing factors are input into the target model to obtain the predicted execution time; The predicted execution time is compared with the corresponding historical execution time to obtain the difference value; If the difference value does not meet the iteration stopping condition, adjust the target model; and return to the step of inputting the influencing factors into the target model to obtain the predicted execution time; If the difference value satisfies the iteration stopping condition, the current target model is determined as the deadline prediction model.
15. A battery management system, characterized in that, include: An information acquisition unit is used to acquire the task code of at least one battery management task in the battery management system and the actual deadline of each of the at least one battery management task. The processor is configured to, for each of the battery management tasks, determine the predicted deadline for each of the at least one battery management task based on the task code of the at least one battery management task; The processor is also configured to, for each of the battery management tasks, obtain the time difference between the actual deadline and the predicted deadline; The processor is further configured to, in response to a battery management task whose time difference is greater than a first time threshold, adjust the execution time of the battery management task in the battery management system so that the time difference corresponding to the adjusted battery management task is less than or equal to the first time threshold.
16. A battery device, characterized in that, Includes the battery and battery management system as described in claim 15.
17. An electrical appliance, characterized in that, Includes the battery device as described in claim 16.