Memory allocation method, device and system of battery management system, medium and product
By determining the memory area and allocation strategy according to the task type in the battery management system, the system instability problem caused by unreasonable memory allocation is solved, and more efficient and stable memory resource management is achieved.
Patent Information
- Application Number
- CN202510323434.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-03-19
AI Technical Summary
In a battery management system, unreasonable memory allocation will lead to over-boundary access to tasks or excessive dynamic memory allocation, reducing the stability and efficiency of system operation.
By responding to memory allocation requests, obtain the task type of the battery management task, and determine the corresponding memory area and allocation strategy based on the task type, prioritize allocating memory for static tasks, reducing the risk of memory overflow and system instability.
It improves the rationality of memory resource allocation, enhances the stability of system operation and battery management efficiency, and avoids memory waste and fragmentation.
Smart Images

Figure CN119847768A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of battery management systems, and in particular to a memory allocation method, device, system, medium and product of a battery management system. Background Art
[0002] When the application in the operating system corresponding to the battery management system executes tasks, it is necessary to allocate memory for the execution of battery management tasks. If the memory allocation is unreasonable, it will cause the task to access out of bounds, or the memory will be dynamically allocated all the time, which will reduce the stability of the system operation and thus affect the operating efficiency of the battery management system. Therefore, how to reasonably allocate system memory is of great significance to improving the operating stability of the system and thus improving the management efficiency of the battery. Summary of the invention
[0003] The present application provides a memory allocation method, device, system, medium and product for a battery management system, which can improve the rationality of memory resource allocation and thereby improve the stability of system operation.
[0004] In a first aspect, the present application provides a memory allocation method for a battery management system, the method comprising: in response to a memory allocation request, obtaining a task type of a battery management task; determining a second memory area corresponding to the task type of the battery management task from a first memory area of an operating system corresponding to the battery management system; and using a memory allocation strategy corresponding to the task type to allocate the second memory area to the battery management task; Among them, when there are multiple battery management tasks, for each battery management task, the memory allocation priority corresponding to the battery management task is determined according to the task type of the battery management task, wherein the memory allocation priority of the static task is higher than the memory allocation priority of the dynamic task; according to the order of the memory allocation priority of the battery management task from high to low, the second memory area is determined from the first memory area.
[0005] In an embodiment of the present application, the memory area required to be allocated to execute the task is determined according to the task type of the task, that is, the memory areas used by different types of tasks are different, thereby reducing the risk of memory overflow caused by all tasks accessing the same memory area, and also avoiding the problem of poor system stability caused by dynamic allocation of memory for all tasks. In addition, in an embodiment of the present application, the memory allocation area and the memory allocation strategy are determined according to the task type of the task, so that the allocated memory area can meet the execution requirements of the task, and at the same time will not cause the problem of memory waste. Compared with the related art that allocates memory resources according to the operation stage of the device, the rationality of memory resource allocation is improved, thereby improving the stability of system operation.
[0006] In addition, in an embodiment of the present application, the order in which memory is allocated to tasks is determined according to the priorities of the tasks, and memory is allocated preferentially to high-priority tasks to ensure the normal operation of higher-priority tasks, making the allocation of memory resources more reasonable, thereby improving the stability of system operation.
[0007] In some embodiments, obtaining the task type of the battery management task includes: obtaining a task identifier corresponding to the battery management task; and determining the task type of the battery management task according to the task identifier corresponding to the battery management task.
[0008] By setting the task ID to associate the task ID with the task type, when creating a task, if the task type needs to be adjusted, only the task ID needs to be adjusted without reconfiguring the task, thereby improving the efficiency of creating or configuring tasks. Moreover, when allocating memory resources to tasks, the task type can be accurately determined based on the task ID, and then memory can be accurately allocated to the task based on the task type, improving the rationality of task allocation.
[0009] In some embodiments, the task types include static tasks and dynamic tasks. Static tasks include tasks for implementing data processing functions, and dynamic tasks include tasks for implementing data collection functions.
[0010] Before allocating memory for the battery management task, the memory allocator determines the dynamic memory area or the static memory area as the second memory area according to the task type corresponding to the battery management task, so that during subsequent memory allocation, the memory resources in the second memory area are allocated to the battery management task to improve the rationality of memory allocation.
[0011] In some embodiments, the second memory area includes a memory area corresponding to a static task, and / or a memory area corresponding to a dynamic task, and the second memory area is determined from the first memory area according to the memory allocation priority of the battery management task from high to low, including: determining the static memory area in the first memory area as the memory area corresponding to the static task according to the memory allocation priority of the battery management task from high to low, wherein the static memory area is a memory area in the first memory area where the memory is greater than the minimum memory required to execute the static task; determining the dynamic memory area in the first memory area as the memory area corresponding to the dynamic task, wherein the dynamic memory area is the memory area remaining after allocating memory to the static task in the first memory area.
[0012] When allocating memory for battery management tasks, memory is allocated to static tasks first, and then to dynamic tasks. Static memory is allocated to more important static tasks first, so as to allocate sufficient memory intervals for the execution of important tasks and ensure the normal execution of important tasks.
[0013] In some embodiments, when the battery management task is a static task, a memory allocation strategy corresponding to the task type is adopted to allocate the second memory area to the battery management task, including: obtaining the minimum memory required to execute the static task from the task parameters of the battery management task; when a static memory area exists in the first memory area, obtaining the memory address corresponding to the static memory area, wherein the static memory area is a memory area in the first memory area whose memory is greater than the minimum memory; and allocating memory resources to the battery management task according to the memory address so that the battery management task accesses the static memory area.
[0014] Allocating memory for static memory according to the minimum memory required to execute static tasks can ensure the normal operation of static tasks, while also reducing the risk of wasting memory resources due to excessive memory allocation and improving the rationality of memory allocation.
[0015] In some embodiments, the memory allocation method of the battery management system also includes: obtaining memory usage data of the second memory area; generating a warning prompt message when the memory usage data meets preset conditions, wherein the preset conditions at least include that the memory usage rate of the second memory area is higher than a preset memory usage rate threshold.
[0016] When the memory usage rate of the second memory area approaches the critical value, an alarm will be issued to remind the staff to deal with the abnormality in time. It can also enable other systems to adopt optimization algorithms or suspend non-critical tasks to release memory resources for non-critical tasks to ensure the stable operation of the vehicle system.
[0017] In some embodiments, the memory allocation method of the battery management system also includes: when the memory usage data meets the preset conditions, obtaining the execution frequency of the battery management task; when the execution frequency of the battery management task is lower than the preset frequency threshold and the battery management task is in a stopped state, compressing the target data required to execute the battery management task to obtain compressed target data; when the battery management task is in an execution state, decompressing the compressed target data in the second memory area to obtain the target data.
[0018] Compressing the relevant data of tasks with low execution frequency can reduce the memory space occupied by the data; when the task needs to access the data, the data is decompressed to ensure the normal operation of the task.
[0019] In some embodiments, when the battery management task is a dynamic task, a memory allocation strategy corresponding to the task type is adopted to allocate memory resources in the second memory area to the battery management task, including: dividing the second memory area into multiple memory blocks; determining at least one target memory block from the multiple memory blocks based on the required memory of the battery management task, wherein the total memory corresponding to the at least one target memory block is greater than or equal to the required memory; and allocating the at least one target memory block to the battery management task.
[0020] By dividing the second memory area into multiple memory blocks to allocate memory for the dynamic task, not only can the normal execution of the dynamic task be preserved, but also memory fragmentation can be reduced, the waste of memory resources can be reduced, and the rationality of memory allocation can be improved.
[0021] In some embodiments, the memory allocation method of the battery management system further includes: when the battery management task is completed, releasing at least one target memory block so that other dynamic memories can continue to use the memory block, thereby improving the utilization of the memory space.
[0022] In the second aspect, the present application also provides a memory allocation device for a battery management system, which includes: a task acquisition module, used to obtain the task type of the battery management task in response to a memory allocation request; a memory determination module, used to determine a second memory area corresponding to the task type of the battery management task from the first memory area of the operating system; a memory allocation module, used to adopt a memory allocation strategy corresponding to the task type to allocate memory resources in the second memory area to the battery management task.
[0023] In a third aspect, the present application provides a battery management system, which includes: a task executor, used to create and execute battery management tasks; a memory, connected to the task executor, used to provide memory resources for the task executor to execute battery management tasks, wherein the memory includes a first memory area of an operating system corresponding to the battery management system; a memory allocator, connected to the task executor and the memory, used to determine a second memory area from the first memory area according to a task type of the battery management task, and adopt a memory allocation strategy corresponding to the task type to allocate the second memory area in the memory to the battery management task.
[0024] In a fourth aspect, the present application provides a readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the memory allocation method for the battery management system as described in the first aspect is implemented.
[0025] In a fifth aspect, the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the memory allocation method of the battery management system as described in the first aspect.
[0026] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The features, advantages and technical effects of exemplary embodiments of the present application will be described below with reference to the accompanying drawings.
[0028] Figure 1 A schematic diagram of the structure of a battery management system according to an embodiment of the present application; Figure 2 A flowchart of a memory allocation method for a battery management system according to an embodiment of the present application; Figure 3 A flowchart of a method for determining a task type of a battery management task according to an embodiment of the present application; Figure 4 A flowchart of a method for determining a second memory area according to an embodiment of the present application; Figure 5 This is a flowchart of a method for allocating memory resources under a static task according to an embodiment of the present application; Figure 6 A flow chart of a method for monitoring memory usage according to an embodiment of the present application; Figure 7 A flowchart of a memory adjustment method according to an embodiment of the present application; Figure 8 A flowchart of a method for allocating memory resources under a dynamic task according to an embodiment of the present application; Fig. 9 A schematic diagram of a memory allocation device of a battery management system according to another embodiment of the present application.
[0029] In the drawings, the drawings are not necessarily drawn to scale. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" in the specification and claims of this application and the above-mentioned figure descriptions and any variations thereof are intended to cover non-exclusive inclusions.
[0032] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0033] Mentioning "embodiment" in the embodiments of the present application means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiment described in the embodiments of the present application can be combined with other embodiments.
[0034] In the description of the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0035] Software-defined vehicles are a software-centric automotive architecture that can give vehicles intelligence, connectivity, and personalization by integrating the vehicle's hardware functions and software systems. Under the general trend of software-defined vehicles, the combination of chips, operating systems, middleware, application algorithm software, and data is the key to realizing vehicle intelligence. The operating system is the soul of the development of the vehicle ecosystem, and the AUTOSAR operating system is a commonly used operating system in vehicles.
[0036] In the related art, the AUTOSAR operating system usually uses static memory allocation to allocate memory for tasks in the vehicle's battery management system. This method can reduce the need for dynamic memory allocation, thereby improving the stability and predictability of the system. However, for the static memory allocation method, if the memory allocation is unreasonable, memory buffer overflow and out-of-bounds access problems will occur, thereby limiting the flexibility and scalability of the system. Although the dynamic memory allocation method can solve the problems of memory overflow and out-of-bounds access, frequent dynamic memory allocation will reduce the stability and predictability of the system.
[0037] In view of the problems existing in the related art, the embodiments of the present application provide a memory allocation method, device, system, medium and product for a battery management system. In the memory allocation method for a battery management system provided in the embodiments of the present application, a combination of dynamic memory partitioning and static reservation is used to implement memory allocation.
[0038] Specifically, the battery management system allocates memory for related tasks of the battery management system (for example, data collection tasks, data calculation tasks) using a memory allocation strategy that combines dynamic memory partitioning with static reservation based on the real-time memory requirements of applications (for example, applications for battery life evaluation, applications for battery status evaluation) and the memory resource usage of the operating system. For different types of tasks, different memory area allocations and different memory allocation strategies are used to allocate memory to improve the rationality of memory allocation, thereby improving the stability of system operation.
[0039] It should be noted that the battery management system (BMS) in this application is used to implement at least one of the following functions for battery cells: status monitoring, status analysis, charge and discharge control, safety protection, information management, thermal management, and high-voltage power distribution. In addition, the battery management system in this application can also implement the functions of the controller in the power-consuming device, such as the vehicle control unit (VCU), motor control unit (MCU), etc., and this application does not limit this.
[0040] It should be noted that the battery management system in the present application can be integrated into a battery device as a controller, such as a battery pack or an energy storage box; The battery management system in the present application can also be integrated into an electrical device as a controller, such as in a vehicle or a vehicle chassis; The battery management system in this application can also be integrated into a charging device as a controller, such as a charging device or a battery replacement device; The battery management system in this application can also be deployed in a server as control software. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms, such as Internet of Vehicles Cloud, APP background, etc.
[0041] In an embodiment of the present application, the battery management system can execute the memory allocation method of the battery management system provided in the embodiment of the present application. The battery management system is equipped with an on-board operating system, which is different from the AUTOSAR operating system. It can be used not only to realize static allocation of memory, but also to realize dynamic allocation of memory.
[0042] The following is an introduction to the memory allocation method of the battery management system provided in the embodiment of the present application in conjunction with the battery management system. The vehicle-mounted operating system runs in the vehicle, and it can interact with the task executor, memory, etc. in the BMS (Battery Management System) to perform memory allocation and memory management for the battery management tasks (e.g., battery safety monitoring tasks, emergency fault handling tasks, battery status estimation tasks, balancing control tasks, etc.) performed by the task executor.
[0043] In one embodiment, Figure 1 The schematic diagram of the battery management system is shown in FIG. Figure 1 As shown, the battery management system includes: a task executor 10 , a memory 20 and a memory allocator 30 .
[0044] In an embodiment of the present application, the task executor 10 can be used to create and execute a battery management task. The task executor 10 can be a control chip capable of creating and running a battery management task, which can be composed of a control unit, an arithmetic logic unit, a register, etc., to achieve task creation and execution.
[0045] The memory 20 may be connected to the task executor 10 to provide memory resources for the task executor 10 to perform battery management tasks.
[0046] In the embodiment of the present application, the storage space corresponding to the memory 20 is the first memory area of the operating system corresponding to the battery management system.
[0047] The memory allocator 30 is connected to the task executor 10 and the memory 20, and is used to determine the second memory area from the first memory area according to the task type of the battery management task, and adopt a memory allocation strategy corresponding to the task type to allocate the second memory area in the memory to the battery management task. The first memory area is the storage space corresponding to the memory 20, and the second memory area is a partial area in the first memory area.
[0048] In the embodiment of the present application, the memory allocator 30 may be any one of a buddy allocator and a slab allocator.
[0049] The following describes the method provided in the embodiment of the present application by taking the memory allocator in the battery management system as the execution entity.
[0050] In one embodiment, Figure 2 A flow chart of a memory allocation method for a battery management system is shown, Figure 2 As shown, the method may include the following steps S201 to S203: Step S201, in response to a memory allocation request, obtaining a task type of a battery management task.
[0051] In step S201, when the vehicle controller controls the BMS to execute a task, the task in the BMS can apply for memory from the vehicle operating system. After receiving the memory allocation request sent by the BMS, the memory allocator uses the method provided in the embodiment of the present application to allocate memory resources to the BMS.
[0052] In step S201, the memory allocation request may include task attribute information of the battery management task, wherein the task attribute information may include information such as the function to be implemented by the battery management task, the task type, the task identifier, and the task priority. The memory allocator can obtain the task type of the battery management task by parsing the memory allocation request. In an embodiment of the present application, the battery management task includes but is not limited to data acquisition tasks (e.g., data recording tasks), data processing tasks (e.g., floating-point calculation tasks, battery state estimation tasks, and battery balancing control tasks).
[0053] Step S202: determining a second memory area corresponding to the task type of the battery management task from a first memory area of the operating system corresponding to the battery management system.
[0054] In step S202, the first memory area is the memory space of the operating system, and the second memory area is a partial memory area in the memory space of the operating system. In the embodiment of the present application, for different types of tasks, the memory allocator allocates memory in different memory areas to tasks of corresponding types.
[0055] As an example, in an embodiment of the present application, the first memory area includes a static memory area and a dynamic memory area, wherein the dynamic memory area is used to provide memory resources for dynamic tasks such as data recording, while the static memory area is used to provide memory resources for static tasks, and the dynamic memory area is used to provide memory resources for dynamic tasks.
[0056] In one embodiment, task types include static tasks and dynamic tasks. Static tasks include tasks for implementing data processing functions (e.g., floating-point operation tasks), and dynamic tasks include tasks for implementing data acquisition functions (e.g., voltage acquisition tasks, current acquisition tasks, and temperature acquisition tasks).
[0057] In the embodiment of the present application, the dynamic memory area and the static memory area constitute the memory space of the operating system. Before allocating memory for the battery management task, the memory allocator determines the dynamic memory area or the static memory area as the second memory area according to the task type corresponding to the battery management task, so that in the subsequent memory allocation, the memory resources in the second memory area are allocated to the battery management task to improve the rationality of memory allocation.
[0058] Step S203: using a memory allocation strategy corresponding to the task type, allocating the second memory area to the battery management task.
[0059] In step S203, different types of tasks have corresponding memory allocation strategies. For example, for static tasks that implement functions such as data processing, a static memory allocation strategy can be adopted to allocate the minimum memory resources required to execute the task from the static memory area to the task; for dynamic tasks that implement functions such as data collection, a dynamic memory allocation strategy can be adopted to obtain memory resources from the dynamic memory area and release the memory resources after the task completes data collection.
[0060] It should be noted that, for traditional AUTOSAR operating systems, static allocation is usually used to allocate memory for tasks, which reduces the flexibility and scalability of the system. In the embodiment of the present application, memory resources are allocated to tasks according to the memory allocation strategy corresponding to the task type, which improves the flexibility of memory allocation and also reduces the problem of reduced system stability caused by frequent dynamic memory allocation.
[0061] Based on the scheme defined by the above steps S201 to S203, it can be known that in the embodiment of the present application, the memory area required to be allocated to execute the task is determined according to the task type of the task, that is, the memory areas used by different types of tasks are different, thereby reducing the risk of memory overflow caused by all tasks accessing the same memory area, and also avoiding the problem of poor system stability caused by dynamic allocation of memory for all tasks. In addition, in the embodiment of the present application, the memory allocation area and the memory allocation strategy are determined according to the task type of the task, so that the allocated memory area can meet the execution requirements of the task, and at the same time will not cause the problem of memory waste. Compared with the related art that allocates memory resources according to the operation stage of the device, the rationality of memory resource allocation is improved, thereby improving the stability of system operation.
[0062] The following is an introduction to the implementation process of the method provided in the embodiment of the present application.
[0063] In an embodiment of the present application, the memory allocator determines the memory area where the memory resource is located according to the task type of the battery management task. Prior to this, the task type of the battery management task needs to be determined. In one embodiment, the task type of the battery management task can be determined by Figure 3 The method shown is to determine, Figure 3 As shown, the process includes the following steps: Step S301, obtaining a task identifier corresponding to a battery management task; Step S302: determining the task type of the battery management task according to the task identifier corresponding to the battery management task.
[0064] In step S301, each battery management task has a corresponding task identifier, which can be set by the R&D personnel according to actual needs. In the embodiment of the present application, the task identifier is used to characterize the function corresponding to the battery management task. For example, task identifier 0001 indicates that the task can realize the collection of voltage data; task identifier 0002 indicates that the task can realize the collection of current data; task identifier 0003 indicates that the task can realize the operation of floating-point data.
[0065] In step S302, the memory allocator can determine the task type of the task according to the task identifier corresponding to the battery management task. For example, the memory allocator identifies tasks with task identifiers 0001 and 0002 as dynamic tasks, and identifies the task with task identifier 0003 as a static task.
[0066] Through step S301 to step S302, by setting the task identifier to associate the task identifier with the task type, when creating a task, if the task type needs to be adjusted, only the task identifier needs to be adjusted without reconfiguring the task, thereby improving the efficiency of creating or configuring tasks. Moreover, when allocating memory resources to a task, the task type can be accurately determined based on the task identifier, and then memory can be accurately allocated to the task based on the task type, thereby improving the rationality of task allocation.
[0067] Furthermore, after determining the task type of the battery management task, the memory allocator can determine the memory area according to the task type.
[0068] In one embodiment, when there are multiple battery management tasks, the memory allocator uses the following method: Figure 4 The method shown is used to determine the second memory area. Specifically, the process includes the following steps S401 to S402: Step S401 : for each battery management task, determine the memory allocation priority corresponding to the battery management task according to the task type of the battery management task.
[0069] In step S401, the memory allocation priority is used to characterize the allocation order of the battery management tasks. In the embodiment of the present application, memory is allocated preferentially to tasks with high memory allocation priority. Among them, the memory allocation priority of static tasks is higher than the memory allocation priority of dynamic tasks.
[0070] Step S402: determining a second memory area from the first memory area according to the memory allocation priorities of the battery management tasks from high to low.
[0071] It should be noted that, through step S401 to step S402, the order of allocating memory to tasks is determined according to the priorities of the tasks, and memory is allocated preferentially to tasks with high priorities to ensure the normal operation of tasks with higher priorities.
[0072] In step S402, the second memory area is determined in different ways according to the task type corresponding to the battery management memory.
[0073] In an embodiment of the present application, the memory allocator determines the static memory area in the first memory area as the memory area corresponding to the static task according to the memory allocation priority of the battery management task from high to low, wherein the static memory area is a memory area in the first memory area whose memory is greater than the minimum memory required to execute the static task; A dynamic memory area in the first memory area is determined as corresponding to the dynamic task, wherein the dynamic memory area is a memory area remaining after memory is allocated to the static task in the first memory area.
[0074] In the above embodiment, the second memory area includes a memory area corresponding to a static task and / or a memory area corresponding to a dynamic task.
[0075] That is, in the embodiment of the present application, when allocating memory for battery management tasks, memory is allocated to static tasks first, and then to dynamic tasks. Among them, static tasks are usually more important tasks such as data processing, while dynamic tasks are usually more frequent tasks such as data collection. For static tasks, taking floating-point arithmetic tasks as an example, static memory is allocated to floating-point arithmetic tasks first, so that sufficient memory intervals are allocated for the execution of important tasks to ensure the normal execution of important tasks.
[0076] In one example, during the program compilation phase, the compiler in the memory allocator pre-configures the static memory size corresponding to different tasks based on the variable declarations, data structure definitions, and static memory requirements in the program code. Then, based on the functions of different tasks and the required static memory size, the compiler determines whether the task needs to dynamically allocate memory based on the task configuration code bit TaskType. After the BMS system is started, when creating a task, the memory allocator starts searching from the head of the free partition chain or table in the operating system's memory space based on the task's configuration information until a free partition of a size that meets the requirements is found. Then, a portion of the partition is allocated to the task, and the remaining free partitions remain in the chain for subsequent dynamic memory allocation for other tasks.
[0077] In addition, in the embodiment of the present application, after static memory is allocated to a static task, during the execution of the static task, the corresponding memory resources can be dynamically adjusted according to the execution of the static task. For example, for a floating-point operation task, it usually involves the processing of a large amount of data, the size and quantity of which may not be fully determined when the program is written. Therefore, in order to manage memory more effectively and avoid unnecessary memory waste or shortage, during the execution of the floating-point operation task, if the static memory is insufficient, dynamic memory can be allocated to it.
[0078] The following introduces the memory allocation process for static tasks and dynamic tasks respectively.
[0079] When the battery management task is a static task, the memory allocator uses Figure 5 The method shown allocates memory resources in the second memory area to the battery management task. Specifically, Figure 5 As shown, the method includes the following steps S501 to S503: Step S501, obtaining the minimum memory required for executing the static task from the task parameters of the battery management task.
[0080] In step S501, the task parameters of the battery management task may include but are not limited to task type, task identifier, minimum memory required to execute the task, task function and other information.
[0081] Step S502: when there is a static memory area in the first memory area, obtain a memory address corresponding to the static memory area.
[0082] In step S502, the static memory area is a memory area in the first memory area where the memory is greater than the minimum memory.
[0083] Step S503, allocating memory resources to the battery management task according to the memory address, so that the battery management task can access the static memory area.
[0084] In one example, taking the static task as a floating-point operation task, the memory allocator first determines the minimum static memory required to execute the floating-point operation task based on the task parameters of the floating-point operation task. For example, the minimum static memory can be the minimum memory required for the normal operation of the floating-point operation task, which is the basis for ensuring the normal operation of the floating-point operation task. Then, the memory allocator performs a memory status check to find a continuous memory area that is large enough from the first memory area to meet the execution of the floating-point operation task. After finding the memory area that meets the requirements of the floating-point operation task, the memory address corresponding to the memory area is obtained, and the memory address is marked to indicate that the memory area has been allocated, and then the memory address is returned to the floating-point operation task, so that the floating-point operation task can use the memory area.
[0085] Through steps S501 to S503, memory is allocated to the static memory according to the minimum memory required to execute the static task, which can ensure the normal operation of the static task, while also reducing the risk of wasting memory resources due to excessive memory allocation and improving the rationality of memory allocation.
[0086] Furthermore, in order to ensure the normal execution of the static task, the memory allocator also monitors the memory usage of the second memory area during the execution of the static task. Figure 6 As shown, the memory monitoring process of the second memory area includes the following steps S601 to S602: Step S601, the memory allocator obtains memory usage data of the second memory area; Step S602: when the memory usage data meets a preset condition, generate a warning prompt message.
[0087] In step S601, the memory usage data may include but is not limited to memory usage rate, memory usage amount, remaining memory amount, etc. In the embodiment of the present application, the memory usage rate is taken as an example for introduction.
[0088] In one example, the memory allocator monitors the memory resource usage status of tasks using the memory resources of the second memory area in real time, counts the total memory usage of all tasks using the memory resources of the second memory area, and calculates the total memory usage and the total memory of the second memory area to obtain the memory utilization rate of the second memory area.
[0089] In step S602, the preset condition at least includes that the memory usage rate of the second memory area is higher than the preset memory usage rate threshold. The memory usage rate threshold can be determined based on the historical memory usage of the second memory area. For example, under historical working conditions, when the memory usage rate of the second memory area reaches the first memory usage rate, if other tasks apply for memory resources, it will cause the second memory area to overflow, and the first memory usage rate can be determined as the memory usage rate threshold.
[0090] In addition, in step S602, the early warning prompt information may include sound, electricity, light and other prompt information, and may also include the value corresponding to the code field representing the memory abnormality.
[0091] It should be noted that, through steps S601 to S602, when the memory usage rate of the second memory area approaches the critical value, an alarm is issued to remind the staff to deal with the abnormality in time, and other systems can also adopt optimization algorithms or suspend non-critical tasks to release memory resources for non-critical tasks to ensure the stable operation of the vehicle system.
[0092] In one embodiment, when the memory usage data meets the preset conditions, the memory allocator can also Figure 7 The memory adjustment method shown is used to adjust the memory of the second region memory area. Specifically, Figure 7 As shown, the method includes the following steps S701 to S703: Step S701, when the memory usage data meets a preset condition, obtaining the execution frequency of the battery management task.
[0093] In step S701, the execution frequency of the battery management task can be obtained by counting the preset duration memory, the total number of tasks using the second memory area, and counting the number of occurrences of the task identifier corresponding to each task. By calculating the ratio of the number of occurrences of the task identifier to the total number of tasks, the execution frequency of the task corresponding to each task identifier can be obtained.
[0094] Step S702: When the execution frequency of the battery management task is lower than a preset frequency threshold and the battery management task is in a stopped state, compress the target data required for executing the battery management task to obtain compressed target data.
[0095] In step S702 , the frequency threshold may be determined according to the task type, and each task type corresponds to a frequency threshold.
[0096] In addition, in step S702, the memory allocator compresses and stores the data of tasks with lower execution frequency to reduce the memory space occupied by the data and release part of the memory space of the operating system. The released memory space can be allocated to other tasks to improve the utilization of memory resources.
[0097] Step S703, when the battery management task is in execution state, decompress the compressed target data in the second memory area to obtain the target data.
[0098] In step S703, when the battery management task needs to be executed, the compressed target data may be decompressed to ensure the normal operation of the battery management task.
[0099] In one example, to ensure sufficient memory space, the memory allocator plans to reserve memory in advance. For example, when the system starts, a dedicated memory area is allocated to each static task, and the memory is dynamically adjusted. For example, the algorithm is adjusted according to the actual situation and memory compression technology is adopted. When the memory allocator detects that the memory pressure is high, the memory manager in the battery management system chooses to compress inactive floating-point data pages so that they are still retained in the physical memory to reduce the space occupied; when these compressed floating-point data need to be accessed, the memory allocator restores the data through decompression operations and re-establishes the address mapping relationship with the process to ensure normal access and use of the data.
[0100] Through steps S701 to S703, the relevant data of the tasks with lower execution frequency are compressed to reduce the memory space occupied by the data; when the task needs to access the data, the data are decompressed to ensure the normal operation of the task.
[0101] When the battery management task is a dynamic task, the memory allocator uses Figure 8 The method shown allocates memory resources in the second memory area to the battery management task. Specifically, Figure 8 As shown, the method includes the following steps S801 to S803: Step S801: divide the second memory area into a plurality of memory blocks.
[0102] In step S801, the memory allocator may use the memory pool technology to divide the second memory area into a plurality of memory blocks of fixed sizes to meet the needs of collected data of different sizes.
[0103] In one example, the memory allocator may divide the second memory area into multiple memory blocks of equal size, wherein the size and number of the memory blocks are determined according to the size of the memory resources requested by the dynamic tasks under historical working conditions. For example, under historical working conditions, there are usually 3 dynamic tasks applying for dynamic memory in the same period, and the memory capacity required by the 3 dynamic tasks is A. Then the memory allocator divides the second memory area into 3 memory blocks, and the memory capacity of each memory block is set to A.
[0104] In another example, the memory allocator may also divide the second memory area into multiple memory blocks of different sizes based on the size of memory resources requested by the dynamic memory under historical operating conditions. For example, under historical operating conditions, within the same time period, the intervals of memory resources requested by dynamic tasks are typically [A, B], [B, C], and [C, D]. The memory allocator then divides the second memory area into three memory blocks, whose corresponding memory capacity sizes are BA, CB, and DC, respectively.
[0105] Step S802: determining at least one target memory block from a plurality of memory blocks according to the memory requirement of the battery management task.
[0106] In step S802, the total memory corresponding to at least one target memory block is greater than or equal to the required memory.
[0107] In one example, if a memory block larger than the memory requirement exists among the multiple memory blocks, the memory block is used as the target memory block. If a memory block larger than the memory requirement does not exist among the multiple memory blocks, multiple consecutive memory blocks can be merged to provide memory resources for the battery management task, and these memory blocks can be used as the target memory blocks.
[0108] Step S803: Allocate at least one target memory block to the battery management task.
[0109] In one example, for dynamic tasks, taking data acquisition tasks as an example, the allocation strategy of the dynamic memory area is optimized to reduce memory fragmentation based on the small data block requirements of the data acquisition tasks. The memory allocator can set the dynamic memory allocation flag in the configuration information of the data acquisition task according to the function of the data acquisition task and the required static memory size. After the BMS system is started, when the data acquisition task is created, the memory allocator uses the memory pool technology to apply for dynamic memory for the data acquisition task according to the flag bit of the configuration information of the data acquisition task. The use of memory pool technology can ensure that the data acquisition task can quickly obtain memory when it is needed, without causing task delays due to the uncertainty of dynamic memory allocation.
[0110] By dividing the second memory area into multiple memory blocks through steps S801 to S803 to allocate memory for dynamic tasks, not only can the normal execution of dynamic tasks be preserved, but also memory fragmentation can be reduced, waste of memory resources can be reduced, and rationality of memory allocation can be improved.
[0111] In one embodiment, the memory allocator also releases at least one target memory block when the battery management task is completed, so that other dynamic memories can continue to use the memory block, thereby improving the utilization rate of the memory space.
[0112] This completes the introduction of the method provided in the embodiments of the present application.
[0113] As can be seen from the above introduction, in the embodiment of the present application, a memory allocation strategy corresponding to the task type is used to allocate appropriate memory to the task, which reduces the memory allocation restrictions of the memory allocator and improves memory utilization and system performance. Static continuous memory is used to provide services for the execution of static tasks, and sufficient running memory is provided for the execution of static tasks to reduce the risk of buffer overflow or cross-boundary access problems. Dynamic tasks usually require smaller memory, and dynamically allocate memory for dynamic tasks, making full use of memory fragmentation and improving memory utilization.
[0114] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0115] In one embodiment, Fig. 9 A schematic diagram of a memory allocation device of a battery management system is shown, comprising Fig. 9 It can be seen that the device 900 includes: a task acquisition module 901, a memory determination module 902 and a memory allocation module 903.
[0116] The task acquisition module 901 is used to obtain the task type of the battery management task in response to the memory allocation request; A memory determination module 902, configured to determine a second memory area corresponding to a task type of a battery management task from a first memory area of an operating system corresponding to the battery management system; The memory allocation module 903 is used to allocate the second memory area to the battery management task by adopting a memory allocation strategy corresponding to the task type.
[0117] In one embodiment, the task acquisition module is specifically used to acquire a task identifier corresponding to the battery management task; and determine the task type of the battery management task according to the task identifier corresponding to the battery management task.
[0118] In one embodiment, the task types include static tasks and dynamic tasks. Static tasks include tasks for implementing data processing functions, and dynamic tasks include tasks for implementing data collection functions.
[0119] In one embodiment, when there are multiple battery management tasks, the memory determination module includes: a priority determination module and a first memory determination module. The priority determination module is used to determine the memory allocation priority corresponding to each battery management task according to the task type of the battery management task, wherein the memory allocation priority of a static task is higher than the memory allocation priority of a dynamic task; and the first memory determination module is used to determine the second memory area from the first memory area according to the order of the memory allocation priorities of the battery management tasks from high to low.
[0120] In one embodiment, the second memory area includes a memory area corresponding to a static task, and / or a memory area corresponding to a dynamic task. The first memory determination module is specifically used to determine the static memory area in the first memory area as the memory area corresponding to the static task according to the memory allocation priority of the battery management task from high to low, wherein the static memory area is a memory area in the first memory area where the memory is greater than the minimum memory required to execute the static task; and determine the dynamic memory area in the first memory area as the memory area corresponding to the dynamic task, wherein the dynamic memory area is the memory area remaining after allocating memory to the static task in the first memory area.
[0121] In one embodiment, when the battery management task is a static task, the memory allocation module is specifically used to obtain the minimum memory required to execute the static task from the task parameters of the battery management task; when there is a static memory area in the first memory area, obtain the memory address corresponding to the static memory area, wherein the static memory area is a memory area in the first memory area whose memory is greater than the minimum memory; allocate memory resources to the battery management task according to the memory address, so that the battery management task accesses the static memory area.
[0122] In one embodiment, the memory allocation device of the battery management system also includes: an early warning module, which is used to obtain memory usage data of the second memory area; when the memory usage data meets preset conditions, a early warning prompt message is generated, wherein the preset conditions at least include that the memory usage rate of the second memory area is higher than a preset memory usage rate threshold.
[0123] In one embodiment, the memory allocation device of the battery management system also includes: a memory adjustment module, which is used to obtain the execution frequency of the battery management task when the memory usage data meets the preset conditions; when the execution frequency of the battery management task is lower than the preset frequency threshold and the battery management task is in a stopped state, compress the target data required to execute the battery management task to obtain compressed target data; when the battery management task is in an execution state, decompress the compressed target data in the second memory area to obtain the target data.
[0124] In one embodiment, when the battery management task is a dynamic task, the memory allocation module is specifically used to divide the second memory area into multiple memory blocks; determine at least one target memory block from the multiple memory blocks according to the required memory of the battery management task, wherein the total memory corresponding to the at least one target memory block is greater than or equal to the required memory; and allocate the at least one target memory block to the battery management task.
[0125] In one embodiment, the memory allocation device of the battery management system further includes: a memory release module, which is used to release at least one target memory block when the battery management task is completed.
[0126] In one embodiment, the present application further provides a readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the above-mentioned memory allocation method for the battery management system is implemented.
[0127] In one embodiment, the present application further provides a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the above-mentioned memory allocation method of the battery management system.
[0128] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0129] The functional blocks shown in the above structural block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. "Machine-readable medium" may include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memory, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0130] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. 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 embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0131] The above describes various aspects of the present application with reference to the flowcharts and / or block diagrams of the memory allocation method, device, system, medium and product of the battery management system according to the embodiments of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram 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 device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the functions / actions specified in one or more boxes of the flowchart and / or block diagram. 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 can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should all be included in the scope of the claims and specification of the present application. In particular, as long as there is no structural conflict, the various technical features mentioned in the various embodiments can be combined in any way. The present application is not limited to the specific embodiments disclosed herein, but includes all technical solutions that fall within the scope of the claims.
Claims
1. A memory allocation method for a battery management system, characterized in that: include: In response to the memory allocation request, obtaining a task type of the battery management task; Determine a second memory area corresponding to the task type of the battery management task from a first memory area of an operating system corresponding to the battery management system; Using a memory allocation strategy corresponding to the task type, allocating the second memory area to the battery management task; In the case that there are multiple battery management tasks, determining the second memory area corresponding to the task type of the battery management task from the first memory area of the operating system corresponding to the battery management system includes: for each battery management task, determining the memory allocation priority corresponding to the battery management task according to the task type of the battery management task, wherein the memory allocation priority of a static task is higher than the memory allocation priority of a dynamic task; and determining the second memory area from the first memory area according to the order of the memory allocation priorities of the battery management tasks from high to low.
2. The method according to claim 1, characterized in that: The task type for obtaining the battery management task includes: Obtaining a task identifier corresponding to the battery management task; The task type of the battery management task is determined according to the task identifier corresponding to the battery management task.
3. The method according to claim 2, characterized in that The task types include static tasks and dynamic tasks. The static tasks include tasks for implementing data processing functions, and the dynamic tasks include tasks for implementing data collection functions.
4. The method according to any one of claims 1 to 3, characterized in that The second memory area includes a memory area corresponding to the static task and / or a memory area corresponding to the dynamic task, and the determining the second memory area from the first memory area according to the memory allocation priority of the battery management task from high to low order includes: According to the memory allocation priorities of the battery management tasks from high to low, a static memory area in the first memory area is determined as a memory area corresponding to the static task, wherein the static memory area is a memory area in the first memory area whose memory is greater than the minimum memory required to execute the static task; A dynamic memory area in the first memory area is determined as a memory area corresponding to the dynamic task, wherein the dynamic memory area is a memory area remaining after memory is allocated to the static task in the first memory area.
5. The method according to any one of claims 1 to 3, characterized in that: In the case where the battery management task is the static task, adopting a memory allocation strategy corresponding to the task type to allocate the second memory area to the battery management task includes: Obtaining the minimum memory required to execute the static task from the task parameters of the battery management task; In the case where a static memory area exists in the first memory area, obtaining a memory address corresponding to the static memory area, wherein the static memory area is a memory area in the first memory area whose memory is greater than the minimum memory; Memory resources are allocated to the battery management task according to the memory address, so that the battery management task accesses the static memory area.
6. The method according to claim 5, characterized in that The method further comprises: Obtaining memory usage data of the second memory area; When the memory usage data meets a preset condition, a warning prompt message is generated, wherein the preset condition at least includes that the memory usage rate of the second memory area is higher than a preset memory usage rate threshold.
7. The method according to claim 6, characterized in that The method further comprises: When the memory usage data satisfies the preset condition, obtaining the execution frequency of the battery management task; When the execution frequency of the battery management task is lower than a preset frequency threshold and the battery management task is in a stopped state, compressing target data required for executing the battery management task to obtain compressed target data; When the battery management task is in execution state, the compressed target data in the second memory area is decompressed to obtain the target data.
8. The method according to any one of claims 1 to 3, characterized in that In the case where the battery management task is the dynamic task, adopting a memory allocation strategy corresponding to the task type to allocate memory resources in the second memory area to the battery management task includes: Dividing the second memory area into a plurality of memory blocks; Determine at least one target memory block from the multiple memory blocks according to the required memory of the battery management task, wherein the total memory corresponding to the at least one target memory block is greater than or equal to the required memory; The at least one target memory block is assigned to the battery management task.
9. The method according to claim 8, characterized in that The method further comprises: When the battery management task is completed, the at least one target memory block is released.
10. A battery management system, characterized in that: include: Task executor, used to create and execute battery management tasks; A memory connected to the task executor, and used to provide memory resources for the task executor to perform the battery management task, wherein the memory includes a first memory area of an operating system corresponding to the battery management system; a memory allocator connected to the task executor and the memory, and configured to determine a second memory area from the first memory area according to a task type of the battery management task, and allocate the second memory area in the memory to the battery management task by adopting a memory allocation strategy corresponding to the task type; In the case where there are multiple battery management tasks, the memory allocator is used to determine the memory allocation priority corresponding to each battery management task according to the task type of the battery management task, wherein the memory allocation priority of a static task is higher than the memory allocation priority of a dynamic task; and determine the second memory area from the first memory area according to the order of the memory allocation priorities of the battery management tasks from high to low.
11. A memory allocation device for a battery management system, characterized in that: include: A task acquisition module, used for acquiring a task type of a battery management task in response to a memory allocation request; A memory determination module, used to determine a second memory area corresponding to a task type of the battery management task from a first memory area of an operating system corresponding to the battery management system; A memory allocation module, configured to allocate the second memory area to the battery management task by adopting a memory allocation strategy corresponding to the task type; In the case where there are multiple battery management tasks, the memory determination module includes: a priority determination module, used to determine the memory allocation priority corresponding to the battery management task for each battery management task according to the task type of the battery management task, wherein the memory allocation priority of a static task is higher than the memory allocation priority of a dynamic task; a first memory determination module, used to determine the second memory area from the first memory area according to the memory allocation priority of the battery management task in descending order.
12. A readable storage medium, characterized in that: Computer program instructions are stored on the readable storage medium, and when the computer program instructions are executed by the processor, the memory allocation method of the battery management system according to any one of claims 1 to 9 is implemented.
13. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the memory allocation method for a battery management system as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Battery management method and device, electronic equipment and storage medium
CN110231993A
Memory allocation method and device and computer readable storage medium
CN111309644A
Memory allocation method and system, electronic equipment and storage medium
CN115344391A
Stack space task allocation method adopting dynamic management strategy
CN118585314A
Dynamic memory adjustment method and system based on comprehensive task scheduling algorithm
CN118963907A