Task processing method, system, device, medium and product of battery management system
Patent Information
- Application Number
- CN202510433054.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2026-10-16
AI Technical Summary
那些依赖这些执行时间过长任务的其他任务,由于无法及时获取所需的结果或数据,其执行进程也会因此受到影响
[0017] By saving the archive files generated by the target task to a shared database or a backup target task, the possibility of the archive files not being available when the target task encounters an anomaly is reduced, further improving the reliability of archive file retrieval.
Smart Images

Figure CN122924975A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of system management, and in particular to a task processing method, system, device, medium and product for a battery management system. Background Technology
[0002] In battery management systems (BMS), many tasks are closely interdependent. If the execution time of some tasks is excessively long, it can trigger a chain reaction. Other tasks that depend on these time-consuming tasks will also be affected, as they will be unable to obtain the necessary results or data in a timely manner. This significantly reduces the overall efficiency of the BMS and may even disrupt the normal workflow of the entire system. Therefore, minimizing the negative chain reactions caused by abnormal task execution times and ensuring the efficient and stable operation of the BMS is a pressing technical problem that needs to be solved. Summary of the Invention
[0003] This application provides a task processing method, system, device, medium, and product for a battery management system, which can promptly reduce the execution time of a target task through priority adjustment and reduce the impact on other tasks that depend on the target task.
[0004] In a first aspect, this application provides a task processing method, including: obtaining the expected execution time and the actual execution time of the target task; determining whether the target task has timed out based on the expected execution time and the actual execution time; adjusting the priority of the target task in acquiring processor resources when the target task has timed out and no other exceptions occur in task execution; the other exceptions are exceptions other than timeout among the exceptions in task execution.
[0005] In the technical solution of this application embodiment, by using the expected execution time of the target task, it is possible to accurately and timely detect whether the execution time of the target task has been exceeded. If the target task times out but no anomaly occurs, the remaining execution time of the target task is adjusted in a timely manner by adjusting the priority of the target task in acquiring processor resources. This changes the overall execution time of the target task, reducing the potential adverse effects on other tasks that depend on it, and improving the overall stability and reliability of the battery management system. Furthermore, while detecting timeouts of the target task, it also further determines whether an anomaly has occurred in the target task, reducing the possibility of the target task still preempting excess processor resources through priority adjustment after an anomaly has occurred, thus improving the overall operating efficiency of the battery management system.
[0006] In some embodiments, after detecting whether the target task has timed out based on the expected execution duration, the task processing method further includes:
[0007] If the target task times out or other exceptions occur during task execution, the target task will be initialized or switched to the target backup task corresponding to the target task.
[0008] When the target task times out and an exception occurs, the target task can be restarted by initializing or switching to a backup task, which reduces the occurrence of the target task being in an abnormal state for a long time, thereby seriously affecting other tasks that depend on the target task.
[0009] In some embodiments, determining whether a target task has timed out based on the expected execution time and the actual execution time includes:
[0010] The target execution progress of the target task is determined by setting the target task nodes; if the target execution progress is greater than the preset progress threshold, the first execution time corresponding to the target execution progress is determined based on the target execution progress and the expected execution time; the target time when the target task completes the target execution progress is determined based on the actual execution time; if the target time is greater than the first execution time, the target task is determined to have timed out.
[0011] By determining the completion time of the target task, it is possible to predict in advance whether the target task will time out. Furthermore, based on this prediction, remedial measures can be taken in advance to effectively reduce the impact on other tasks that depend on the target task.
[0012] In some embodiments, switching the target task to the target backup task corresponding to the target task includes:
[0013] The target archive file closest to the current time is obtained from multiple archive files corresponding to the target task; during the execution of the target task, an archive file is generated at preset intervals, and the archive file is used to save the task execution parameters of the target task at different times; based on the task execution parameters saved in the target archive file, the target task is switched to the target backup task corresponding to the target task, so that the target backup task performs task execution based on the task execution parameters saved in the target archive file.
[0014] By periodically saving the task execution parameters during the execution of the target task through a file, the target backup task does not need to start from scratch when it is executed, which further reduces the completion time of the target backup task and reduces the impact on other tasks that depend on the target task.
[0015] In some embodiments, obtaining the target archive file that is closest to the current time includes:
[0016] The target archive file is retrieved from the shared database; wherein, after generating the archive file, the target task sends the archive file to the shared database; or, the target archive file is retrieved from the target standby task; wherein, after generating the archive file, the target task sends the archive file to the target standby task.
[0017] By saving the archive files generated by the target task to a shared database or a backup target task, the possibility of the archive files not being available when the target task encounters an anomaly is reduced, further improving the reliability of archive file retrieval.
[0018] In some embodiments, after receiving an archive file sent by the target task, the target backup task will replace the archive file saved by the target backup task with the received archive file.
[0019] By updating the saved archive files in real time in the target backup task, the target backup task can save only the latest archive files, thus saving memory for the target backup task.
[0020] In some embodiments, adjusting the priority of a target task in acquiring processor resources includes:
[0021] If the target task is a preset non-critical task, reduce the priority of the target task in acquiring processor resources; or, if the target task is not a preset non-critical task, increase the priority of the target task in acquiring processor resources.
[0022] By lowering the priority of pre-defined non-critical tasks that have timed out in acquiring processor resources, resources can be further allocated to other tasks, thereby reducing the timeouts of other more important tasks. Simultaneously, by increasing the priority of timed-out tasks that are not pre-defined non-critical tasks in acquiring processor resources, the remaining execution time of those non-pre-defined non-critical tasks can be reduced, further minimizing the impact on other tasks that depend on this target task.
[0023] In some embodiments, when the target task is not a preset non-critical task, the above task processing method further includes:
[0024] Acquire related tasks that conflict with the target task in terms of processor resources; if the related tasks are not preset critical tasks, reduce the priority of the related tasks in acquiring processor resources.
[0025] By further reducing the priority of non-critical tasks that conflict with the target task in terms of processor resources, it is possible to ensure that the target task obtains more processor resources, thereby further accelerating the execution speed of the target task and reducing the remaining execution time.
[0026] In some embodiments, obtaining the actual execution time corresponding to the target task includes: obtaining the actual execution time through the duration recorded by the timer corresponding to the target task; wherein the timer starts counting when the target task begins execution and stops counting when the target task completes execution. This allows for accurate acquisition of the real-time execution time of the target task.
[0027] In some embodiments, obtaining the actual execution time corresponding to the target task includes: obtaining the initial time of the battery management system where the target task is located when the target task starts to execute; periodically obtaining the time of the battery management system based on a preset period during the execution of the target task; and obtaining the actual execution time corresponding to the target task based on the periodically obtained battery management system time and the initial time.
[0028] By periodically obtaining the system time, the execution duration of the target task can be determined without the need for an external timer.
[0029] Secondly, this application provides a battery management system, including: an information acquisition module for acquiring the expected execution time and the actual execution time of a target task; a processor for determining whether the target task has timed out based on the expected execution time and the actual execution time; and adjusting the priority of the target task in acquiring processor resources if the target task has timed out and no other exceptions occur in the task execution; the other exceptions are exceptions other than timeout among the exceptions in the task execution.
[0030] Thirdly, this application provides an electrical device comprising: a processor and a memory storing computer program instructions; the processor, when executing the computer program instructions, implements the task processing method as shown in any embodiment of the first aspect.
[0031] Fourthly, this application provides a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the task processing method shown in any embodiment of the first aspect.
[0032] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electrical device, cause the electrical device to perform the task processing method shown in any embodiment of the first aspect. Attached Figure Description
[0033] The features, advantages, and technical effects of exemplary embodiments of this application will now be described with reference to the accompanying drawings.
[0034] Figure 1 This is one of the flowcharts illustrating a task processing method for a battery management system according to some embodiments of this application;
[0035] Figure 2 This is a schematic diagram of a process for obtaining the actual execution time corresponding to a target task according to some embodiments of this application;
[0036] Figure 3 This is a schematic diagram of a process for determining a target task timeout according to some embodiments of this application;
[0037] Figure 4 This is a schematic diagram illustrating a process for adjusting the priority of a target task in acquiring processor resources, according to some embodiments of this application.
[0038] Figure 5 This is a second schematic flowchart of a task processing method for a battery management system according to some embodiments of this application;
[0039] Figure 6 This is a schematic diagram of a process for switching a target task to a target backup task according to some embodiments of this application;
[0040] Figure 7 One of the schematic diagrams illustrating the sending of archive files to a target task in some embodiments of this application;
[0041] Figure 8 A second schematic diagram illustrating the sending of archive files to a target task in some embodiments of this application;
[0042] Figure 9 This is a schematic diagram of the structure of a battery management system according to some embodiments of this application;
[0043] Figure 10 This is a schematic diagram of the structure of an electrical device according to some embodiments of this application.
[0044] The accompanying drawings are not necessarily drawn to scale. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the embodiments of the technical solutions of this application will be described in detail below with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solutions of this application more clearly, and are therefore only examples, and should not be used to limit the scope of protection of this application.
[0046] 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.
[0047] 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.
[0048] 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.
[0049] In the description of the embodiments in this application, the term "and / or" is merely a description of the association 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. The term "multiple" refers to two or more (including two).
[0050] The Battery Management System (BMS) 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 BMS of this application can also implement 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. It should be noted that the BMS of this application can be integrated as a controller into a battery device, such as into a battery pack or energy storage box; the BMS of this application can also be integrated as a controller into an electrical device, such as into a vehicle or vehicle chassis; the BMS of this application can also be integrated as a controller into a charging device, such as into a charging device or battery swapping device; the BMS of this application can also be deployed as control software on a server. A 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, CDN (Content Delivery Network), and big data and artificial intelligence platforms, such as vehicle networking cloud, APP backend, etc.
[0051] As shown in the background section, battery management systems allow multiple tasks to run simultaneously. By rationally allocating system resources (such as CPU time, memory, and I / O devices), each task can be processed in a timely manner, thereby achieving efficient resource utilization and parallel task execution. In complex battery management systems, task execution is often influenced by a combination of complex factors. These factors include, but are not limited to, the allocation of system resources, task priority settings, data interaction between tasks, and potential unforeseen circumstances. If the execution time of some tasks is too long, it can trigger a series of chain reactions. In battery management systems, many tasks have close dependencies. For example, battery thermal runaway warning and handling tasks rely on the execution results of battery temperature detection tasks. Other tasks that depend on these time-consuming tasks will also be affected because they cannot obtain the required results or data in a timely manner. They may have to enter a waiting state, delaying subsequent operations, and may even cause chaos and stagnation in the entire system's workflow, severely reducing system efficiency and overall performance.
[0052] To address the aforementioned technical problems, this application provides a task processing method, system, device, medium, and product for a battery management system. By accurately and promptly detecting whether the expected execution time of a target task has been exceeded based on the target task's expected execution time, and adjusting the priority of the target task in acquiring processor resources when the target task times out without any anomalies, the remaining execution time of the target task can be adjusted in a timely manner. This changes the overall execution time of the target task, reducing potential adverse effects on other tasks that depend on it, and improving the overall stability and reliability of the battery management system. Furthermore, while detecting timeouts, the system also determines whether any anomalies have occurred in the target task, reducing the likelihood of a target task already experiencing anomalies still preempting excess processor resources through priority adjustments, thus improving the overall operating efficiency of the battery management system.
[0053] The task processing method provided in this application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0054] Figure 1 This is one of the flowcharts illustrating a task processing method for a battery management system provided in some embodiments of this application. This task processing method for a battery management system can be applied to a host computer, various in-vehicle systems developed for automotive open system architectures, battery management systems (BMS), or other electrical devices with data processing capabilities such as mobile phones, laptops, tablets, and desktop computers.
[0055] like Figure 1 As shown, the task processing method may include the following S101-S103.
[0056] S101, obtain the expected execution time and actual execution time of the target task.
[0057] S102, determine whether the target task has timed out based on the expected execution time and the actual execution time.
[0058] S103, If the target task times out and no other exceptions occur during task execution, adjust the priority of the target task in acquiring processor resources.
[0059] In the technical solution of this application embodiment, by using the expected execution time of the target task, it is possible to accurately and timely detect whether the execution time of the target task has been exceeded. If the target task times out but no other anomalies occur, the remaining execution time of the target task is adjusted by changing the priority of the target task in acquiring processor resources. This changes the overall execution time of the target task, reducing potential adverse effects on other tasks that depend on it, and improving the overall stability and reliability of the battery management system. Furthermore, while detecting timeouts in the target task, it also further determines whether an anomaly has occurred in the target task. This reduces the risk of the target task, already exhibiting anomalies, still preempting excess processor resources through priority adjustment. Other normal tasks might fail to run properly due to excessive resource consumption by the abnormal task, leading to a decrease in overall system performance and impacting the overall operating efficiency of the battery management system.
[0060] The above steps are explained in detail below:
[0061] In S101, the target task is the task that will be processed immediately. It should be noted that, in this embodiment, the target task can theoretically be any task within the battery management system; it is referred to as the target task here for ease of description and does not imply a specific limitation on the task. The expected execution time is the expected execution time of each task under normal circumstances in a multi-task system. To ensure stable operation during the execution of multiple tasks, the battery management system sets an expected execution time for each task. This expected execution time can also be an execution time limit set by the system for each task. Therefore, the expected execution time of each task can be obtained directly through the battery management system. In one example, the expected execution time of each task can be pre-configured and saved, allowing the expected execution time of the target task to be retrieved directly from the location where the expected execution time is saved. The actual executed time of the target task is the time consumed during its execution. This actual executed time is generally calculated from the start of the target task's execution and increases continuously over time. In one example, the actual executed time of the target task can be obtained by real-time monitoring of the target task's execution time.
[0062] To accurately obtain the actual execution time corresponding to the target task, in some embodiments, step S101 above, obtaining the actual execution time corresponding to the target task, includes:
[0063] The actual execution time is obtained by recording the duration of the timer corresponding to the target task; the timer starts counting when the target task begins execution and stops counting when the target task is completed.
[0064] The timer starts timing when the target task begins execution. That is, once the target task starts, the timer begins working, ensuring that time is recorded from the moment the task begins. Then, it continuously times the target task during execution until the task is completed, at which point the timer stops. This allows for accurate acquisition of the execution duration of the target task at any given point in time. Furthermore, since the timer is a standalone program, its operation is unaffected by the target task, further ensuring the accuracy and reliability of the real-time execution duration acquisition.
[0065] In some embodiments, reference Figure 2 In step S101 above, obtaining the actual execution time corresponding to the target task includes the following steps S201-S203:
[0066] S201, when the target task starts execution, obtain the initial time of the battery management system where the target task is located.
[0067] S202, During the execution of the target task, the battery management system time is periodically obtained based on a preset cycle.
[0068] S203, based on the battery management system time and initial time obtained periodically, obtain the actual execution time corresponding to the target task.
[0069] In some embodiments, the battery management system (BMS) provides the execution environment for the target task. The initial time of the BMS is the system time inherent to the BMS when the target task begins execution. In this embodiment, the start time of the target task can be determined based on this system time. After obtaining the initial time, during the execution of the target task, the BMS time can be periodically acquired according to a preset period. This preset period can be set as needed and is not limited. Generally, the shorter the preset period, the more accurate the actual execution time of the target task can be obtained. However, this also brings additional costs and efficiency losses. Therefore, a suitable preset period can be set according to different accuracy requirements. In one example, the preset period can be set to 100ms, meaning the BMS time is acquired every 100ms.
[0070] In some embodiments, when obtaining the actual execution time corresponding to the target task based on the periodically acquired battery management system time and the initial time, the time of the battery management system closest to the current time can be determined from the periodically acquired battery management system time, and then the difference between the closest battery management system time and the aforementioned initial time can be used to determine the actual execution time corresponding to the target task.
[0071] By periodically acquiring the system time, the execution duration of the target task can be determined without the need for an external timer. This not only reduces reliance on external timers and lowers system complexity and cost, but also improves the flexibility and accuracy of duration calculation, better meeting the needs for monitoring and analyzing task execution duration in different scenarios.
[0072] In S102, the timeout of the target task can be determined by comparing the expected execution time with the actual execution time. In one example, if the actual execution time is longer than the expected execution time, the target task is determined to have timed out. If the target task is determined to have timed out, step S103 is executed. If the target task is determined not to have timed out, the timeout determination can continue.
[0073] In order to determine whether a target task has timed out before it completes, in some embodiments, reference is made to... Figure 3 In step S102 above, determining whether the target task has timed out based on the expected execution time and the actual execution time includes the following steps S301-S304.
[0074] S301 determines the target execution progress of the target task by pre-setting task nodes.
[0075] S302, if the target execution progress is greater than the preset progress threshold, determine the first execution time corresponding to the target execution progress based on the target execution progress and the expected execution time.
[0076] S303, determine the target duration when the target task is completed based on the actual execution duration.
[0077] S304, if the target duration is longer than the first execution duration, determine that the target task has timed out.
[0078] In some embodiments, task execution progress is a quantitative assessment of the degree of task completion, reflecting the progress of the task towards the result within a certain period of time. In some examples, task execution progress can be represented by the percentage of task completion. In other examples, task execution progress can be represented by preset task stages, such as early-stage, mid-stage, and late-stage tasks. It should be noted that for an executing task to be completed on time, the completion time of the task at each execution stage needs to be controlled within a certain range. If this range is exceeded, the task generally cannot be completed on time. For example, if the expected execution time of a target task is 10 seconds, and 9 seconds have already been spent when the target task is halfway through, then at the previous execution speed, it will definitely not be able to complete the remaining half of the progress within the remaining 1 second. Therefore, it can be predicted in advance that the task will time out.
[0079] In some embodiments, the target execution progress of the target task can be determined by preset task nodes. In one example, multiple preset task nodes can be configured in advance for each task according to the percentage of task completion. For example, a preset task node is set every 10% of the task is completed. When it is determined that a task has just completed the 5th preset task node, the execution progress of the task can be determined to be 50% of the total progress.
[0080] To improve the accuracy of determining whether a target task has timed out based on its execution progress, in this embodiment, a first execution duration is determined based on the target execution progress and the expected execution duration only when the target execution progress exceeds a preset progress threshold. This preset progress threshold is a reference value used by the battery management system to determine whether the target task execution progress has reached a specified progress. When the target task execution progress reaches the specified progress, it indicates that the timeout of the target task can be determined by its execution progress. In other words, the preset progress threshold is used to determine whether the target task has timed out based on its target execution progress. The specific value of this preset progress threshold can be set as needed; for example, it can be set to 50% of the total execution progress. In some embodiments, the first execution duration refers to the maximum allowed time threshold when the task execution progress reaches the target execution progress, ensuring that the overall target task does not time out. If, during the task's progress, the actual time taken to reach the target execution progress exceeds this maximum time threshold, it indicates that the task execution efficiency is lower than expected, and there is a high risk of timeout. In this case, it can be determined that the target task is highly likely to time out. When determining the first execution time corresponding to the target execution progress based on the target execution progress and the expected execution time, one can first determine a reasonable execution time corresponding to the target execution progress based on the target execution progress and the expected execution time. Then, based on this reasonable execution time, a maximum deviation time is added to obtain the first execution time corresponding to the target execution progress. For example, if the target execution progress of a certain task is 50% of the total execution progress, and assuming the expected execution time of the target task is 10 seconds, then the reasonable execution time corresponding to this target execution progress is 5 seconds. At the same time, based on experience or historical data, the maximum deviation time is determined to be 2 seconds. Therefore, the final first execution time corresponding to the target execution progress is 7 seconds.
[0081] Since the actual execution time of the target task may not correspond exactly to a pre-defined task node, in some scenarios, the real-time actual execution time may be greater than the target time when the target task completes its target execution progress. Therefore, when the actual execution time of the target task at the current moment is obtained, the target time when the target task completes its target execution progress can be further determined based on this actual execution time. For example, if the actual execution time at the current moment is 6 seconds, and the target execution progress was completed 1 second ago, then the corresponding target time when the target task completes its target execution progress is 5 seconds. After determining the target time and the first execution time, the target task can be determined to have timed out by comparing their relative magnitudes. That is, if the target time is greater than the first execution time, the target task is determined to have timed out.
[0082] By determining the completion time of the target task, it is possible to predict in advance whether the target task will time out. Furthermore, based on this judgment, remedial measures can be taken in advance to effectively reduce the impact on other tasks that depend on the target task.
[0083] In S103, after determining that the target task has timed out, it is further determined whether the target task has encountered other execution exceptions, namely exceptions other than timeout. If the target task encounters other execution exceptions, it may cause the task to stall. In this case, simply adjusting the priority of the target task in acquiring processor resources will not be able to restore the target task to a normal execution state. Therefore, in order to reduce the waste of processor resources, in this embodiment, the priority of the target task in acquiring processor resources is adjusted only when the target task times out and no other execution exceptions occur.
[0084] In some embodiments, other exceptions to task execution include at least one of the following: task resource access exception, task status exception, and task error status return. Task resource access exceptions may include memory access errors, other resource contention, etc.; task error status returns may include function call errors, hardware error feedback, etc.; and task status exceptions may include task suspension or blocking exceptions, task termination exceptions, etc.
[0085] In order to accurately adjust the priority of the target task in acquiring processor resources, in some embodiments, step S103 above, adjusting the priority of the target task in acquiring processor resources, includes:
[0086] If the target task is a pre-defined non-critical task, reduce the priority of the target task in acquiring processor resources;
[0087] Alternatively, if the target task is not a pre-defined non-critical task, increase the priority of the target task in acquiring processor resources.
[0088] It should be noted that preset non-critical tasks can be set as needed and are not limited in this regard. In one example, tasks with no dependencies can be identified as preset non-critical tasks, meaning that the execution result of a preset non-critical task will not affect other tasks. In another example, preset non-critical tasks can also be set based on the importance of different tasks. For example, factors such as the real-time nature of the task, its system impact, and the severity of the consequences can be considered to determine whether a task is a preset non-critical task. It should also be noted that in a battery management system, the execution of some tasks depends on the execution results of other tasks. If the execution result of one task is needed by other tasks, then that task has a dependency. For example, the battery thermal runaway warning and handling task depends on the execution result of the battery temperature detection task. Therefore, the battery temperature detection task has a dependency.
[0089] In some embodiments, when the target task is a preset non-critical task, the specific level of reducing the priority of the target task in acquiring processor resources can be determined based on the difference between the expected execution time and the actual execution time. For example, the specific level of reducing the priority of the target task in acquiring processor resources can be directly proportional to the difference between the expected execution time and the actual execution time. That is, the greater the difference between the expected execution time and the actual execution time, the lower the level of reducing the priority of the target task in acquiring processor resources.
[0090] In some embodiments, when the target task is not a preset non-critical task, the priority of the target task in acquiring processor resources can be determined based on the difference between the expected execution time and the actual execution time. For example, the specific level of priority increase for the target task in acquiring processor resources can be directly proportional to the difference between the expected execution time and the actual execution time. That is, the greater the difference between the expected execution time and the actual execution time, the lower the corresponding priority increase level for the target task in acquiring processor resources.
[0091] By lowering the priority of pre-defined non-critical tasks that have timed out in acquiring processor resources, resources can be further allocated to other tasks, thereby reducing the timeouts of other more important tasks. Simultaneously, by increasing the priority of timed-out tasks that are not pre-defined non-critical tasks in acquiring processor resources, the remaining execution time of those non-pre-defined non-critical tasks can be reduced, further minimizing the impact on other tasks that depend on this target task.
[0092] To further accelerate the processing speed of the target task, in some embodiments, when the target task is not a preset non-critical task, the above task processing method further includes:
[0093] Acquire related tasks that conflict with the target task in terms of processor resources; if the related tasks are not preset critical tasks, reduce the priority of the related tasks in acquiring processor resources.
[0094] By further reducing the priority of non-critical tasks that conflict with the target task in terms of processor resources, it is possible to ensure that the target task obtains more processor resources, thereby further accelerating the execution speed of the target task and reducing the remaining execution time.
[0095] In order to secure more processor resources for the target task, in some embodiments, reference is made to Figure 4 In step S103 above, adjusting the priority of the target task in acquiring processor resources includes the following steps, S401-403.
[0096] S401, when the target task is not a preset non-critical task, increases the priority of the target task in acquiring processor resources.
[0097] S402, acquire related tasks that conflict with the target task in terms of processor resources.
[0098] S403, when the relevant task is not a preset critical task, reduces the priority of the relevant task in acquiring processor resources.
[0099] By simultaneously increasing the priority of the target task in acquiring processor resources and decreasing the priority of related tasks in acquiring processor resources, processor resources can be secured for the target task to the greatest extent possible, thereby improving the execution speed of the target task and reducing the remaining execution time.
[0100] To ensure timely recovery of the target task in the event of an anomaly, in some embodiments, after detecting whether the target task has timed out based on the expected execution duration, the task processing method further includes:
[0101] If the target task times out or other exceptions occur during task execution, the target task will be initialized or switched to the target backup task corresponding to the target task.
[0102] In some embodiments, to quickly launch an identical task in the event of an anomaly or stall in a given task, the battery management system pre-configures a backup task for each task. Normally, this backup task will not be launched. However, when the task corresponding to the backup task encounters an anomaly, the backup task will be launched as an alternative to continue the task's execution. The target backup task is the backup task corresponding to the target task. If the target task times out or encounters other execution anomalies, the target task can be randomly initialized, or the target task can be switched to its corresponding target backup task.
[0103] When the target task times out and an exception occurs, the target task can be restarted by initializing or switching to a backup task, which reduces the occurrence of the target task being in an abnormal state for a long time, thereby seriously affecting other tasks that depend on the target task.
[0104] In some embodiments, reference Figure 5 The task processing method of this application includes the following steps S501-S503.
[0105] S501, obtain the expected execution time and actual execution time of the target task.
[0106] S502 determines whether the target task has timed out based on the expected execution time and the actual execution time.
[0107] S503: If the target task times out or other exceptions occur during task execution, initialize the target task or switch the target task to the corresponding backup target task.
[0108] It should be noted that steps S501-S502 are similar to steps S101-S102, and the specific process will not be repeated. In step S503, initializing the target task means restoring its normal execution by restarting it. Switching the target task to its corresponding backup task means starting a task identical to the target task to perform the task execution. In one example, if the target task times out and other execution exceptions occur, the system can choose to initialize the target task or switch to its corresponding backup task as needed. Therefore, in the event of an exception to the target task, the system can quickly resume task execution by initializing the task or switching to the backup task, ensuring system stability and reliability.
[0109] To reduce the execution time of backup tasks and ensure that the target backup tasks can execute as close as possible to the current progress of the target task, in some embodiments, reference is made to... Figure 6 In step S503 above, the target task is switched to the target backup task corresponding to the target task, including the following steps S601-S602.
[0110] S601, obtain the target archive file closest to the current time from multiple archive files corresponding to the target task; during the task execution process, the target task generates an archive file at preset intervals, and the archive file is used to save the task execution parameters of the target task at different times.
[0111] S602, based on the task execution parameters saved in the target archive file, the target task is switched to the target standby task corresponding to the target task, so that the target standby task performs task execution based on the task execution parameters saved in the target archive file.
[0112] In some embodiments, the preset duration can be set as needed and is not limited thereto. Task execution parameters are the various parameters used during task execution. Since the target backup task and the target task are essentially the same task, these task execution parameters allow the backup task to quickly resume the execution progress of the original task without having to start from scratch. In one example, the task execution parameters cover various key information of the target task during execution, such as specific operation steps, various types of data involved, and runtime environment configuration.
[0113] By periodically saving task execution parameters during the execution of the target task using archive files, the backup task can be executed without having to start from scratch. Compared to starting the task from the beginning, this significantly saves time and resources, improving task execution efficiency. Simultaneously, it further reduces the impact on other tasks that depend on the target task. In complex battery management systems, tasks often have close dependencies; a delay or interruption in one task can trigger a chain reaction, affecting the normal operation of the entire system. This archive file and backup task mechanism minimizes this impact even if the target task encounters problems and needs to switch to the backup task, ensuring the stable and efficient operation of the entire task system.
[0114] To ensure the reliability of the target archive file, in some embodiments, the target archive file closest to the current time is obtained, including:
[0115] Retrieve the target archive file from the shared database; the target task sends the archive file to the shared database after generating it.
[0116] Alternatively, the target archive file can be obtained from the target standby task; wherein, after generating the archive file, the target task sends the archive file to the target standby task.
[0117] In some embodiments, the shared database serves as a centralized data storage and management platform, possessing powerful data storage capabilities and high reliability. Once the target task generates archive files, these archive files are promptly and accurately stored in the shared database. This ensures that even if unforeseen anomalies occur during the execution of the target task, such as program crashes or network failures, the archive files remain securely stored in the shared database and will not be lost or unretrievable due to the target task's malfunction. (Reference) Figure 7 Once the target task 01 generates an archive file, it will upload the archive file to the shared database 02. Then, when the target backup task 03 starts, it can directly retrieve the archive file from the shared database 02.
[0118] In some embodiments, after the target task generates an archive file, the archive file can be promptly sent to the target backup task for storage. This not only reduces the possibility of archive files being lost in the target task but also further improves the speed at which the backup device acquires task execution parameters. (Reference) Figure 8 Once target task 01 generates an archive file, it will send the archive file directly to target backup task 03. When target backup task 03 starts, it can directly obtain the archive file from its local machine.
[0119] By saving the archive files generated by the target task to a shared database or a backup target task, the possibility of the archive files not being available when the target task encounters an anomaly is reduced, further improving the reliability of archive file retrieval.
[0120] To further conserve memory occupied by the target backup task, in some embodiments, the target backup task replaces the archive file saved by the target backup task with the received archive file each time it receives an archive file sent by the target task.
[0121] By updating the saved archive files in real time in the target backup task, the target backup task can save only the latest archive files, thus saving memory for the target backup task.
[0122] Based on the same inventive concept, this application also provides a battery management system. The following, in conjunction with... Figure 9 The battery management system provided in the embodiments of this application will be described in detail.
[0123] Figure 9 A schematic diagram of a battery management system provided in one embodiment of this application is shown.
[0124] like Figure 9 As shown, the battery management system includes:
[0125] Information acquisition module 901 acquires the expected execution time and actual execution time of the target task;
[0126] Processor 902 determines whether the target task has timed out based on the expected execution time and the actual execution time; and if the target task times out and no other exceptions occur during task execution, it adjusts the priority of the target task in acquiring processor resources; other exceptions are exceptions other than timeouts among the exceptions during task execution.
[0127] In some embodiments, the battery management system further includes a recovery module, which is used for:
[0128] If the target task times out or other exceptions occur during task execution, the target task will be initialized or switched to the target backup task corresponding to the target task.
[0129] When the target task times out and an exception occurs, the target task can be restarted by initializing or switching to a backup task, thus reducing the possibility of the target task being in an abnormal state for a long time, which could seriously affect other tasks that depend on the target task.
[0130] In some embodiments, the processor 902 is specifically used for:
[0131] The target execution progress of the target task is determined by pre-setting task nodes;
[0132] If the target execution progress is greater than the preset progress threshold, the first execution time corresponding to the target execution progress is determined based on the target execution progress and the expected execution time.
[0133] The target duration for achieving the target task's execution progress is determined based on the actual execution time already completed.
[0134] If the target duration exceeds the first execution duration, the target task is determined to have timed out.
[0135] By determining the completion time of the target task, it is possible to predict in advance whether the target task will time out. Furthermore, based on this judgment, remedial measures can be taken in advance to effectively reduce the impact on other tasks that depend on the target task.
[0136] In some embodiments, the recovery module includes:
[0137] The acquisition unit acquires the target archive file closest to the current time from multiple archive files corresponding to the target task; during the execution of the target task, an archive file is generated at preset intervals, and the archive file is used to save the task execution parameters of the target task at different times;
[0138] The switching unit switches the target task to the target backup task corresponding to the target task based on the task execution parameters saved in the target archive file, so that the target backup task can perform task execution based on the task execution parameters saved in the target archive file.
[0139] By periodically saving the task execution parameters during the execution of the target task through a file, the target backup task does not need to start from scratch when executing the task, which further reduces the completion time of the target backup task and reduces the impact on other tasks that depend on the target task.
[0140] In some embodiments, the above-mentioned acquisition unit is specifically used for:
[0141] The target archive file is retrieved from the shared database; wherein, after generating the archive file, the target task sends the archive file to the shared database; or, the target archive file is retrieved from the target standby task; wherein, after generating the archive file, the target task sends the archive file to the target standby task.
[0142] By saving the archive files generated by the target task to a shared database or a backup target task, the possibility of the archive files not being available when the target task encounters an anomaly is reduced, further improving the reliability of archive file retrieval.
[0143] In some embodiments, after receiving an archive file sent by the target task, the target backup task will replace the archive file saved by the target backup task with the received archive file.
[0144] By updating the saved archive files in real time in the target backup task, the target backup task can save only the latest archive files, thus saving memory for the target backup task.
[0145] In some embodiments, the above-mentioned adjustment module is specifically used for:
[0146] If the target task is a preset non-critical task, reduce the priority of the target task in acquiring processor resources; or, if the target task is not a preset non-critical task, increase the priority of the target task in acquiring processor resources.
[0147] By lowering the priority of pre-defined non-critical tasks that have timed out in acquiring processor resources, resources can be further allocated to other tasks, thereby reducing the timeouts of other more important tasks. Simultaneously, by increasing the priority of timed-out tasks that are not pre-defined non-critical tasks in acquiring processor resources, the remaining execution time of those non-pre-defined non-critical tasks can be reduced, further minimizing the impact on other tasks that depend on this target task.
[0148] In some embodiments, the battery management system further includes a priority reduction module, which is used to:
[0149] Acquire related tasks that conflict with the target task in terms of processor resources; if the related tasks are not preset critical tasks, reduce the priority of the related tasks in acquiring processor resources.
[0150] By further reducing the priority of non-critical tasks that conflict with the target task in terms of processor resources, it is possible to ensure that the target task obtains more processor resources, thereby further accelerating the execution speed of the target task and reducing the remaining execution time.
[0151] In some embodiments, the acquisition module 901 is specifically used for:
[0152] The actual execution time is obtained by recording the duration of the timer corresponding to the target task; the timer starts counting when the target task begins execution and stops counting when the target task completes execution. This allows for an accurate determination of the real-time execution time of the target task.
[0153] In some embodiments, the acquisition module 901 is specifically used for:
[0154] When the target task begins execution, obtain the initial time of the battery management system where the target task is located; during the execution of the target task, obtain the time of the battery management system periodically based on a preset cycle; based on the periodically obtained battery management system time and the initial time, obtain the actual execution time corresponding to the target task.
[0155] By periodically obtaining the system time, the execution duration of the target task can be determined without the need for an external timer.
[0156] Based on the same inventive concept, this application also provides an electrical device, which includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, it implements the task processing method shown in any of the above embodiments.
[0157] like Figure 10 A schematic diagram of an electrical device according to an embodiment of this application is shown. This electrical device can be integrated into an electric vehicle and includes a processor and an operating system mounted on the processor.
[0158] like Figure 10 As shown, the electrical device 1000 includes a battery management system as described in any of the above embodiments, thereby enabling the task processing method according to the embodiments of this application. The electrical device may refer to a structural diagram of an exemplary hardware architecture of the electrical device in the embodiments of this application.
[0159] The electrical device 1000 may include a processor 1001 and a memory 1002 storing computer program instructions.
[0160] Specifically, the processor 1001 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0161] Memory 1002 may include mass storage for data or instructions. For example, and not limitingly, memory 1002 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 1002 may include removable or non-removable (or fixed) media. Where appropriate, memory 1002 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 1002 is non-volatile solid-state memory. In a particular embodiment, memory 1002 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, typically, memory 1002 includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.
[0162] The processor 1001 implements any of the task processing methods described in the above embodiments by reading and executing computer program instructions stored in the memory 1002.
[0163] In one example, the electrical device may also include a communication interface 1003 and a bus 1004. Wherein, for example... Figure 10 As shown, the processor 1001, memory 1002, and communication interface 1003 are connected through bus 1004 and complete communication with each other.
[0164] The communication interface 1003 is mainly used to realize communication between various modules, devices and / or equipment in the embodiments of this application.
[0165] Bus 1004 includes hardware, software, or both, that couples components of an electrically powered device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 1004 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0166] The electrical device can execute the task processing method of any of the embodiments in this application and has the beneficial effects of the above-described task processing method embodiments, which will not be described in detail here.
[0167] Furthermore, in conjunction with the task processing methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the task processing methods in the above embodiments.
[0168] This application also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above method embodiments and achieve the same technical effect. To reduce repetition, it will not be described again here.
[0169] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0170] This application provides a computer program product stored in a readable storage medium. When executed by at least one processor, the program product can implement the various processes of the above-described task processing method embodiments and achieve the same technical effects. To reduce repetition, further details are omitted here.
[0171] 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.
[0172] The functional blocks shown in the above-described structural 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, ROM, flash memory, erasable ROM (EROM), floppy disks, 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.
[0173] 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.
[0174] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations 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 produce 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 flowchart illustrations 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.
[0175] 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 task processing method for a battery management system, characterized in that, include: Obtain the expected execution time and actual execution time for the target task; Determine whether the target task has timed out based on the expected execution time and the actual execution time. If the target task times out and no other exceptions occur during task execution, the priority of the target task in acquiring processor resources is adjusted; the other exceptions are exceptions other than timeouts during task execution.
2. The method according to claim 1, characterized in that, After detecting whether the target task has timed out based on the expected execution time, the method further includes: If the target task times out and other abnormalities occur during task execution, the target task will be initialized or switched to the target backup task corresponding to the target task.
3. The method according to claim 1 or 2, characterized in that, Determining whether the target task has timed out based on the expected execution time and the actual execution time includes: The target execution progress of the target task is determined by pre-setting task nodes; If the target execution progress is greater than a preset progress threshold, a first execution time corresponding to the target execution progress is determined based on the target execution progress and the expected execution time. The target duration for the target task to complete the target execution progress is determined based on the actual execution duration. If the target duration exceeds the first execution duration, the target task is determined to have timed out.
4. The method according to claim 2, characterized in that, Switching the target task to the corresponding backup target task includes: The target archive file closest to the current time is obtained from multiple archive files corresponding to the target task; during the execution of the target task, an archive file is generated at preset intervals, and the archive file is used to save the task execution parameters of the target task at different times; Based on the task execution parameters saved in the target archive file, the target task is switched to the target backup task corresponding to the target task, so that the target backup task performs task execution based on the task execution parameters saved in the target archive file.
5. The method according to claim 4, characterized in that, Retrieve the target archive file that is closest to the current time, including: The target archive file is obtained from the shared database; wherein, after generating the archive file, the target task sends the archive file to the shared database; Alternatively, the target archive file can be obtained from the target backup task; wherein, after generating the archive file, the target task sends the archive file to the target backup task.
6. The method according to claim 5, characterized in that, Each time the target backup task receives an archive file sent by the target task, it will replace the archive file saved by the target backup task with the received archive file.
7. The method according to any one of claims 1 to 6, characterized in that, Adjusting the priority of the target task in acquiring processor resources includes: If the target task is a preset non-critical task, reduce the priority of the target task in acquiring processor resources; Alternatively, if the target task is not a preset non-critical task, the priority of the target task in acquiring processor resources may be increased.
8. The method according to claim 7, characterized in that, If the target task is not a preset non-critical task, the method further includes: Obtain related tasks that conflict with the target task in terms of processor resources; If the relevant task is not a preset critical task, reduce the priority of the relevant task in acquiring processor resources.
9. The method according to any one of claims 1 to 8, characterized in that, Obtaining the actual execution time corresponding to the target task includes: The actual execution time is obtained by recording the duration of the timer corresponding to the target task; wherein the timer starts counting when the target task begins execution and stops counting when the target task is completed.
10. The method according to any one of claims 1 to 9, characterized in that, Obtaining the actual execution time corresponding to the target task includes: When the target task begins execution, obtain the initial time of the battery management system where the target task is located; During the execution of the target task, the time of the battery management system is periodically acquired based on a preset cycle. Based on the periodically acquired battery management system time and the initial time, the actual execution time corresponding to the target task is obtained.
11. A battery management system, characterized in that, include: The information acquisition module obtains the expected execution time and the actual execution time of the target task. The processor determines whether the target task has timed out based on the expected execution time and the actual execution time; and if the target task times out but no other exceptions occur during task execution, it adjusts the priority of the target task in acquiring processor resources; the other exceptions are exceptions other than timeouts among the exceptions during task execution.
12. An electrical appliance, characterized in that, The device includes: the battery management system as described in claim 11.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement the task processing method as described in any one of claims 1-10.
14. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electrical device, the electrical device performs the task processing method as described in any one of claims 1-10.