A memory allocation method, device, and adaptive automobile open system architecture
By adopting memory pooling technology and swap block mechanism in the adaptive automotive open system architecture, the resource bottlenecks and memory fragmentation problems caused by dynamic memory application and release in traditional systems are solved, and more efficient memory utilization and data security are achieved.
Patent Information
- Application Number
- CN202111595985.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2041-12-23
AI Technical Summary
Traditional automotive open system architectures cannot meet the functional needs of complex automotive electronic systems, especially in service-oriented architecture development and high-performance processor use, there are resource bottlenecks and memory fragmentation problems caused by dynamic memory application and release.
The memory pool technology and swap block mechanism are adopted to share the swap block collection through multiple memory pools to dynamically manage memory resources, avoid dynamic memory application and release, reduce memory fragmentation, and improve memory utilization.
It improves memory utilization, reduces resource bottlenecks during runtime, shortens memory application time, ensures certainty of application time, and provides a memory protection mechanism to improve data security.
Smart Images

Figure CN114296917B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of autonomous driving technology, and in particular to a memory allocation method, device, and adaptive automobile open system architecture. Background Art
[0002] With the rapid development of autonomous driving and intelligent network technology, the traditional automotive open system architecture (Classical Automotive Open System Architecture, Classical AUTOSAR) can no longer meet the functional requirements of increasingly complex automotive electronic systems. In particular, Adaptive AUTOSAR has incomparable advantages in terms of service-oriented architecture development and the use of high-performance processors. As we all know, with the increasing complexity of automotive electronic systems and the application of more and more software and electromechanical devices, the risks of electronic system failures and random hardware failures are increasing.
[0003] In functional safety, Dependent Failure Analysis (DFA) is a very important task. The software development standards for automotive electronic systems mention the need to ensure the independence and freedom from interference between software architecture elements. This is an analysis process that must be experienced for developing software that meets functional safety requirements. It is difficult and labor-intensive. The software development standards for automotive electronic systems divide the possible causes of interference with software elements into three parts: timing and execution, memory, and communication. Among them, memory is a very important reason. Functional safety requires no dynamic objects or variables, and requires avoiding unnecessary or undetected memory overlap, avoiding inadvertent overwriting of other variables, avoiding stack overflows, avoiding resource bottlenecks at runtime, and avoiding uncertainty. Figure 1 It is a schematic diagram of the existing adaptive automotive open system architecture, including applications, platform modules, operating systems and hardware. Whether it is an application or a platform module, it directly calls the Portable Operating System Interface (POSIX) or the programming language C++ interface to dynamically apply for / release memory. The software development standard IOS26262 for automotive electronic systems requires that dynamic application / release of memory should be avoided as much as possible, and even in some high-level autonomous driving safety levels, such as ASIL D, dynamic application / release of memory is prohibited. For dynamic application / release of memory, frequent dynamic application / release will generate a large amount of memory fragmentation, which will not only increase the uncertainty of application results and time, but also affect performance. Summary of the invention
[0004] The embodiments of the present application provide a memory allocation method, device, and adaptive automotive open system architecture, which can improve memory utilization and reduce resource bottlenecks during operation. In addition, by using a memory pool, memory fragmentation can be reduced and application time can be shortened.
[0005] The present application provides a memory allocation method, including:
[0006] Get a memory request; the memory request includes a target size;
[0007] Determine a target memory pool matching the target size from among multiple memory pools;
[0008] Determine a target swap block corresponding to a target memory pool from a swap block set;
[0009] Determine a target memory set from the memory set corresponding to the target swap block;
[0010] Generate memory request feedback based on the target memory set;
[0011] The target exchange block is an idle exchange block in the exchange block set, and multiple memory pools share the exchange block set. Any exchange block in the exchange block set can only be used by one memory pool in the multiple memory pools at any time.
[0012] Further, determining a target exchange block corresponding to the target memory pool from the exchange block set includes:
[0013] If the target memory pool has a corresponding exchange block set, based on the memory pool control block of the target memory pool, a target exchange block corresponding to the target memory pool is determined from the exchange block set corresponding to the target memory pool.
[0014] Further, determining a target exchange block corresponding to the target memory pool from the exchange block set includes:
[0015] If the corresponding exchange block set of the target memory pool is an empty set, or the exchange blocks in the exchange block set of the target memory pool are exchange blocks in a busy state, determine the target exchange block corresponding to the target memory pool from the exchange block set corresponding to the exchange block management module.
[0016] Furthermore, after determining the target swap block corresponding to the target memory pool, the method further includes:
[0017] The exchange block set corresponding to the target memory pool is updated, and the target exchange block is added to the exchange block set corresponding to the target memory pool to obtain the exchange block set corresponding to the updated target memory pool.
[0018] Further, determining a target memory set from the memory set corresponding to the target exchange block includes:
[0019] Based on the exchange control block of the target exchange block, a target memory set is determined from the memory sets corresponding to the target exchange block.
[0020] Furthermore, the above method also includes:
[0021] When the application of the memory request is completed, the target memory collection is released.
[0022] Accordingly, an embodiment of the present application further provides a memory allocation device, including:
[0023] An acquisition module is used to acquire a memory application request; the memory application request includes a target size;
[0024] A first determination module is used to determine a target memory pool matching a target size from a plurality of memory pools;
[0025] A second determination module is used to determine a target exchange block corresponding to a target memory pool from the exchange block set; the target exchange block is an exchange block in an idle state in the exchange block set, multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool among the multiple memory pools at any time;
[0026] A third determination module is used to determine a target memory set from the memory set corresponding to the target exchange block; the target memory in the target memory set is the available memory;
[0027] A generation module is used to generate memory request feedback based on a target memory set.
[0028] Furthermore, the second determining module is used to:
[0029] If the target memory pool has a corresponding exchange block set, based on the memory pool control block of the target memory pool, a target exchange block corresponding to the target memory pool is determined from the exchange block set corresponding to the target memory pool.
[0030] Furthermore, the second determination module is used to determine the target switch block corresponding to the target memory pool from the switch block set corresponding to the switch block management module if the corresponding switch block set of the target memory pool is an empty set, or the switch block in the switch block set of the target memory pool is a switch block in a busy state.
[0031] Furthermore, the above device also includes:
[0032] The update module is used to update the exchange block set corresponding to the target memory pool after determining the target exchange block corresponding to the target memory pool, add the target exchange block to the exchange block set corresponding to the target memory pool, and obtain the exchange block set corresponding to the updated target memory pool.
[0033] Furthermore, the third determination module is used to determine the target memory set from the memory sets corresponding to the target switch block based on the switch control block of the target switch block.
[0034] Furthermore, the above device also includes:
[0035] The release module is used to release the target memory collection after the application of the memory application request ends.
[0036] Accordingly, an embodiment of the present application further provides an adaptive automotive open system architecture, including a memory allocation device, the memory allocation device including a memory pool layer, a switch block layer and a memory layer;
[0037] The memory pool layer includes multiple memory pools, each memory pool has a memory pool control block;
[0038] The switch block layer includes a switch block set, each switch block in the switch block set has a switch control block;
[0039] The memory layer includes multiple memories, each of which includes a memory header and a memory body;
[0040] Wherein, the memory pool control block is used to determine the target exchange block from the exchange block set of the exchange block layer in the head-to-tail order based on the idle exchange block linked list;
[0041] The exchange control block is used to determine a target memory set from multiple memories of the memory layer based on a free memory linked list.
[0042] Correspondingly, an embodiment of the present application also provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by the processor to implement the above-mentioned memory allocation method.
[0043] Accordingly, an embodiment of the present application also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the above-mentioned memory allocation method.
[0044] The embodiments of the present application have the following beneficial effects:
[0045] A memory allocation method, device, and adaptive automotive open system architecture disclosed in the embodiment of the present application include obtaining a memory application request, the memory application request includes a target size; determining a target memory pool matching the target size from multiple memory pools; determining a target exchange block corresponding to the target memory pool from an exchange block set; the target exchange block is an exchange block in an idle state in the exchange block set, multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool in the multiple memory pools at any time; determining a target memory set from a memory set corresponding to the target exchange block; and generating memory application feedback based on the target memory set. Based on the memory pool technology adopted in the embodiment of the present application, there is no need to dynamically apply for dynamic memory when the system is running, and it can be directly obtained from the memory pool. And through the exchange block mechanism, that is, adding exchange blocks shared by multiple memory pools, memory utilization can be improved to prevent resource bottlenecks during operation. In addition, memory fragmentation can be reduced, application time can be shortened, and the application time can be determined. In addition, a memory protection mechanism is also provided to improve data security. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0047] Figure 1 It is a schematic diagram of the existing adaptive automotive open system architecture;
[0048] Figure 2 It is a flowchart of a memory allocation method provided in an embodiment of the present application;
[0049] Figure 3 is a schematic diagram of memory allocation provided in an embodiment of the present application;
[0050] Figure 4 It is a structural schematic diagram of a memory allocation device provided in an embodiment of the present application;
[0051] Figure 5 is a schematic diagram of an adaptive automotive open system architecture provided by an embodiment of the present application;
[0052] Figure 6 It is a schematic diagram of another adaptive automotive open system architecture provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiment is only one embodiment of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0054] The "embodiment" referred to herein refers to a specific feature, structure or characteristic that may be included in at least one implementation of the present application. In the description of the embodiments of the present application, it should be understood that, in addition, the terms "including", "having" and "being" and any variations thereof are intended to cover non-exclusive inclusions.
[0055] The following describes a specific embodiment of a memory allocation method of the present application. Figure 2 is a flowchart of a memory allocation method provided in an embodiment of the present application, Figure 3 It is a schematic diagram of memory allocation provided by an embodiment of the present application. This specification provides method operation steps as shown in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one of many execution orders and does not represent the only execution order. In actual execution, the method sequence shown in the embodiment or the accompanying drawings may be executed or executed in parallel (for example, in a parallel processor or multi-threaded processing environment).
[0056] User memory management in the Adaptive AUTOSAR platform is configured according to the Electronic Control Unit (ECU). When the engine starts, the ECU enters the working state, and some running programs or operating instructions are transferred from the memory to the central processing unit (CPU) to control the running of the process corresponding to the running program or operating instruction. For example, control the running of processes such as fuel injection, ignition timing, and idle speed. The embodiment of the present application adopts the memory pool (User Buffer Pool, UB Pool) technology to achieve efficient management of frequently applied memory. Among them, the memory can be divided into system memory and user memory, which are used by the internal application of the Adaptive AUTOSAR platform and the external application of the Adaptive AUTOSAR platform respectively. In addition, the embodiment of the present application adds a set of exchange blocks shared by multiple memory pools, and there are protection pages between the exchange blocks to provide alarms when memory accesses, and dynamic UB protection can be performed. In a multi-process environment, the memory resources of each process are independent of each other, so each process has its own exchange block configuration information, that is, each process has a corresponding exchange block configuration table. The application process maintains the swap block size and the total number of swap blocks, and allows users to configure a custom memory pool to carry memory size.
[0057] As for the UB in the Adaptive AUTOSAR platform, since it only carries events, i.e. messages, it mainly relies on the Adaptive AUTOSAR platform for maintenance. Currently, the unified support adopts the Unix Socket communication method. The Adaptive AUTOSAR platform UB is used to cache events only in special cases such as when the coroutine CORO sends synchronous events or when two COROs in the same scheduling task send events. At most one Adaptive AUTOSAR platform UB needs to be reserved for each CORO. In actual applications, the number of synchronous events sent is not large. Therefore, at most 16 32K exchange blocks can be created during initialization. If they are not enough later, you can apply to the system again.
[0058] Specific as Figure 2 and 3 As shown, the method may include:
[0059] S201: Obtain a memory application request; the memory application request includes a target size.
[0060] In the embodiment of the present application, a memory application request sent by an applicant may be obtained, and the memory application request includes a target size.
[0061] S203: Determine a target memory pool that matches the target size from multiple memory pools.
[0062] In an embodiment of the present application, a target memory pool matching the target size can be determined from multiple memory pools according to the target size in the memory application request. In an optional implementation, a memory pool having a memory size ub size equal to the target size can be determined from multiple memory pools as the target memory pool.
[0063] In the embodiment of the present application, if there is no memory pool whose size matches the target size among the multiple memory pools, the system can be requested for heap memory, and the memory can be returned to the applicant who sent the memory request. By adopting the memory pool technology, there is no need to dynamically request dynamic memory when the system is running, and it can be directly obtained from the memory pool.
[0064] S205: Determine the target exchange block corresponding to the target memory pool from the exchange block set; wherein the target exchange block is an idle exchange block in the exchange block set, multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool among the multiple memory pools at any time.
[0065] In an embodiment of the present application, a swap block (S Block) is a large block of memory shared by multiple memory pools, and each swap block may be composed of one swap control block, several memory headers, and several memory bodies. Among them, the number of memory headers and the number of memory bodies are equal. At a certain moment, a swap block may be owned by a memory pool, that is, a memory pool has the right to use the swap block, and may wait to be owned by the memory pool in the swap block management module, i.e., the swap block manager. A swap block cannot be owned by two memory pools at the same time. If a swap block is no longer used by a memory pool, it can be retained in the usable S block list of the idle swap block corresponding to the memory pool, or it can be returned to the swap block management module, i.e., the swap block manager. The swap block management module can manage the idle swap block set based on a linked list. When the target memory pool does not have a corresponding swap block, a swap block set can be provided for determining the target swap block. In addition, the target swap block can be recycled after the target swap block is used.
[0066] In an optional embodiment, if the target memory pool has a corresponding exchange block set, the target exchange block corresponding to the target memory pool can be determined from the exchange block set corresponding to the target memory pool based on the memory pool control block of the target memory pool. Among them, the memory pool control block can manage idle exchange blocks and busy exchange blocks based on a linked list. Optionally, an exchange block can be randomly determined from the idle exchange block linked list usable S block list of the target memory pool as the target exchange block, or an exchange block can be determined from the idle exchange block linked list usable S block list of the target memory pool in a head-to-tail order as the target exchange block. For example, the first exchange block in the idle exchange block linked list usable S block list is used as the target exchange block.
[0067] In an optional implementation, if the exchange block set corresponding to the target memory pool is an empty set, that is, the target memory pool does not have a corresponding exchange block set, the target exchange block corresponding to the target memory pool can be determined from the exchange block set corresponding to the exchange block management module. The exchange block set corresponding to the target memory pool is updated, and the target exchange block is added to the exchange block set corresponding to the target memory pool to obtain the updated exchange block set corresponding to the target memory pool. Optionally, when the target memory pool's free exchange block linked list usable S block list is empty, and the target memory pool's full exchange block linked list full S block list is also empty, an application can be made to the free exchange block manager to determine the exchange block obtained as the target exchange block corresponding to the target memory pool, and add it to the free exchange block linked list usable S block list corresponding to the target memory pool.
[0068] In an optional implementation, if the exchange block in the exchange block set corresponding to the target memory pool is a busy exchange block, the target exchange block corresponding to the target memory pool can be determined from the exchange block set corresponding to the exchange block management module. The exchange block set corresponding to the target memory pool is updated, and the target exchange block is added to the exchange block set corresponding to the target memory pool to obtain the updated exchange block set corresponding to the target memory pool. Optionally, when the idle exchange block linked list usable S block list of the target memory pool is empty and the full exchange block linked list full S block list is not empty, an application can be made to the idle exchange block manager to determine the exchange block obtained as the target exchange block corresponding to the target memory pool, and add it to the idle exchange block linked list usable S block list corresponding to the target memory pool. Through the exchange block mechanism, that is, adding exchange blocks shared by multiple memory pools, memory utilization can be improved to prevent resource bottlenecks during operation. In addition, memory fragmentation can be reduced, application time can be shortened, and application time can be determined.
[0069] S207: Determine a target memory set from the memory sets corresponding to the target swap block.
[0070] In an embodiment of the present application, each exchange block in the exchange block set may be composed of one exchange control block, a plurality of memory heads and a plurality of memory bodies, wherein the number of memory heads is equal to the number of memory bodies. The exchange control block may manage the free memory in the memory set through a linked list free ub head list. After determining the target exchange block, the target memory set may be determined from the memory set corresponding to the target exchange block based on the exchange control block of the target exchange block, i.e., a plurality of memories in an idle state.
[0071] In an optional implementation, after an available swap block S Block is found in the memory pool UB Pool, semaphore protection may be performed, and free memory UB may be applied for from the swap block S Block, and relevant information of the applicant may be recorded.
[0072] S209: Generate memory request feedback based on the target memory set.
[0073] In the embodiment of the present application, after the target memory set is determined, the memory UB pointer in the target memory set may be returned to the applicant.
[0074] In an embodiment of the present application, when the application of the memory application request ends, the target memory collection can be released. In an optional implementation, the corresponding memory head can be found according to the incoming memory body pointer, and the memory head can be transferred from the used linked list of the exchange block where it is located to the free linked list. Optionally, the incoming memory body pointer can be offset to obtain the address of the corresponding memory head, and the exchange block where the memory is located can be further obtained based on the address of the memory head, and the semaphore protection is entered at the same time. If the memory exists in the full linked list of the interactive control block of the exchange block, it can be transferred to the free linked list. If the exchange block is idle at this time, it can be returned to the exchange block control module, and the semaphore protection can be released. Through the memory protection mechanism, the security of the data can be improved.
[0075] By adopting the memory allocation method provided in the embodiment of the present application and the memory pool technology, it is not necessary to dynamically apply for dynamic memory when the system is running, and it can be directly obtained from the memory pool. And through the exchange block mechanism, that is, adding exchange blocks shared by multiple memory pools, the memory utilization rate can be improved to prevent resource bottlenecks during operation. In addition, memory fragmentation can be reduced, the application time can be shortened, and the application time can be determined. In addition, a memory protection mechanism is provided to improve the security of data.
[0076] The embodiment of the present application also provides a memory allocation device, Figure 4is a schematic diagram of the structure of a memory allocation device provided in an embodiment of the present application, such as Figure 4 As shown, the device may include:
[0077] The acquisition module 401 is used to acquire a memory application request; the memory application request includes a target size;
[0078] The first determination module 403 is used to determine a target memory pool matching the target size from multiple memory pools;
[0079] The second determination module 405 is used to determine the target exchange block corresponding to the target memory pool from the exchange block set; the target exchange block is an exchange block in the exchange block set that is in an idle state, multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool among the multiple memory pools at any time;
[0080] The third determination module 407 is used to determine a target memory set from the memory set corresponding to the target exchange block; the target memory in the target memory set is the available memory;
[0081] The generating module 409 is used to generate memory application feedback based on the target memory set.
[0082] In the embodiment of the present application, the second determination module 405 may be used to:
[0083] If the target memory pool has a corresponding exchange block set, based on the memory pool control block of the target memory pool, a target exchange block corresponding to the target memory pool is determined from the exchange block set corresponding to the target memory pool.
[0084] In an embodiment of the present application, the second determination module 405 can be used to determine the target exchange block corresponding to the target memory pool from the exchange block set corresponding to the exchange block management module if the corresponding exchange block set of the target memory pool is an empty set, or the exchange block in the exchange block set of the target memory pool is a busy exchange block.
[0085] In the embodiment of the present application, the above device may further include:
[0086] The update module is used to update the exchange block set corresponding to the target memory pool after determining the target exchange block corresponding to the target memory pool, add the target exchange block to the exchange block set corresponding to the target memory pool, and obtain the exchange block set corresponding to the updated target memory pool.
[0087] In the embodiment of the present application, the third determination module 407 may be configured to determine a target memory set from memory sets corresponding to the target switch block based on the switch control block of the target switch block.
[0088] In the embodiment of the present application, the above device may further include:
[0089] The release module is used to release the target memory collection after the application of the memory application request ends.
[0090] The device and method embodiments in the embodiments of the present application are based on the same application concept.
[0091] The memory allocation device provided by the embodiment of the present application adopts the memory pool technology. When the system is running, there is no need to dynamically apply for dynamic memory, and it can be directly obtained from the memory pool. And through the exchange block mechanism, that is, adding exchange blocks shared by multiple memory pools, the memory utilization rate can be improved to prevent resource bottlenecks during operation. In addition, memory fragmentation can be reduced, the application time can be shortened, and the application time can be determined. In addition, a memory protection mechanism is provided to improve the security of data.
[0092] Figure 5 is a schematic diagram of an adaptive automotive open system architecture provided by an embodiment of the present application, Figure 6 It is a schematic diagram of another adaptive automotive open system architecture provided in an embodiment of the present application.
[0093] like Figure 5 As shown, the adaptive automotive open system architecture can include applications, platform modules, operating systems and hardware. Among them, the platform module includes communication management, RETful, time synchronization management, log and tracking management, core type management, persistence management, platform health management, password management, execution management, identity access management, diagnostic management, sensor interface management, update and configuration management, state management, network management, etc. The operating system includes process management, memory management, network management, timer management, resource management, inter-process communication, reception management, i.e., I / O management, and device start / stop management. Among them, memory management includes three independent sub-modules: memory allocation, memory protection, and memory exception handling. Memory allocation can be performed using the memory allocation method described above.
[0094] like Figure 6As shown, the adaptive automotive open system architecture may include a memory allocation system, namely a memory allocation module. From a hierarchical perspective, the memory allocation system may include a memory pool layer, namely a UB Pool layer, a switch block layer, namely an S Block layer, and a memory layer, namely a UB Head / Body layer. Among them, the memory pool layer may include multiple memory pools, each memory pool may have a memory pool control block (UB Pool Control), the switch block layer may include a switch block set, each switch block in the switch block set may have a switch block control block (S Block Control), and the memory layer may include multiple memories, each of which may include a memory header and a memory body. The memory pool control block is used to determine the target switch block from the switch block set of the switch block layer in a head-to-tail order based on the free switch block linked list, and the switch control block is used to determine the target memory set from multiple memories of the memory layer based on the free memory linked list.
[0095] An embodiment of the present application also provides an electronic device, which can be set in a server to store at least one instruction, at least one program, code set or instruction set related to a memory allocation method in an implementation method embodiment. The at least one instruction, the at least one program, the code set or instruction set is loaded and executed by the memory to implement the above-mentioned memory allocation method.
[0096] An embodiment of the present application also provides a storage medium, which can be set in a server to store at least one instruction, at least one program, code set or instruction set related to a memory allocation method in an implementation method embodiment. The at least one instruction, the at least one program, the code set or instruction set is loaded and executed by the processor to implement the above-mentioned memory allocation method.
[0097] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a mobile hard disk, a magnetic disk, or an optical disk.
[0098] It can be seen from the embodiments of the memory allocation method, device, electronic device or storage medium provided by the present application that the method in the present application includes obtaining a memory application request, the memory application request includes a target size; determining a target memory pool that matches the target size from multiple memory pools; determining a target exchange block corresponding to the target memory pool from an exchange block set; the target exchange block is an exchange block in an idle state in the exchange block set, and multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool in the multiple memory pools at any time; determining a target memory set from a memory set corresponding to the target exchange block; and generating memory application feedback based on the target memory set. Based on the exchange blocks shared by multiple memory pools in the embodiments of the present application, memory utilization can be improved and resource bottlenecks during runtime can be reduced. In addition, by adopting a memory pool, memory fragmentation can be reduced and application time can be shortened.
[0099] In the present invention, unless otherwise clearly specified and limited, the terms "connected", "connection" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be a connection between two elements or an interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0100] It should be noted that the order of the above embodiments of the present application is only for description and does not represent the advantages and disadvantages of the embodiments. The above description describes specific embodiments, and other embodiments are also within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in the order of different embodiments and can achieve the expected results. In addition, the processes depicted in the drawings do not necessarily require a specific order or connection order to achieve the desired results. In some embodiments, multi-task parallel processing is also possible or may be advantageous.
[0101] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is based on a method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0102] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A memory allocation method, characterized in that: include: Get memory application request; The memory application request includes a target size; Determine a target memory pool matching the target size from a plurality of memory pools; Determine a target exchange block corresponding to the target memory pool from the exchange block set; Determine a target memory set from the memory sets corresponding to the target exchange block; Generate memory request feedback based on the target memory set; The memory application feedback includes a release signal of the target memory set; Among them, the target exchange block is an idle exchange block in the exchange block set, the multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool among the multiple memory pools at any time.
2. The method according to claim 1, characterized in that The step of determining the target exchange block corresponding to the target memory pool from the exchange block set includes: If the target memory pool has a corresponding exchange block set, based on the memory pool control block of the target memory pool, the target exchange block corresponding to the target memory pool is determined from the exchange block set corresponding to the target memory pool.
3. The method according to claim 2, characterized in that The step of determining the target exchange block corresponding to the target memory pool from the exchange block set includes: If the corresponding exchange block set of the target memory pool is an empty set, or the exchange blocks in the exchange block set of the target memory pool are exchange blocks in a busy state, determine the target exchange block corresponding to the target memory pool from the exchange block set corresponding to the exchange block management module.
4. The method according to claim 3, characterized in that After determining the target swap block corresponding to the target memory pool, the method further includes: The exchange block set corresponding to the target memory pool is updated, and the target exchange block is added to the exchange block set corresponding to the target memory pool to obtain an updated exchange block set corresponding to the target memory pool.
5. The method according to claim 1, characterized in that The determining the target memory set from the memory set corresponding to the target exchange block includes: Based on the exchange control block of the target exchange block, the target memory set is determined from the memory sets corresponding to the target exchange block.
6. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the application of the memory application request is completed, the target memory set is released.
7. A memory allocation device, characterized in that: include: The acquisition module is used to obtain memory application requests; The memory application request includes a target size; A first determining module, configured to determine a target memory pool matching the target size from a plurality of memory pools; A second determination module is used to determine a target exchange block corresponding to the target memory pool from the exchange block set; The target exchange block is an idle exchange block in the exchange block set, the multiple memory pools share the exchange block set, and any exchange block in the exchange block set can only be used by one memory pool among the multiple memory pools at any time; A third determination module, used to determine a target memory set from the memory set corresponding to the target exchange block; The target memory in the target memory set is available memory; A generating module, used for generating memory application feedback based on the target memory set; The memory application feedback includes a release signal of the target memory set.
8. An adaptive automotive open system architecture, characterized in that: It includes a memory allocation device, which includes a memory pool layer, a swap block layer and a memory layer; The memory pool layer includes a plurality of memory pools, each memory pool having a memory pool control block; The switch block layer includes a switch block set, each switch block in the switch block set has a switch control block; The memory layer includes a plurality of memories, each memory including a memory header and a memory body; Wherein, the memory pool control block is used to determine the target exchange block from the exchange block set of the exchange block layer in a head-to-tail order based on the idle exchange block linked list; The exchange control block is used to determine a target memory set from the multiple memories of the memory layer based on a free memory linked list.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the memory allocation method described in any one of claims 1-6.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the memory allocation method as described in any one of claims 1-6.
Citation Information
Patent Citations
Memory management method and system
CN102063385A