Battery management system, task switching method, apparatus, and device

CN122830478APending Publication Date: 2026-09-29CONTEMPORARY AMPEREX TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510358785.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

而任务切换主要包括保存当前任务的上下文和恢复新任务的上下文等操作,这个过程会产生较大的开销,导致任务切换的效率较低,难以满足车辆电子系统对实时性的要求

Benefits of technology

[0056]第六方面,本申请实施例提供了一种计算机程序产品,计算机程序产品中的指令由电子设备的处理器执行时,使得电子设备执行第二方面或第三方面的任一项实施例中所示的任务切换方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122830478A_ABST
    Figure CN122830478A_ABST
Patent Text Reader

Abstract

The application discloses a battery management system, a task switching method and device and equipment, and belongs to the technical field of batteries. The battery management system comprises an operating system and a controller. The operating system sends a task switching instruction to the controller when it is determined that a first battery management task meets a task switching condition. The controller saves first context information of the first battery management task to a target position in response to the task switching instruction. The operating system sends a task recovery instruction to the controller when the saving of the first context information is completed. The controller recovers second context information of a second battery management task that is stored in advance according to a task identifier in response to the task recovery instruction, and executes the second battery management task according to the second context information. That is, the embodiment of the application uses a combination of software and hardware to perform specific saving and recovery operations by using hardware, so that the software overhead can be greatly reduced, and the task switching efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of battery technology, and in particular to a battery management system, task switching method, apparatus and device. Background Technology

[0002] A Battery Management System (BMS) is an indispensable part of a battery system. Through various tasks such as battery status monitoring, fault diagnosis, and equalization control, it controls and manages the battery system, ensuring its performance and safety.

[0003] In a multi-tasking scenario within a BMS (Battery Management System), task switching ensures that each task receives sufficient execution time, preventing any single task from consuming CPU resources for an extended period and thus improving CPU utilization. However, task switching primarily involves operations such as saving the context of the current task and restoring the context of the new task. This process incurs significant overhead, resulting in low efficiency and making it difficult to meet the real-time requirements of vehicle electronic systems. Summary of the Invention

[0004] This application provides a battery management system, a task switching method, an apparatus, and a device that can improve task switching efficiency.

[0005] In a first aspect, embodiments of this application provide a battery management system, including an operating system and a controller;

[0006] The operating system is used to send a task switching instruction to the controller when it is determined that the first battery management task meets the task switching conditions.

[0007] The controller is used to save the first context information of the first battery management task to the target location in response to a task switching command;

[0008] The operating system is also used to send a task recovery instruction to the controller after the first context information has been saved. The task recovery instruction includes the task identifier of the second battery management task.

[0009] The controller is also configured to, in response to a task recovery instruction, recover the second context information of a pre-stored second battery management task based on the task identifier, and execute the second battery management task based on the second context information.

[0010] In this embodiment, the battery management system includes an operating system and a controller. The operating system sends a task switching instruction to the controller when it determines that the first battery management task meets the task switching conditions. The controller, in response to the task switching instruction, saves the first context information of the first battery management task to a target location. The operating system, after the first context information is saved, sends a task recovery instruction to the controller, the task recovery instruction including a task identifier for the second battery management task. The controller, in response to the task recovery instruction, restores the pre-stored second context information of the second battery management task according to the task identifier, and executes the second battery management task according to the second context information. That is, this embodiment combines software (operating system) and hardware (controller) approaches, utilizing hardware to perform the specific save and restore operations, which can greatly reduce software overhead and improve task switching efficiency.

[0011] In some embodiments, the operating system is further configured to:

[0012] Obtain the task parameters for each battery management task in the battery management system;

[0013] Based on the task parameters of each battery management task, determine whether each battery management task meets the task switching conditions.

[0014] Therefore, by using the operating system to monitor the status of battery management tasks and triggering task switching instructions based on the task status, the controller performs specific context information saving and restoration operations. Through a combination of hardware and software, the goal of completing task switching in a short time is achieved, thus improving task switching efficiency.

[0015] In some embodiments, the task parameters include the execution duration of the battery management task, and the battery management task includes a first battery management task;

[0016] Operating system, specifically used for:

[0017] If the execution time of the first battery management task reaches the execution time threshold, it is determined that the first battery management task meets the task switching conditions.

[0018] In this embodiment, using the execution time of the battery management task as the criterion for task switching can improve the response speed and user experience of the battery management system. Moreover, since the task execution time is relatively short, the overhead of task switching can be reduced when switching tasks, thereby improving the stability and reliability of the battery management system.

[0019] In some embodiments, the operating system is further configured to:

[0020] Based on task priority, the second battery management task is determined from the task cache queue, which is used to store battery management tasks to be executed.

[0021] In this embodiment, determining the task switching target based on task priority can ensure that certain specific tasks are executed first, thereby improving the execution efficiency of specific tasks.

[0022] In some embodiments, the operating system is specifically used for:

[0023] The highest priority task in the task cache queue is designated as the second battery management task.

[0024] This embodiment prioritizes switching to the highest priority task, ensuring that critical tasks are executed first, improving their execution efficiency, and guaranteeing the stability and reliability of the battery management system.

[0025] In some embodiments, the operating system is further configured to:

[0026] The mapping relationship between the logical registers used to create the second battery management task and the physical registers of the controller;

[0027] The controller is also used for:

[0028] Based on the mapping relationship between the logical registers used by the second battery management task created by the operating system and the physical registers of the controller, the logical registers of the second battery management task are renamed to map the logical registers used by the second battery management task to the physical registers of the controller.

[0029] In this embodiment, the operating system sets up relevant register mapping relationships for the upcoming second battery management task. The controller renames the registers of the second battery management task according to the mapping relationship provided by the operating system, so that the logical registers of different tasks can point to different physical registers. This avoids direct read and write conflicts to registers during task switching and improves task switching efficiency.

[0030] In some embodiments, the second context information includes register values ​​of the second battery management task, and the register values ​​include at least one of the following: program counter value, general-purpose register value, and status register value;

[0031] The controller is specifically used for:

[0032] In response to the task resume command, the pre-stored register values ​​of the second battery management task are loaded into the corresponding registers of the controller.

[0033] By utilizing the controller's hardware to perform context information recovery operations, which only takes a few clock cycles, the context information recovery time can be greatly shortened, thus improving task switching efficiency.

[0034] In some embodiments, the operating system is further configured to:

[0035] A third battery management task is determined from the various battery management tasks of the battery management system. The third battery management task includes tasks whose impact on the battery management system is greater than a preset threshold.

[0036] Send a data lock request to the controller. The data lock request includes the region identifier of the memory region where the target task data of the third battery management task is located.

[0037] The controller is also used to lock the target task data in the corresponding memory region to the cache in response to a data locking request, based on the region identifier.

[0038] In this embodiment, the operating system can utilize the controller's data locking function to lock the data of critical tasks. This effectively prevents the data from being replaced by other tasks during task execution, thereby improving the execution efficiency of critical tasks and ensuring system stability and reliability. Furthermore, locking the data in a cache improves subsequent data retrieval efficiency, further enhancing the execution efficiency of critical tasks.

[0039] In some embodiments, the third battery management task includes a battery overcharge protection task;

[0040] Operating systems are also used for:

[0041] When performing a battery overcharge protection task, read the battery voltage from the cache;

[0042] If the battery voltage is greater than the corresponding voltage threshold, read the application that disconnects the charging circuit of the battery management system from the cache and execute the application.

[0043] The controller is also used for:

[0044] Disconnect the charging circuit.

[0045] In this embodiment, by locking the data in the cache, the data can be quickly read from the cache later, which improves the timeliness of task response. Moreover, the charging circuit can be quickly disconnected through the combination of hardware and software, avoiding battery overcharging and ensuring battery safety.

[0046] Secondly, embodiments of this application provide a task switching method, including:

[0047] If the task switching conditions for the first battery management task are met, a task switching command is sent to the controller so that the controller responds to the task switching command and saves the first context information of the first battery management task to the target location.

[0048] Once the first context information is saved, a task recovery instruction is sent to the controller so that the controller responds to the task recovery instruction, recovers the pre-stored second context information of the second battery management task according to the task identifier, and executes the second battery management task according to the second context information. The task recovery instruction includes the task identifier of the second battery management task.

[0049] Thirdly, embodiments of this application provide a task switching method, including:

[0050] In response to a task switching instruction, the first context information of the first battery management task is saved to the target location. The task switching instruction is sent by the operating system when it determines that the first battery management task meets the task switching conditions.

[0051] In response to a task recovery instruction, the pre-stored second context information of the second battery management task is recovered based on the task identifier of the second battery management task included in the task recovery instruction. The task recovery instruction is sent by the operating system after the first context information has been saved.

[0052] The second battery management task is executed based on the second context information.

[0053] Fourthly, embodiments of this application provide a battery device, including a battery and a battery management system as described in the first aspect.

[0054] Fifthly, embodiments of this application provide an electrical device including the battery device as described in the fourth aspect.

[0055] In a sixth aspect, this application provides a computer storage medium storing computer program instructions, which, when executed by a processor, implement the task switching method shown in any of the embodiments of the second or third aspect.

[0056] In a sixth aspect, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the task switching method shown in any of the embodiments of the second or third aspect.

[0057] 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

[0058] 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:

[0059] Figure 1 This application provides a schematic diagram of the structure of a battery management system according to some embodiments;

[0060] Figure 2 A schematic diagram illustrating the interaction between an operating system and a controller, provided for some embodiments of this application;

[0061] Figure 3 One of the flowcharts illustrating a task switching method provided in some embodiments of this application;

[0062] Figure 4 A second schematic flowchart illustrating a task switching method provided in some embodiments of this application;

[0063] Figure 5 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application. Detailed Implementation

[0064] 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.

[0065] 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.

[0066] 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.

[0067] 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.

[0068] 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. The term "multiple" refers to two or more (including two). In addition, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0069] 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.

[0070] 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.

[0071] 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.

[0072] 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.

[0073] 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, CDN (Content Delivery Network), and big data and artificial intelligence platforms, such as vehicle networking cloud, APP backend, etc.

[0074] In a multi-tasking scenario of BMS, task switching can effectively prevent a task from occupying CPU resources for a long time, thereby ensuring that each task can get a certain amount of execution time and improving CPU utilization.

[0075] During task switching, the saving of the current task context information and the restoration of the new task context information incur certain overhead, affecting the efficiency of task switching.

[0076] To address the aforementioned technical problems, embodiments of this application provide a battery management system, task switching method, apparatus, and device. By combining software (operating system) and hardware (controller), the software issues instructions and the hardware executes specific save and restore operations, which can greatly reduce software overhead and improve task switching efficiency.

[0077] The battery management system provided in this application will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0078] Figure 1 This is one of the structural schematic diagrams of a battery management system provided in some embodiments of this application. The battery management system can be applied to electric vehicles such as pure electric vehicles or plug-in hybrid electric vehicles, or it can be used as a stand-alone device or apparatus.

[0079] like Figure 1 As shown, the battery management system 100 may include an operating system 101 and a controller 102, and the operating system 101 and the controller 102 communicate with each other.

[0080] The operating system 101 is an operating system adapted to the battery management system 100 and can be used in conjunction with the conventional controller 102. For example, the operating system 101 may be an operating system improved based on the AUTSAR standard. The controller 102 may be a conventional microcontroller unit (MCU). In this embodiment, the interaction between the operating system 101 and the controller 102 can improve task switching efficiency and meet the real-time requirements of the vehicle's electronic systems.

[0081] The specific functions implemented by the operating system 101 and controller 102 are described below.

[0082] In this embodiment, the operating system 101 is used to send a task switching instruction to the controller 102 when it is determined that the first battery management task meets the task switching conditions.

[0083] The first battery management task here can be a battery management task in the battery management system 100, and there can be one or more first battery management tasks. For example, the first battery management task can be a battery management task that meets the task switching conditions and needs to be switched. That is, it is necessary to pause the execution of the first battery management task and switch to other battery management tasks for execution.

[0084] Task switching conditions can be flexibly set according to actual needs. For example, task switching conditions can be set based on the execution duration of battery management tasks. For instance, the task switching condition can be set to the maximum execution duration of a battery management task reaching a set duration. That is, if the execution duration of a currently executing battery management task reaches the set duration, the battery management task can be considered to meet the task switching condition. The set duration can be set to, for example, 5 milliseconds to ensure the real-time performance of the task. Of course, it can also be set to other durations; this embodiment does not specifically limit this. The maximum execution duration of different battery management tasks can be the same or different, and can be flexibly set according to needs.

[0085] For example, task switching conditions can be set based on the task load of the battery management task. For instance, this task switching condition can be set to the task load reaching a set load threshold. That is, if the task load of a currently executing battery management task reaches the set load threshold, the battery management task can be considered to meet the task switching condition.

[0086] For example, task switching conditions can also be set based on system events of the battery management system. These system events may include, but are not limited to, battery status change events and system load change events.

[0087] Among them, battery status change events indicate changes in battery status, such as when the battery level falls below a set threshold, requiring task switching. System load change events indicate changes in system load, such as when the system load increases, requiring task switching.

[0088] The task switching instruction is used to instruct the controller 102 to perform specific task switching operations. When performing task switching, the controller 102's hardware feature is used to perform specific task switching operations, which can reduce software overhead and enable tasks to switch to the execution state in the shortest possible time, thereby improving task switching efficiency, as well as the real-time performance and response speed of the battery management system 100.

[0089] For example, the task switching instruction may include, but is not limited to, the task identifier of the first battery management task, the context information of the first battery management task, and the instruction identifier. The context information of the first battery management task may include, for example, the register values ​​used by the first battery management task, and these register values ​​may include, but are not limited to, program counter values, general-purpose register values, and status register values.

[0090] The instruction identifier is used to indicate which operation the controller 102 needs to perform for task switching. For example, instruction identifier 1 indicates saving, instruction identifier 2 indicates restoring, and other identifiers can also be used. This embodiment does not make specific limitations.

[0091] The controller 102 is used to save the first context information of the first battery management task to the target location in response to a task switching command.

[0092] The first context information refers to the current context information of the first battery management task. The target location could be, for example, the memory storage area for the context information of the first battery management task; different battery management tasks use different memory storage areas for their context information. This memory can be shared memory to facilitate subsequent reading and writing of information.

[0093] For example, after the controller 102 receives the task switching instruction sent by the operating system 101, the hardware circuit inside the controller 102 will save all the relevant register values ​​of the first battery management task to the target location in memory within a few clock cycles, which significantly shortens the time for saving context information.

[0094] For example, the operating system 101 described above is also configured to send a task recovery instruction to the controller 102 when the first context information has been saved.

[0095] The task resumption instruction here is used to resume the execution of a battery management task other than the first battery management task, such as the second battery management task. The task resumption instruction may include the task identifier of the second battery management task. In some embodiments, the task resumption instruction may also include the context information and instruction identifier of the second battery management task.

[0096] For example, the operating system 101 may send a task recovery instruction to the controller 102 after a preset clock cycle of issuing the task switching instruction. The preset clock cycle can be determined according to the clock cycle required for the controller 102 to save the context information. For example, the controller 102 generally needs M clock cycles to save the context information. Then, the operating system 101 may continue to send the task recovery instruction to the controller 102 after M clock cycles of issuing the task switching instruction.

[0097] For example, after saving the context information of the first battery management task, the controller 102 may also return a notification message to the operating system 101. The notification message is used to indicate that the controller 102 has completed the saving of the context information. After receiving the notification message, the operating system 101 sends a task recovery instruction to the controller 102.

[0098] Accordingly, the controller 102 is also configured to, in response to a task recovery instruction, recover the second context information of the pre-stored second battery management task according to the task identifier, and execute the second battery management task according to the second context information.

[0099] The second context information is the context information of the second battery management task, which can be pre-stored in a designated area of ​​memory, such as the context information storage area of ​​the second battery management task.

[0100] For example, controller 102 can load the register values ​​of the second battery management task pre-stored in memory into the corresponding registers of controller 102. This process can also be completed in a very short time, typically requiring only a few clock cycles. For instance, controller 102 can load the values ​​of the programmable parameters of the second battery management task stored in memory into the programmable parameters of controller 102, thereby enabling controller 102 to continue execution from the point where the second battery management task last ended.

[0101] Taking the second battery management task as an example, which includes a battery charging current adjustment task, the controller 102 can continue to execute the code corresponding to the battery charging current adjustment task to adjust the battery charging current.

[0102] In some embodiments, the operating system 101 is further configured to obtain task parameters for each battery management task in the battery management system.

[0103] Based on the task parameters of each battery management task, determine whether each battery management task meets the task switching conditions.

[0104] The task parameters here can be parameters that characterize the battery management task. For example, task parameters can include, but are not limited to, the execution duration, waiting time, and task load of the battery management task. The execution duration and waiting time of the battery management task can be obtained through a timer, and the task load can be estimated based on the execution duration, idle time, and communication overhead of the battery management task, or it can be determined based on factors such as the complexity of the battery management task.

[0105] In this embodiment, the operating system 101 can monitor the task parameters of the battery management task in real time and determine whether the battery management task meets the switching conditions based on the monitoring results.

[0106] Therefore, by using the operating system to monitor the status of battery management tasks and triggering task switching instructions based on the task status, the controller performs specific context information saving and restoration operations. Through a combination of hardware and software, the goal of completing task switching in a short time is achieved, thus improving task switching efficiency.

[0107] Taking the execution duration of the battery management task as an example, and the battery management task including the first battery management task, the aforementioned operating system 101 is specifically used for:

[0108] If the execution time of the first battery management task reaches the execution time threshold, it is determined that the first battery management task meets the task switching conditions.

[0109] In this embodiment, using the execution time of the battery management task as the criterion for task switching can improve the response speed and user experience of the battery management system. Moreover, since the task execution time is relatively short, the overhead of task switching can be reduced when switching tasks, thereby improving the stability and reliability of the battery management system.

[0110] To determine the switching target, in some embodiments, the aforementioned operating system 101 is further configured to:

[0111] The second battery management task is determined from the task cache queue based on task priority.

[0112] The task cache queue is used to store battery management tasks to be executed. The task cache queue can be updated in real time. For example, if a battery management task is being executed, the task identifier of the battery management task can be removed from the task cache queue. If a battery management task is paused, the task identifier of the paused battery management task can be added to the task cache queue.

[0113] For example, the operating system 101 can select a task from the task cache queue as the switching target based on task priority. For instance, the battery management task with the highest priority can be selected as the second battery management task, or the battery management task with the lowest priority can be selected as the second battery management task. The specific switching strategy can be set according to requirements.

[0114] The priority of each battery management task can be preset or dynamically updated based on the task load, system load, task importance, urgency, etc.

[0115] In this embodiment, determining the task switching target based on task priority can ensure that specific tasks are executed first, thereby improving the execution efficiency of specific tasks.

[0116] In some embodiments, the operating system 101 is specifically used for:

[0117] The highest priority task in the task cache queue is designated as the second battery management task.

[0118] Understandably, tasks that are more important or urgent to the battery management system generally have higher priority. For example, tasks directly related to battery safety, such as overcharge and over-discharge protection, thermal runaway warning, and temperature warning, typically have high priority. This embodiment prioritizes switching to the highest priority task, ensuring that critical tasks are executed first, improving their efficiency, and guaranteeing the stability and reliability of the battery management system.

[0119] In order to avoid direct read / write conflicts to registers during task switching, in some embodiments, the operating system 101 is also used to create a mapping relationship between the logical registers used by the second battery management task and the physical registers of the controller 102.

[0120] Accordingly, controller 102 is also used for:

[0121] Based on the mapping relationship between the logical registers used by the second battery management task created by the operating system 101 and the physical registers of the controller 102, the logical registers of the second battery management task are renamed so as to map the logical registers used by the second battery management task to the physical registers of the controller 102.

[0122] Logical registers are the register numbers that a task can directly use in instructions. Each task has its own logical registers, such as R0-R15. Physical registers are the actual registers inside the controller 102. When a task needs to be executed, its logical registers need to be mapped to the currently available physical registers. For example, assuming task B uses logical register R1, according to the mapping table, the physical register corresponding to logical register R1 is determined to be P5. Then, the operation on R1 in the instruction is actually an operation on P5.

[0123] The aforementioned mapping table can be established and updated by the operating system 101. For example, in this embodiment, the operating system 101 can establish a mapping relationship between the logical registers used by the second battery management task and the physical registers of the controller 102. In subsequent applications, only the mapping table needs to be updated to allow the character to access different physical registers without actually moving data, thus reducing overhead and improving switching efficiency.

[0124] For example, the operating system 101 can store the mapping relationship in a specified location in memory, such as a specified location in shared memory. Subsequently, the controller 102 can directly read the mapping relationship from the shared memory, providing a basis for the recovery of context information.

[0125] For example, the operating system 101 may also send the association directly to the controller 102.

[0126] According to the mapping relationship provided by the operating system 101, the controller 102 can rename the logical registers of the second battery management task to map the logical registers used by the second battery management task to the physical registers of the controller 102.

[0127] In this embodiment, the operating system sets up relevant register mapping relationships for the upcoming second battery management task. The controller renames the registers of the second battery management task according to the mapping relationship provided by the operating system, so that the logical registers of different tasks can point to different physical registers. This avoids direct read and write conflicts to registers during task switching and improves task switching efficiency.

[0128] Taking the second context information as including the register values ​​of the second battery management task, where the register values ​​include at least one of the following: program counter value, general-purpose register value, and status register value, in order to restore the context information of the second battery management task, in some embodiments, the controller 102 is specifically used for:

[0129] In response to the task resume command, the pre-stored register values ​​of the second battery management task are loaded into the corresponding registers of the controller.

[0130] By utilizing the hardware of controller 102 to perform the context information recovery operation, which only takes a few clock cycles, the context information recovery time can be greatly shortened, thus improving task switching efficiency.

[0131] During the aforementioned task switching process, the operating system 101 is primarily responsible for monitoring the task execution status and triggering task switching instructions. The controller 102, under the instructions of the operating system 101, utilizes its fast context switching mechanism and register renaming features to quickly and efficiently complete the actual context saving and restoration. This close cooperation between hardware and software enables task switching to be completed in an extremely short time, improving the real-time performance and response speed of the BMS system. For example, the entire process of switching from task A to task B may only take tens to hundreds of nanoseconds, ensuring that the system can respond promptly to changes in battery status and guaranteeing the safe and efficient operation of the battery.

[0132] To improve the efficiency of critical task execution, in some embodiments, the operating system 101 described above is further used for:

[0133] A third battery management task is determined from the various battery management tasks of the battery management system 100. The third battery management task includes tasks whose impact on the battery management system is greater than a preset threshold.

[0134] Send a data lock request to controller 102. The data lock request includes the region identifier of the memory region where the target task data of the third battery management task is located.

[0135] Accordingly, the controller 102 is also configured to lock the target task data in the corresponding memory region to the cache in response to a data locking request, based on the region identifier.

[0136] For example, the greater the impact of a battery management task on the battery management system 100, the more important the battery management task is. The impact of a battery management task on the battery management system 100 can be determined empirically or based on a machine learning model such as the XGBoost model.

[0137] For example, battery management tasks with an impact exceeding a preset threshold can be designated as third battery management tasks. The preset threshold can be set based on experience, requirements, etc. For example, third battery management tasks may include, but are not limited to, battery overcharge and over-discharge protection tasks, battery thermal runaway warning and handling tasks, BMS relay control tasks, collision detection tasks, and temperature warning tasks when the battery temperature approaches an abnormal threshold.

[0138] The data lock request is used to request controller 102 to lock relevant data for the third battery management task. Data locking effectively prevents data from being replaced by other tasks during task execution, thereby improving data hit rate and ensuring timely task response.

[0139] For example, the data locking request may include, but is not limited to, the region identifier of the memory region where the target task data of the third battery management task is located, the task identifier of the third battery management task, etc.

[0140] In this embodiment, for example, the operating system 101 can determine the critical tasks during task initialization and send a data lock request to the controller 102.

[0141] For example, before sending a data lock request to the controller 102, the operating system 101 may also mark the memory area where the data of the third battery management task is located. The mark can indicate that the content in the memory area can be locked. By marking the memory area, the controller 102 can quickly find the content that needs to be locked, improve the data locking efficiency, and thus improve the stability and reliability of the system.

[0142] For example, in addition to marking memory regions, the operating system 101 can also mark data within those memory regions that needs to be locked. The specific marking method is not limited in this embodiment; for example, the memory region containing the data can be marked using colors, identifiers, or other methods. The marking method for memory regions corresponding to different tasks can be different.

[0143] The target task data can be some or all of the data related to the third battery management task. For example, in some embodiments, the target task data can be the more important data in the third battery management task, which can save the memory occupied by the locked data.

[0144] Taking the third battery management task, which includes battery overcharge protection, as an example, the battery overcharge protection task is designed to prevent battery damage due to excessive voltage during charging. Executing the battery overcharge protection task ensures battery safety and extends battery life. For example, the target of the battery overcharge protection task can be a single battery cell or a battery pack containing multiple battery cells. That is, this embodiment can provide overcharge protection for both individual battery cells and the entire battery pack.

[0145] The data involved in the battery overcharge protection task mainly includes battery voltage, overcharge protection threshold, battery temperature, and other data.

[0146] In the case where the third battery management task includes a battery overcharge protection task, the target task data may include, for example, the code segment used in the battery overcharge protection task for real-time reading of battery voltage data and the corresponding voltage threshold.

[0147] Taking the third battery management task, which includes thermal runaway early warning and handling, as an example, this task involves monitoring data such as battery temperature, internal resistance, voltage, and current to identify potential thermal runaway risks in advance and issue an early warning signal before thermal runaway occurs, thereby avoiding or mitigating the harm caused by thermal runaway. Similarly, the object of the thermal runaway early warning and handling task can be a single battery cell or a battery pack containing multiple battery cells. That is, this embodiment can perform thermal runaway early warning and handling on both individual battery cells and battery packs.

[0148] The data involved in thermal runaway early warning and handling tasks may include battery temperature, voltage, current, thermal runaway early warning threshold, etc.

[0149] In cases where the third battery management task includes thermal runaway warning and handling tasks, the target task data may include, for example, code segments used to read temperature data, temperature thresholds, and code segments for controlling the cooling system in the thermal runaway warning task.

[0150] After receiving a data lock request from the operating system 101, the controller 102 can load specified data within a region into a cache based on the region identifier and lock this specified data. This cache can be, for example, an L1 cache or an L2 cache. The L1 cache is also called the first-level cache, and the L2 cache is also called the second-level cache; the L1 cache is faster than the L2 cache. By locking data in the cache, subsequent read efficiency can be improved, thereby improving the execution efficiency of critical tasks.

[0151] In this embodiment, the operating system can utilize the controller's data locking function to lock the data of critical tasks. This effectively prevents the data from being replaced by other tasks during task execution, thereby improving the execution efficiency of critical tasks and ensuring system stability and reliability. Furthermore, locking the data in a cache improves subsequent data retrieval efficiency, further enhancing the execution efficiency of critical tasks.

[0152] Taking the third battery management task as an example, which includes battery overcharge protection, the operating system 101 described above is also configured to:

[0153] When performing a battery overcharge protection task, read the battery voltage from the cache;

[0154] If the battery voltage is greater than the corresponding voltage threshold, read the application that disconnects the charging circuit of the battery management system from the cache and execute the application.

[0155] Accordingly, the controller 102 described above is also used for:

[0156] Disconnect the charging circuit.

[0157] Executing a task requires the cooperation of both software and hardware. For example, in this embodiment, the operating system 101 and the controller 102 need to work together. Since the controller 102 locks the data for the battery overcharge protection task, the operating system 101 needs to read data from the cache. This read operation can be completed in a short time. For example, the operating system 101 can retrieve the data from the cache within one clock cycle, which significantly improves the task's execution efficiency compared to reading from the slower main memory.

[0158] For example, for a battery overcharge protection task, the operating system 101 can quickly read the battery voltage and the corresponding voltage threshold from the cache and compare the battery voltage with the voltage threshold. When the battery voltage is greater than the corresponding voltage threshold, the operating system 101 can quickly read the application that disconnects the charging circuit of the battery management system from the cache and execute the application. That is, once the battery voltage is found to exceed the voltage threshold, the operating system 101 can immediately execute the application that switches the charging circuit without delay due to cache misses or other issues.

[0159] Correspondingly, when the controller 102 performs the operation of disconnecting the charging circuit, its pipeline will not stop due to waiting for data, thereby ensuring timely response and promptly preventing the charging circuit from continuing to charge the battery, thus ensuring the safety of the system.

[0160] In this embodiment, by locking the data in the cache, the data can be quickly read from the cache later, which improves the timeliness of task response. Moreover, the charging circuit can be quickly disconnected through the combination of hardware and software, avoiding battery overcharging and ensuring battery safety.

[0161] Similarly, for thermal runaway early warning and handling tasks, the operating system 101 can read temperature data and the corresponding temperature threshold from the cache, and compare the temperature data with the temperature threshold. If the temperature data is greater than the temperature threshold, the operating system 101 immediately executes the code related to cooling measures, and the corresponding controller 102 can immediately perform the cooling operation, ensuring the timeliness of the response.

[0162] The following is through Figure 2 The interaction process between the operating system 101 and the controller 102 is described.

[0163] S1. When the operating system 101 determines that the first battery management task meets the task switching conditions, it sends a task switching instruction to the controller 102.

[0164] S2, In response to the task switching command, the controller 102 saves the first context information of the first battery management task to the target location.

[0165] S3. The operating system 101 creates a mapping relationship between the logical registers used by the second battery management task and the physical registers of the controller, and sends the mapping relationship to the controller 102. Figure 2 Taking the example of the operating system 101 directly sending the mapping relationship to the controller 102.

[0166] S4. The controller 102 renames the registers of the second battery management task according to the mapping relationship provided by the operating system 101.

[0167] S5, the operating system 101 sends a task recovery command to the controller 102.

[0168] S6. In response to the task recovery instruction, the controller 102 loads the context information of the second battery management task stored in memory into the corresponding register.

[0169] S7. Operating system 101 sends a data lock request to controller 102.

[0170] S8, Controller 102 responds to the data locking request and locks the target task data in the corresponding memory region to the cache according to the region identifier.

[0171] Based on the same inventive concept, this application also provides a task switching method, which can be applied to the operating system in the above embodiments. The following, in conjunction with... Figure 3 The task switching method provided in the embodiments of this application will be described.

[0172] Figure 3 A flowchart of a task switching method according to an embodiment of this application is shown. This task switching method can be applied to the operating system in the above embodiment.

[0173] like Figure 3 As shown, the task switching method may include the following S310-S320.

[0174] S310. If it is determined that the first battery management task meets the task switching conditions, a task switching command is sent to the controller so that the controller responds to the task switching command and saves the first context information of the first battery management task to the target location.

[0175] S320: After the first context information is saved, a task recovery instruction is sent to the controller so that the controller responds to the task recovery instruction, recovers the second context information of the pre-stored second battery management task according to the task identifier, and executes the second battery management task according to the second context information.

[0176] The task recovery instruction includes the task identifier of the second battery management task.

[0177] In some embodiments, the task switching method further includes:

[0178] Obtain the task parameters for each battery management task in the battery management system;

[0179] Based on the task parameters of each battery management task, determine whether each battery management task meets the task switching conditions.

[0180] In some embodiments, the task parameters include the execution duration of the battery management task, and the battery management task includes a first battery management task;

[0181] Based on the task parameters of each battery management task, determine whether each battery management task meets the task switching conditions, including:

[0182] If the execution time of the first battery management task reaches the execution time threshold, it is determined that the first battery management task meets the task switching conditions.

[0183] In some embodiments, the task switching method further includes:

[0184] Based on task priority, the second battery management task is determined from the task cache queue, which is used to store battery management tasks to be executed.

[0185] In some embodiments, determining a second battery management task from a task cache queue based on task priority includes:

[0186] The highest priority task in the task cache queue is designated as the second battery management task.

[0187] In some embodiments, the task switching method further includes:

[0188] The mapping relationship between the logical registers used to create the second battery management task and the physical registers of the controller.

[0189] In some embodiments, the task switching method further includes:

[0190] A third battery management task is determined from the various battery management tasks of the battery management system. The third battery management task includes tasks whose impact on the battery management system is greater than a preset threshold.

[0191] Send a data lock request to the controller to request the controller to lock the target task data in the corresponding memory area. The data lock request includes the area identifier of the memory area where the target task data of the third battery management task is located.

[0192] In some embodiments, the task switching method further includes:

[0193] When performing a battery overcharge protection task, read the battery voltage from the cache;

[0194] If the battery voltage is greater than the corresponding voltage threshold, the application that disconnects the charging circuit of the battery management system is read from the cache and executed.

[0195] For specific details, please refer to the above embodiments. For the sake of brevity, they will not be repeated here.

[0196] Based on the same inventive concept, this application also provides a task switching method, which can be applied to the controller in the above embodiments. The following, in conjunction with... Figure 4 The task switching method provided in the embodiments of this application will be described.

[0197] Figure 4 A flowchart of a task switching method according to an embodiment of this application is shown. This task switching method can be applied to the controller in the above embodiment.

[0198] like Figure 4 As shown, the task switching method may include the following S410-S430.

[0199] S410, in response to the task switching command, save the first context information of the first battery management task to the target location.

[0200] The task switching instruction is sent by the operating system after determining that the first battery management task meets the task switching conditions.

[0201] S420, In response to the task recovery instruction, restore the pre-stored second context information of the second battery management task according to the task identifier of the second battery management task included in the task recovery instruction.

[0202] The task recovery instruction is sent by the operating system after the first context information has been saved.

[0203] S430, Execute the second battery management task based on the second context information.

[0204] In some embodiments, the task switching method further includes:

[0205] Based on the mapping relationship between the logical registers used by the second battery management task and the physical registers of the controller, the logical registers of the second battery management task are renamed to map the logical registers used by the second battery management task to the physical registers of the controller. This mapping relationship is created by the operating system.

[0206] In some embodiments, in response to a task recovery instruction, pre-stored second context information of the second battery management task is recovered based on the task identifier of the second battery management task included in the task recovery instruction, including:

[0207] In response to the task resume command, the pre-stored register values ​​of the second battery management task are loaded into the corresponding registers of the controller.

[0208] In some embodiments, the task switching method further includes:

[0209] In response to a data locking request, the target task data in the corresponding memory region is locked to the cache based on the region identifier.

[0210] In some embodiments, the task switching method further includes:

[0211] Disconnect the charging circuit.

[0212] For specific details, please refer to the above embodiments. For the sake of brevity, they will not be repeated here.

[0213] Based on the same inventive concept, embodiments of this application also provide a battery device, including a battery and a battery management system as described in the above embodiments.

[0214] Based on the same inventive concept, this application also provides an electrical device, including the battery device as described in the above embodiments.

[0215] Figure 5 A schematic diagram of the structure of an electronic device provided in one embodiment of this application is shown.

[0216] like Figure 5 As shown, the electronic device 500 is capable of implementing an exemplary hardware architecture structure of the task switching method according to the embodiments of this application. This electronic device may refer to the electronic device in the embodiments of this application.

[0217] The electronic device 500 may include a processor 501 and a memory 502 storing computer program instructions.

[0218] Specifically, the processor 501 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.

[0219] Memory 502 may include mass storage for data or instructions. For example, and not limitingly, memory 502 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 502 may include removable or non-removable (or fixed) media. Where appropriate, memory 502 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 502 is non-volatile solid-state memory. In a particular embodiment, memory 502 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. Thus, generally, memory 502 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.

[0220] The processor 501 implements any of the task switching methods described in the above embodiments by reading and executing computer program instructions stored in the memory 502.

[0221] In one example, the electronic device 500 may also include a communication interface 503 and a bus 504. Wherein, as... Figure 5 As shown, the processor 501, memory 502, and communication interface 503 are connected through bus 504 and complete communication with each other.

[0222] The communication interface 503 is mainly used to realize communication between various modules, devices, apparatuses and / or equipment in the embodiments of this application.

[0223] Bus 504 includes hardware, software, or both, that couples components of electronic device 500 together. For example, and not limitingly, the bus may include Accelerated Graphics Port (AGP) or other graphics buses, Enhanced Industry Standard Architecture (EISA) buses, Front Side Bus (FSB), HyperTransport (HT) interconnects, Industry Standard Architecture (ISA) buses, Infinite Bandwidth Interconnects, Low Pin Count (LPC) buses, memory buses, Microchannel Architecture (MCA) buses, Peripheral Component Interconnect (PCI) buses, PCI-Express (PCI-X) buses, Serial Advanced Technology Attachment (SATA) buses, Video Electronics Standards Association Local (VLB) buses, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 504 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.

[0224] The electronic device can execute the task switching method of any of the embodiments in this application.

[0225] Furthermore, in conjunction with the task switching methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the task switching methods in the above embodiments.

[0226] 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 avoid repetition, it will not be described again here.

[0227] 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.

[0228] 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 method embodiments and achieve the same technical effects. To avoid repetition, it will not be described again here.

[0229] 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.

[0230] 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.

[0231] 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.

[0232] 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.

[0233] 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 battery management system, characterized in that, Including the operating system and controller; The operating system is used to send a task switching instruction to the controller when it is determined that the first battery management task meets the task switching conditions. The controller is configured to, in response to the task switching instruction, save the first context information of the first battery management task to the target location; The operating system is further configured to send a task recovery instruction to the controller after the first context information has been saved, the task recovery instruction including the task identifier of the second battery management task; The controller is further configured to, in response to the task recovery instruction, recover the pre-stored second context information of the second battery management task according to the task identifier, and execute the second battery management task according to the second context information.

2. The battery management system according to claim 1, characterized in that, The operating system is also used for: Obtain the task parameters of each battery management task in the battery management system; Based on the task parameters of each battery management task, determine whether each battery management task meets the task switching conditions.

3. The battery management system according to claim 2, characterized in that, The task parameters include the execution duration of the battery management task, and the battery management task includes the first battery management task; The operating system is specifically used for: If the execution time of the first battery management task reaches the execution time threshold, it is determined that the first battery management task meets the task switching condition.

4. The battery management system according to any one of claims 1-3, characterized in that, The operating system is also used for: The second battery management task is determined from the task cache queue based on the task priority, the task cache queue being used to store battery management tasks to be executed.

5. The battery management system according to claim 4, characterized in that, The operating system is specifically used for: The task with the highest priority in the task cache queue is identified as the second battery management task.

6. The battery management system according to any one of claims 1-5, characterized in that, The operating system is also used for: Create the mapping relationship between the logical registers used by the second battery management task and the physical registers of the controller; The controller is also used for: Based on the mapping relationship between the logical registers used by the second battery management task created by the operating system and the physical registers of the controller, the logical registers of the second battery management task are renamed to map the logical registers used by the second battery management task to the physical registers of the controller.

7. The battery management system according to any one of claims 1-6, characterized in that, The second context information includes register values ​​of the second battery management task, wherein the register values ​​include at least one of the following: program counter value, general-purpose register value, and status register value; The controller is specifically used for: In response to the task recovery command, the pre-stored register value of the second battery management task is loaded into the corresponding register of the controller.

8. The battery management system according to any one of claims 1-7, characterized in that, The operating system is also used for: A third battery management task is determined from the battery management tasks of the battery management system. The third battery management task includes tasks whose impact on the battery management system is greater than a preset threshold. Send a data lock request to the controller, the data lock request including the region identifier of the memory region where the target task data of the third battery management task is located; The controller is also configured to, in response to the data locking request, lock the target task data in the corresponding memory region to the cache according to the region identifier.

9. The battery management system according to claim 8, characterized in that, The third battery management task includes battery overcharge protection; The operating system is also used for: When performing the battery overcharge protection task, the battery voltage is read from the cache; If the battery voltage is greater than the corresponding voltage threshold, read the application that disconnects the charging circuit of the battery management system from the cache and execute the application. The controller is also used for: Disconnect the charging circuit.

10. A task switching method, characterized in that, include: If it is determined that the first battery management task meets the task switching conditions, a task switching instruction is sent to the controller so that the controller responds to the task switching instruction and saves the first context information of the first battery management task to the target location. When the first context information is saved, a task recovery instruction is sent to the controller so that the controller responds to the task recovery instruction, recovers the second context information of the pre-stored second battery management task according to the task identifier, and executes the second battery management task according to the second context information. The task recovery instruction includes the task identifier of the second battery management task.

11. A task switching method, characterized in that, include: In response to a task switching instruction, the first context information of the first battery management task is saved to the target location. The task switching instruction is sent by the operating system when it determines that the first battery management task meets the task switching conditions. In response to a task recovery command, the pre-stored second context information of the second battery management task is recovered according to the task identifier of the second battery management task included in the task recovery command. The task recovery command is sent by the operating system after the first context information has been saved. The second battery management task is executed based on the second context information.

12. A battery device, characterized in that, Includes a battery and a battery management system as described in any one of claims 1-9.

13. An electrical appliance, characterized in that, Includes the battery device as described in claim 12.