WO2017070869A1 - 一种内存配置方法、装置及系统 - Google Patents
一种内存配置方法、装置及系统 Download PDFInfo
- Publication number
- WO2017070869A1 WO2017070869A1 PCT/CN2015/093113 CN2015093113W WO2017070869A1 WO 2017070869 A1 WO2017070869 A1 WO 2017070869A1 CN 2015093113 W CN2015093113 W CN 2015093113W WO 2017070869 A1 WO2017070869 A1 WO 2017070869A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- memory pool
- memory
- buffers
- local memory
- pool
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
Definitions
- the present invention relates to the field of data storage, and in particular, to a memory configuration method, apparatus, and system.
- the general memory configuration method is to divide memory, such as DDR (Double Data Rate SDRAM) into a plurality of memory pools, and place a plurality of memory blocks of the same length inside each memory pool.
- DDR Double Data Rate SDRAM
- the minimum unit is a "storage block".
- the operating system consisting of a processor, DDR, BMU (buffer management unit) and other functional modules as an example.
- the memory size of the processor and other functional modules in a certain system (for example, 2G network) is usually used. It does not change much within a certain range. Therefore, the BMU can pre-configure the proportional relationship between the storage blocks in each memory pool, so that the storage blocks in the memory pool can be used by the processor or other functional modules in a time-sharing manner or simultaneously. .
- the BMU configures the storage blocks of the Y block for use by the processor and other functional modules.
- Each memory block is 4X bytes in size (that is, Pool A is configured with X-byte granularity).
- the ratio of the storage block size in Pool B and Pool C) then, when allocating memory to the processor, function module 1 and function module 2, the BMU applies for the corresponding size storage from Pool A, Pool B, and Pool C respectively.
- the storage block length of Pool A is X bytes
- the storage block length of Pool B is 2X bytes
- the storage block length of Pool C is 4X bytes
- the storage block size ratio of Pool A, Pool B, and Pool C is It is 1:2:4, that is, the size of the memory block in different memory pools needs to be as close as possible to a certain proportional relationship.
- the granularity may change when the processor, the function module 1 and the function module 2 process data, for example, the processor, the function module 1 and the function module 2 have a granularity of Y when processing data (Y> X) byte, processor, function module 1
- the ratio of the storage block size required by function module 2 is 1:3:5.
- the ratio of the storage block size in Pool A, Pool B, and Pool C is still 1:2:4.
- the storage blocks are allocated according to the proportion of the configured storage block size, which results in a lower sharing rate of the storage blocks in the multi-standard operation scenario and lower utilization of the storage resources in the entire memory.
- the embodiment of the invention provides a memory configuration method, device and system, which can improve the sharing rate of the storage block in the multi-standard operation scenario, and increase the utilization rate of the storage resource in the entire memory.
- an embodiment of the present invention provides a memory configuration method, where the memory includes a common memory pool and at least one local memory pool, and the method includes: at least one local memory pool, the N local memory pool to be configured includes N a storage block, each of which contains M buffers, and the memory configuration device counts the number of buffers in the local memory pool to be configured to be idle, J, N ⁇ 0, M>0, 0 ⁇ J ⁇ N *M; if J is less than the first threshold, the memory configuration device applies at least one storage block from the common memory pool to the local memory pool to be configured until the number of buffers in the local memory pool to be configured is idle.
- the memory configuration device releases at least one storage block from the local memory pool to be configured to the common memory pool until the local memory pool to be configured is in an idle state.
- the number of buffers is equal to or smaller than the second threshold, wherein the second threshold is greater than the first threshold.
- the local memory pool to be configured can apply for the memory block released by other memory pools from the common memory pool through the memory configuration device, and release the free memory block to the public memory pool, so that the released memory block can also be According to the application of other local memory pools, it is recycled by other local memory pools to avoid the proportional relationship between the size of each buffer in the memory when allocating memory.
- the solution of the present invention can also improve the sharing rate of the storage blocks in the multi-standard operation scenario, and increase the utilization rate of the storage resources in the entire memory.
- the The storage configuration device applies at least one storage block from the common memory pool to the local memory pool to be configured until the number of buffers in the local memory pool to be configured is equal to or greater than the first threshold, including: A The memory configuration device requests the first storage block from the common memory pool to the local memory pool to be configured, the first storage block is any storage block in the common memory pool; B, the memory configuration device stores the first storage The block is divided into M buffers; C.
- the memory configuration device counts the current number of buffers in the local memory pool to be configured in an idle state; if the current number of buffers in the local memory pool to be configured is idle is less than The first threshold, the memory configuration device loops through steps A, B, and C until the number of buffers in the local memory pool to be configured in an idle state is equal to or greater than the first threshold.
- the memory configuration device releases the at least one memory block from the local memory pool to be configured to the public memory pool, to the local memory pool to be configured.
- the number of the buffers in the idle state is equal to or smaller than the second threshold, including: D, the memory configuration device releases the second storage block from the local memory pool to be configured to the common memory pool, where the second storage block is The storage block in the local memory pool is in an idle state; E.
- the memory configuration device counts the current number of buffers in the local memory pool to be configured in an idle state; if the current local memory pool to be configured is in an idle state The number of buffers is greater than the second threshold, and the memory configuration device loops through steps D and E until the number of buffers in the local memory pool to be configured in an idle state is equal to or less than the second threshold.
- the memory configuration device when the memory configuration device allocates a free buffer from the local memory pool to be configured, the memory configuration device can directly store the storage itself.
- the identifier of the buffer in the idle state is allocated to the software without querying and determining the buffer in the idle state from the in-memory local memory pool in the memory, thereby speeding up the memory configuration device to apply for the buffer.
- the memory configuration apparatus releases the at least one from the local memory pool to be configured Storing the block to the common memory pool until the number of buffers in the local memory pool to be idle is equal to or less than the second threshold, including: the memory configuration device according to at least one of the first buffers of the W buffers And the at least one first buffer is released to the third storage block in the first memory buffer in the local memory pool to be configured, the at least one first buffer and the buffer in the third storage block The area is in an idle state; the memory configuration device releases the third storage block from the local memory pool to be configured to the public memory pool.
- the memory configuration apparatus is configured to perform the first buffer according to the W buffers
- the identifier of the first buffer is released to the third storage block corresponding to the first buffer in the memory, and further includes: the memory configuration device statistics corresponding to the second buffer in the local memory pool to be configured In the memory block, whether the buffer other than the second buffer is in an idle state, the second buffer is any one of the W buffers; if the other buffers are in an idle state, the memory configuration The device then determines the second buffer as the first buffer.
- the memory configuration device is configured to be configured in the memory Before the J buffers in the idle state in the local memory pool, the memory configuration device divides the storage space of a predetermined size in the memory into the common memory pool, where the common memory pool includes Z storage blocks, Z ⁇ N.
- an embodiment of the present invention provides a memory configuration apparatus, where the memory configuration apparatus is connected to a memory, where the memory includes a common memory pool and at least one local memory pool to be configured, and the apparatus includes: a statistical unit, configured to perform statistics The number of buffers in the at least one local memory pool that are in an idle state in the local memory pool to be configured is J.
- the local memory pool to be configured includes N storage blocks, each of which contains M buffers, N ⁇ 0, M>0, 0 ⁇ J ⁇ N*M;; application unit, if J is smaller than the first a threshold, the application of the at least one storage block from the common memory pool to the local memory pool to be configured until the number of buffers in the local memory pool to be idle is equal to or greater than the first threshold; And if the J is greater than the second threshold, releasing at least one storage block from the local memory pool to be configured to the common memory pool, until the number of buffers in the local memory pool to be configured in an idle state is equal to or smaller than the second a threshold, the second threshold being greater than the first threshold.
- the local memory pool to be configured can apply for the memory block released by other memory pools from the common memory pool through the memory configuration device, and release the free memory block to the public memory pool, so that the released memory block can also be According to the application of other local memory pools, it is recycled by other local memory pools to avoid the proportional relationship between the size of each buffer in the memory when allocating memory.
- the solution of the present invention can also improve the sharing rate of the storage blocks in the multi-standard operation scenario, and increase the utilization rate of the storage resources in the entire memory.
- the application unit is specifically configured to: A: apply for a first storage block from a common memory pool to the local memory pool to be configured, the first The storage block is any storage block in the common memory pool; B, the first storage block is divided into M buffers; C, the current number of buffers in the local memory pool to be configured that are idle; If the number of buffers in the idle state of the to-be-configured local memory pool is less than the first threshold, the steps A, B, and C are performed cyclically until the number of buffers in the local memory pool to be configured in the idle state is equal to or greater than The first threshold.
- the releasing unit is specifically configured to: D: release the second storage block from the local memory pool to be configured to the public memory pool, where The second storage block is the storage block in the idle state in the local memory pool to be configured; E. The current number of buffers in the local memory pool to be configured is idle; if the current local memory pool to be configured is idle If the number of buffers in the state is greater than the second threshold, steps D and E are performed cyclically until the to-be-configured The number of buffers in the local memory pool that are idle is equal to or less than the second threshold.
- the releasing unit is configured to: identify, according to the at least one first buffer in the W buffers Deleting the at least one first buffer into a third storage block in the first memory buffer of the to-be-configured local memory pool, where the at least one first buffer and the buffer in the third storage block are both The idle state is released; the third storage block is released from the local memory pool to be configured to the public memory pool.
- the device further includes a determining unit, where the statistic unit is further configured to collect the local memory to be configured In the memory block corresponding to the second buffer in the pool, whether the other buffers other than the second buffer are in an idle state, the second buffer is any one of the W buffers; If the other buffer is in an idle state, the second buffer is determined as the first buffer.
- the apparatus further includes: a configuration unit, The storage space of a predetermined size in the memory is divided into the common memory pool, and the common memory pool includes Z storage blocks, Z ⁇ N.
- the apparatus may be a BMU.
- an embodiment of the present invention further provides a memory configuration apparatus, wherein the memory configuration apparatus includes: a processor, a memory, a bus, and a communication interface; the memory is configured to store a computer execution instruction, and the processor and the memory Connected via this bus, When the memory configuration device is in operation, the processor executes the computer-executable instructions stored by the memory to cause the memory configuration device to perform the memory configuration method of any of the first aspects.
- the memory configuration apparatus includes: a processor, a memory, a bus, and a communication interface; the memory is configured to store a computer execution instruction, and the processor and the memory Connected via this bus, When the memory configuration device is in operation, the processor executes the computer-executable instructions stored by the memory to cause the memory configuration device to perform the memory configuration method of any of the first aspects.
- the embodiment of the present invention further provides a memory configuration system, comprising: the memory configuration device according to any one of the second aspect, and a memory connected to the memory configuration device, wherein the memory includes a common memory pool and At least one local memory pool.
- the embodiment of the present invention provides a memory configuration method, apparatus, and system, wherein the memory configuration device counts J buffers in an idle state in a local memory pool to be configured, and the local memory pool to be configured includes N storage blocks, each of which The memory block includes M buffers, N ⁇ 0, M>0, 0 ⁇ J ⁇ N*M; if J is less than the first threshold, the memory configuration device applies at least one memory block from the common memory pool to be configured.
- the local memory pool until the number of buffers in the local memory pool to be idle is equal to or greater than the first threshold; if J is greater than the second threshold, the memory configuration device releases at least one memory block from the local memory pool to be configured to The public memory pool, until the number of buffers in the local memory pool to be idle is equal to or less than the second threshold.
- the local memory pool to be configured can apply for the memory block released by other memory pools from the common memory pool through the memory configuration device, and release the free memory block to the public memory pool, so that the released memory block can also be According to the application of other local memory pools, it is recycled by other local memory pools to avoid the proportional relationship between the size of each buffer in the memory when allocating memory.
- the solution of the present invention can also improve the sharing rate of the storage blocks in the multi-standard operation scenario, and increase the utilization rate of the storage resources in the entire memory.
- FIG. 1 is a schematic diagram of a memory allocation performed by a BMU in the prior art
- FIG. 2 is a system architecture diagram of a memory configuration system according to an embodiment of the present invention.
- FIG. 3 is a schematic structural diagram 1 of a storage block according to an embodiment of the present invention.
- FIG. 4 is a schematic flowchart diagram of a memory configuration method according to an embodiment of the present disclosure.
- FIG. 5 is a schematic structural diagram 2 of a storage block according to an embodiment of the present disclosure.
- FIG. 6 is a schematic structural diagram 1 of a memory configuration apparatus according to an embodiment of the present disclosure.
- FIG. 7 is a schematic structural diagram 2 of a memory configuration apparatus according to an embodiment of the present disclosure.
- FIG. 8 is a schematic structural diagram 3 of a memory configuration apparatus according to an embodiment of the present invention.
- first and second are used for descriptive purposes only, and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, features defining “first” and “second” may include one or more of the features either explicitly or implicitly. In the description of the present invention, "a plurality” means two or more unless otherwise stated.
- the memory configuration method provided by the embodiment of the present invention may be applied to a memory configuration system, as shown in FIG. 2, the memory configuration system may include a memory configuration device 01, and the memory configuration device 01 may be a hardware device such as a BMU, and The memory configuration device 01 is connected to the memory 02.
- the memory 02 includes a common memory pool and at least one local memory pool.
- the memory configuration system may further include a processor 03, such as at least one CPU, and the memory configuration device.
- the memory 02 and the processor 03 communicate via the bus 04.
- the memory configuration device 01 can be specifically used to manage the application and release of the storage space in the memory 02, reducing the load on the processor 03.
- the common memory pool and the at least one local memory pool included in the memory 02 may be a logical memory pool or a physical memory pool, which is not limited by the embodiment of the present invention, wherein the common memory pool and each A local memory pool can contain multiple memory blocks, each of which is a fixed size.
- the memory 02 can be pre-previously A fixed size storage space (for example, Z storage block sizes, Z>0) is divided into a common memory pool.
- a buffer may contain multiple buffers, and buffers in different local memory pools may have different sizes, so buffers in different memory blocks may be included. The number is different, then, the tail of the memory block can have a little free memory can not be utilized, that is, the tail fragment is formed.
- different local memory pools can correspond to different standards (for example, local memory pool 1 corresponds to 2G network standard, local memory pool 2 corresponds to 3G network standard, local memory pool 3 corresponds to 4G network standard, etc.), or different.
- the local memory pool can also correspond to different types of software (for example, the local memory pool 1 corresponds to the video software, the local memory pool 2 corresponds to the instant communication software, etc.), which is due to the buffer of the storage block in different local memory pools.
- the size of the memory may be inconsistent, and the granularity of the memory used by different standards or different types of software may also be different. For example, in the 2G network standard, it is usually used to process packet data such as voice packets, and the buffer in the memory block of the local memory pool 1 is used. The size of the area is relatively small, so using the memory blocks in the local memory pool 1 in the 2G network system can improve the memory utilization.
- a local memory pool that is, a local memory pool to be configured
- a memory configuration method provided by an embodiment of the present invention is provided. , including the following steps 101-103.
- Step 101 The memory configuration device counts J buffers in an idle state in the local memory pool to be configured.
- the local memory pool to be configured includes N storage blocks, and each storage block includes M buffers, N ⁇ 0, M. >0,0 ⁇ J ⁇ N*M.
- Step 102 If J is smaller than the first threshold, the memory configuration device applies at least one storage block from the common memory pool to the local memory pool to be configured until the number of buffers in the local memory pool to be idle is equal to or greater than The first threshold.
- Step 103 If J is greater than the second threshold, the memory configuration device releases at least one storage block from the local memory pool to be configured to the common memory pool, until the number of buffers in the local memory pool to be idle is equal to or less than the number of buffers. Two thresholds.
- each local memory pool contains N memory blocks
- Each memory block can be divided into M buffers of a certain size.
- it will apply for several buffers for data processing and other tasks in the corresponding local memory pool (for example, the local memory pool to be configured).
- a part of the buffer in the local memory pool to be configured is occupied, and the unoccupied buffer is the buffer in the idle state.
- the memory configuration device can periodically count the number of buffers in the local memory pool (for example, the local memory pool 1) that are idle, and obtain the J buffers in the local memory pool 1 to be idle.
- the local memory pool for example, the local memory pool 1
- each storage block in the local memory pool to be configured has its own identifier, such as the address of the storage block, which is used to indicate the location of each storage block in the memory.
- each memory block's buffer also has its own identifier, such as the address of the buffer, which is used to indicate the location of each buffer in the corresponding memory block, or directly used to indicate the location of the buffer in memory. .
- step 102 if the number J of buffers in the idle state obtained in step 101 is less than the first threshold, the number of unoccupied buffers in the local memory pool to be configured is small, and most The buffer is already occupied.
- the memory configuration device may apply at least one storage block from the common memory pool to the local memory pool to be configured until the number of buffers in the local memory pool to be configured is idle or equal to or greater than The first threshold.
- the memory configuration device may first apply, from the common memory pool, the first storage block to the local memory pool to be configured, where the first storage block is any one of the common memory pools; At this time, the memory configuration device divides the first storage block into M buffers according to the size of the preset buffer; and further, the memory configuration device counts the number of buffers in the current local memory pool to be configured in an idle state; If the number of buffers in the idle state of the current local memory pool is still less than the first threshold, the memory configuration device may perform the foregoing steps cyclically until the number of buffers in the local memory pool to be idle is equal to or The buffer is greater than the first threshold to ensure that there are enough buffers in the local memory pool to be configured to be available to each software, thereby improving the utilization of the storage resources.
- step 103 if the obtained in step 101 is in an idle state
- the number of buffers J is greater than the second threshold, which means that the number of unoccupied buffers in the local memory pool to be configured is large.
- the memory configuration device can be configured from the local to be configured. At least one storage block is released from the memory pool to the common memory pool until the number of buffers in the idle local memory pool is equal to or less than a second threshold, wherein the second threshold is greater than the first threshold.
- the memory configuration device first releases the second storage block from the local memory pool to be configured to the common memory pool, where the second storage block is in an idle state in the local memory pool to be configured. a memory block; in addition, the memory configuration device counts the number of buffers in the current local memory pool to be idle; if the number of buffers in the current local memory pool that are in the idle state is still greater than the second threshold, the memory configuration The device performs the above steps cyclically until the number of buffers in the local memory pool to be configured in an idle state is equal to or less than a second threshold. In this way, the second storage block that is released from the local memory pool to be configured to the common memory pool can be used by other local memory pools to be configured, thereby improving the utilization of the storage resources.
- the number J of the buffers in the local memory pool 1 that are in the idle state is greater than the second threshold.
- the memory configuration device releases the memory block 1 to the common memory pool from the local memory pool 1 to be configured, the local memory to be configured is configured.
- the number J of the buffers in the idle state in the pool 1 is smaller than the second threshold. In this case, the number J of buffers in the idle state in the local memory pool 2 is less than the first threshold.
- the memory block 1 is removed from the common memory pool to be allocated to the local memory pool 2, and the memory block 1 is divided into P (P>0) buffers for use, if the local memory pool 1 to be configured corresponds to the 2G network.
- the operation scenario of the system, and the local memory pool 2 to be configured corresponds to the operation scenario of the 3G network standard, then it can be seen that the storage block 1 released to the common memory pool can implement memory sharing across the system, and does not need to be buffered. Size makes a specific scale limit.
- first threshold and the second threshold that are involved in the embodiments of the present invention may be preset by a person skilled in the art according to actual experience or a specific algorithm, which is not limited by the embodiment of the present invention.
- an embodiment of the present invention provides a memory configuration method, wherein a memory is configured
- the device counts J buffers in an idle state in the local memory pool to be configured.
- the local memory pool to be configured includes N memory blocks, each of which contains M buffers, N ⁇ 0, M>0,0. ⁇ J ⁇ N * M; if J is less than the first threshold, the memory configuration device applies at least one memory block from the common memory pool to the local memory pool to be configured until the number of buffers in the local memory pool to be configured is idle.
- the value is equal to or greater than the first threshold; if J is greater than the second threshold, the memory configuration device releases at least one memory block from the local memory pool to be configured to the common memory pool until the number of buffers in the local memory pool to be idle is equal to Or less than the second threshold.
- the local memory pool to be configured can apply for the memory block released by other memory pools from the common memory pool through the memory configuration device, and release the free memory block to the public memory pool, so that the released memory block can also be According to the application of other local memory pools, it is recycled by other local memory pools to avoid the proportional relationship between the size of each buffer in the memory when allocating memory.
- the solution of the present invention can also improve the sharing rate of the storage blocks in the multi-standard operation scenario, and increase the utilization rate of the storage resources in the entire memory.
- a storage area may be further disposed in the memory configuration device, and the identifier of the W (W ⁇ J) buffers in the idle state of the local memory pool to be configured may be stored in a storage area in the memory configuration device, for example,
- the memory configuration device can place the identifiers of the plurality of free buffers in the LIFO (Last In First Out) stack, so that when the memory configuration device allocates software from the local memory pool to be configured When the buffer is free, the memory configuration device can directly assign the identifier of the buffer that is stored in the idle state to the software, and mark the allocated buffer as an occupied state without the need to be configured from the memory.
- the local memory pool queries and determines the buffer in the idle state, thereby speeding up the memory configuration device to apply for the buffer.
- the W buffers in the idle state in the local memory pool to be configured are stored in the storage area in the memory configuration device, the W buffers are already occupied for the memory. However, the W buffers are only temporarily occupied by the memory configuration device, and are not actually used by the software. The software can still use the W buffers.
- the specific configuration includes: the statistics are located in the memory configuration device.
- the number of identifiers of the buffers inside, that is, W, and the sum of the number of buffers Q (Q ⁇ 0) in the memory in the local memory pool to be configured in the memory, where J W + Q.
- the memory configuration device applies at least one memory block from the common memory pool to the local memory pool to be configured until the buffer in the local memory pool to be configured is in an idle state.
- the number is equal to or greater than the first threshold.
- step 103 if J is greater than the second threshold, the memory configuration device releases at least one memory block from the local memory pool to be configured to the common memory pool. At this time, if a certain memory block in the local memory pool to be configured is configured When all the identifiers of the M buffers are not in the memory configuration device, and the M buffers are in the idle state, the memory configuration device can directly release the memory block into the common memory pool.
- the identifiers of the W buffers in the LIFO stack often belong to multiple different storage blocks, as shown in FIG. 5, for the storage in the local memory pool to be configured in the memory.
- the buffers 101-108 are all idle, and the buffers 109 and 110 are located in the LIFO stack of the memory configuration device, that is, all buffers in the memory block 1 are idle, but for the in-memory In the case of configuring the local memory pool, it is considered that the buffers 109 and 110 are occupied. Since the memory configuration device in the embodiment of the present invention needs to apply and release the memory block in units of memory blocks, the memory block 1 is caused to be in step 103. Cannot be released to the public memory pool and shared to other systems of the local memory pool to be configured.
- the memory configuration device may first release the at least one first buffer according to the identifier of the at least one first buffer in the W buffers to a third storage block in which the first buffer is located in the local memory pool, wherein the first buffer and other buffers in the third storage block are in an idle state; and further, the memory configuration device is further The third memory block is released to the public memory pool in the local memory pool to be configured.
- the memory configuration device may first count the occupation status of each buffer corresponding to the identifier of the W buffers in the LIFO stack in the local memory pool to be configured, and the first in the W buffers. For example, if the buffer is in the memory block 3 corresponding to the second buffer in the local memory pool to be configured, all the buffers except the second buffer are in an idle state, and the memory configuration device The second buffer is determined as the first buffer, and the memory configuration device releases the first buffer to the memory block 3 corresponding to the first buffer according to the identifier of the first buffer, and then The storage block 3 is released to the common memory pool in the local memory pool to be configured.
- the memory configuration device may count the occupancy of the storage block corresponding to the identifier of each buffer in the LIFO stack, and if it is determined that the buffer 109 and the buffer 110 correspond to the storage block 1
- the buffers 101-108 are all in an idle state, and the memory configuration device can determine the buffer 109 and the buffer 110 as the first buffer. Further, the memory configuration device determines the identifier of the buffer 109 and the identifier of the buffer 110 according to the identifier of the buffer 109.
- the buffer 109 and the buffer 110 are released to the memory block 1 in the memory, and then the memory block 3 is released from the local memory pool to be configured to the common memory pool.
- the storage block 3 that is released from the local memory pool to be configured to the common memory pool can be used by other local memory pools to be configured, thereby improving the sharing rate of the storage blocks in the multi-standard operation scenario and making the entire memory.
- the utilization of storage resources has increased.
- the embodiment of the present invention provides a memory configuration method, wherein the memory configuration device counts J buffers in an idle state in a local memory pool to be configured, and the local memory pool to be configured includes N storage blocks, and each storage The block contains M buffers, N ⁇ 0, M>0, 0 ⁇ J ⁇ N*M; if J is less than the first threshold, the memory configuration device applies at least one memory block from the common memory pool to the local memory to be configured. The pool, until the number of buffers in the local memory pool to be idle is equal to or greater than the first threshold; if J is greater than the second threshold, the memory configuration device releases at least one memory block from the local memory pool to be configured to the common memory.
- the number of buffers in the pool until the local memory pool to be configured is idle is equal to or less than the second threshold. It can be seen that the local memory pool to be configured can apply for the memory block released by other memory pools from the common memory pool through the memory configuration device, and release the free memory block to the public memory pool, so that the internal memory pool is released.
- the save block can also be recycled by other local memory pools according to the application of other local memory pools, which can avoid the proportional relationship of the size of each buffer in the memory when allocating memory, and at the same time, different memory pools can be used for different standards respectively.
- the operation scenario therefore, the solution of the present invention can also improve the sharing rate of the storage blocks in the multi-standard operation scenario, so that the utilization rate of the storage resources in the entire memory is increased.
- FIG. 6 is a schematic structural diagram of a memory configuration apparatus according to an embodiment of the present invention, and the memory configuration apparatus provided by the embodiment of the present invention may be used to implement the method implemented by the embodiments of the present invention shown in FIG. 1 to FIG.
- the memory configuration apparatus provided by the embodiment of the present invention may be used to implement the method implemented by the embodiments of the present invention shown in FIG. 1 to FIG.
- FIGS. 6 For the convenience of description, only parts related to the embodiments of the present invention are shown. Without specific details, please refer to the embodiments of the present invention shown in FIGS.
- the memory configuration device may be a hardware device such as a BMU.
- the present invention does not impose any limitation on this, and all hardware products that can meet the computing power requirements are applicable.
- the memory configuration apparatus includes:
- the statistic unit 11 is configured to count the number of buffers in the local memory pool to be idle, and the number of buffers to be configured in the local memory pool is N, and each storage block includes M buffers, N ⁇ 0, M>0, 0 ⁇ J ⁇ N*M;
- the application unit 12 is configured to apply, from the common memory pool, at least one storage block to the local memory pool to be configured until the J is smaller than the first threshold, until the buffer in the local memory pool to be configured is in an idle state.
- the number is equal to or greater than the first threshold
- the release unit 13 is configured to: when J is greater than the second threshold, release at least one storage block from the local memory pool to be configured to the common memory pool, until the buffer in the local memory pool to be configured is in an idle state
- the number is equal to or smaller than the second threshold, and the second threshold is greater than the first threshold.
- the application unit 12 is specifically configured to: apply for the first storage block from the common memory pool to the local memory pool to be configured, and the first storage block is any storage in the common memory pool. Blocking the first memory block into M buffers; C. Counting the number of buffers in the current local memory pool to be configured in an idle state; if the current local memory pool to be configured is in the current If the number of buffers in the idle state is less than the first threshold, steps A, B, and C are performed cyclically until the to-be-configured The number of buffers in the local memory pool that are in an idle state is equal to or greater than the first threshold.
- the releasing unit 13 is specifically configured to: D: release the second storage block from the local memory pool to be configured to the common memory pool, where the second storage block is the local memory pool to be configured The number of buffers in the idle state in the current local memory pool to be configured; and the number of buffers in the current local memory pool in the idle state is greater than the number of buffers in the idle state.
- the second threshold is performed, and steps D and E are performed cyclically until the number of buffers in the idle state in the local memory pool to be configured is equal to or smaller than the second threshold.
- the device stores, in the device, an identifier of a W buffer in an idle state in the local memory pool to be configured, where W ⁇ J;
- the releasing unit 13 is configured to: release the at least one first buffer to the local memory pool to be configured according to the identifier of the at least one first buffer in the W buffers In the third storage block in which the first buffer is located, the buffers in the at least one first buffer and the third storage block are in an idle state; and the release is performed from the local memory pool to be configured.
- the third storage block is to the common memory pool.
- the apparatus further includes a determining unit 14, wherein
- the statistic unit 11 is further configured to: in the storage block corresponding to the second buffer in the local memory pool to be configured, whether the buffer other than the second buffer is in an idle state, the first The second buffer is any one of the W buffers;
- the determining unit 14 is configured to determine the second buffer as the first buffer if the other buffers are in an idle state.
- the device further includes:
- the configuration unit 15 is configured to divide a storage space of a predetermined size in the memory into the common memory pool, where the common memory pool includes Z storage blocks, Z ⁇ N.
- an embodiment of the present invention provides a memory configuration apparatus 01, which may be a hardware device such as a BMU, where the memory configuration apparatus 01 includes: a processor, a memory, a bus, and a communication interface; The storage computer executes the instruction, and the processor is connected to the memory through the bus.
- the processor executes the computer execution instruction stored in the memory, so that the memory configuration device 01 executes as shown in FIG. 2 .
- the memory configuration method described in any of FIG. 5. For a specific memory configuration method, refer to the related description in the foregoing embodiment shown in any one of FIG. 2 to FIG. 5, and details are not described herein again.
- FIG. 2 a schematic structural diagram of a memory configuration system according to an embodiment of the present invention is provided.
- the system includes any of the foregoing memory configuration devices 01, and a memory 02 connected to the memory configuration device 01.
- the memory 02 includes a common memory pool and at least one local memory pool to be configured.
- the memory configuration system provided by the embodiment of the present invention can be used to implement the method implemented by the embodiments of the present invention shown in FIG. 1 to FIG. Let me repeat.
- the embodiment of the present invention provides a memory configuration apparatus and system, wherein the memory configuration device counts J buffers in an idle state in a local memory pool to be configured, and the local memory pool to be configured includes N storage blocks, each of which The memory block includes M buffers, N ⁇ 0, M>0, 0 ⁇ J ⁇ N*M; if J is less than the first threshold, the memory configuration device applies at least one memory block from the common memory pool to be configured.
- the local memory pool until the number of buffers in the local memory pool to be idle is equal to or greater than the first threshold; if J is greater than the second threshold, the memory configuration device releases at least one memory block from the local memory pool to be configured to The public memory pool, until the number of buffers in the local memory pool to be idle is equal to or less than the second threshold.
- the local memory pool to be configured can apply for the memory block released by other memory pools from the common memory pool through the memory configuration device, and release the free memory block to the public memory pool, so that the released memory block can also be According to the application of other local memory pools, it is recycled by other local memory pools to avoid the proportional relationship between the size of each buffer in the memory when allocating memory.
- the solution of the present invention can also improve the sharing rate of the storage block in the multi-standard operation scenario. Increase the utilization of storage resources across the entire memory.
- the disclosed system, apparatus, and method may be implemented in other manners.
- the device embodiments described above are merely illustrative.
- the division of the modules or units is only a logical function division.
- there may be another division manner for example, multiple units or components may be used. Combinations can be integrated into another system, or some features can be ignored or not executed.
- the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
- each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
- the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
- the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
- the technical solution of the present invention which is essential or contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in a storage medium. , including several instructions All or part of the steps of the method of the various embodiments of the present invention are performed by a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor.
- the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System (AREA)
Abstract
一种内存配置方法、装置及系统,涉及数据存储领域,提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。该方法包括:待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,内存配置装置统计该待配置本地内存池内处于空闲状态的J个缓冲区;若J小于第一阈值,该内存配置装置则从公共内存池中申请至少一个存储块至该待配置本地内存池,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于该第一阈值;若J大于第二阈值,该内存配置装置则从该待配置本地内存池中释放至少一个存储块至该公共内存池,直至该待配置本地内存池内处于空闲状态的缓冲区个数等于或小于该第二阈值。
Description
本发明涉及数据存储领域,尤其涉及一种内存配置方法、装置及系统。
目前,通用的内存配置方法是将内存,例如DDR(Double Data Rate SDRAM,双倍速率同步动态随机存储器)划分为若干个内存池(Memory Pool),每个内存池内部放置若干相同长度的存储块,在申请内存和释放内存的过程中,最小单位为一块“存储块”。
以处理器、DDR、BMU(buffer management unit,缓冲区管理单元)以及其他功能模块组成的操作系统为例,处理器和其他功能模块在某种制式下(例如2G网络)分别使用的内存大小通常是在一定范围内变化不大的,因此,BMU可以预先配置各个内存池中的存储块之间的比例关系,使内存池中的存储块可以分时或同时的被处理器或其他功能模块使用。
例如,如图1所示,在使用内存前,BMU配置Y块的存储块供处理器以及其他功能模块使用,每个内存块的大小为4X字节(即以X字节为粒度配置Pool A、Pool B、Pool C中存储块大小的比例关系),那么,在向处理器、功能模块1和功能模块2分配内存时,BMU分别从Pool A、Pool B、Pool C中申请相应大小的存储块,设Pool A的存储块长度为X字节、Pool B的存储块长度为2X字节、Pool C的存储块长度为4X字节,则Pool A、Pool B、Pool C的存储块大小比例为1:2:4,也就是说,不同内存池中存储块的大小需要尽量接近一定的比例关系。
而在3G网络下工作时,由于处理器、功能模块1和功能模块2在处理数据时粒度可能发生改变,例如,处理器、功能模块1和功能模块2在处理数据时粒度为Y(Y>X)字节,处理器、功能模块1
和功能模块2所需的存储块大小的比例关系为1:3:5,但是,此时Pool A、Pool B、Pool C中存储块大小的比例关系仍然为1:2:4,BMU只能按照配置好的存储块大小的比例关系分配存储块,进而导致在多制式的操作场景下存储块的共享率降低,并使整个内存中存储资源的利用率降低。
发明内容
本发明的实施例提供一种内存配置方法、装置及系统,可提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
为达到上述目的,本发明的实施例采用如下技术方案:
第一方面,本发明的实施例提供一种内存配置方法,该内存中包含公共内存池以及至少一个本地内存池,该方法包括:至少一个本地内存池中的待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,该内存配置装置统计该待配置本地内存池内处于空闲状态的缓冲区的个数为J,N≥0,M>0,0≤J≤N*M;若J小于第一阈值,该内存配置装置则从该公共内存池中申请至少一个存储块至该待配置本地内存池,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于该第一阈值;若J大于第二阈值,该内存配置装置则从该待配置本地内存池中释放至少一个存储块至该公共内存池,直至该待配置本地内存池内处于空闲状态的缓冲区个数等于或小于该第二阈值,其中,该第二阈值大于该第一阈值。
可以看出,待配置本地内存池可以通过内存配置装置从公共内存池中申请其他内存池释放的内存块,并将自身空闲的内存块释放至公共内存池,这样,被释放的内存块还可以根据其他本地内存池的申请,被其他本地内存池循环利用,可避免分配内存时对内存中各个缓冲区大小的比例关系限制,同时,由于不同内存池可分别用于不同制式的操作场景,因此,本发明方案还可以提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
结合第一方面,在第一方面的第一种可能的实现方式中,该内
存配置装置则从该公共内存池中申请至少一个存储块至该待配置本地内存池,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于该第一阈值,包括:A、该内存配置装置从公共内存池中申请第一存储块至该待配置本地内存池,该第一存储块为该公共内存池中的任意存储块;B、该内存配置装置将该第一存储块划分为M个缓冲区;C、该内存配置装置统计当前的该待配置本地内存池内处于空闲状态的缓冲区个数;若当前的该待配置本地内存池内处于空闲状态的缓冲区个数小于该第一阈值,则该内存配置装置循环执行步骤A、B和C,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于该第一阈值。
结合第一方面,在第一方面的第二种可能的实现方式中,该内存配置装置则从该待配置本地内存池中释放至少一个存储块至该公共内存池,直至该待配置本地内存池内处于空闲状态的缓冲区个数等于或小于该第二阈值,包括:D、该内存配置装置从该待配置本地内存池中释放第二存储块至该公共内存池,该第二存储块为该待配置本地内存池中的处于空闲状态的存储块;E、该内存配置装置统计当前的该待配置本地内存池内处于空闲状态的缓冲区个数;若当前的该待配置本地内存池内处于空闲状态的缓冲区个数大于该第二阈值,则该内存配置装置循环执行步骤D和E,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或小于该第二阈值。
结合第一方面以及第一方面的第一至第二种可能的实现方式中的任一种实现方式,在第一方面的第三种可能的实现方式中,该内存配置装置中存储有该待配置本地内存池中处于空闲状态的W个缓冲区的标识,W≤J;其中,该内存配置装置统计该待配置本地内存池内处于空闲状态的J个缓冲区,包括:该内存配置装置计算在该内存配置装置中的缓冲区的个数W,与在该内存中该待配置本地内存池内处于空闲状态的缓冲区的个数Q之和,其中,J=W+Q。
这样一来,当内存配置装置为某软件从该待配置本地内存池中分配空闲的缓冲区时,内存配置装置可以直接将自身存储的处于空
闲状态的缓冲区的标识分配给该软件,而无需从内存中的该待配置本地内存池中查询并确定处于空闲状态的缓冲区,进而加速内存配置装置申请缓冲区的速度。
结合第一方面的第三种可能的实现方式中的任一种实现方式,在第一方面的第四种可能的实现方式中,该内存配置装置则从该待配置本地内存池中释放至少一个存储块至该公共内存池,直至该待配置本地内存池内处于空闲状态的缓冲区个数等于或小于该第二阈值,包括:该内存配置装置根据该W个缓冲区中至少一个第一缓冲区的标识,将该至少一个第一缓冲区释放至该待配置本地内存池中该第一缓冲区所处的第三存储块中,该至少一个第一缓冲区与该第三存储块内的缓冲区均处于空闲状态;该内存配置装置从该待配置本地内存池中释放该第三存储块至该公共内存池。
结合第一方面的第四种可能的实现方式中的任一种实现方式,在第一方面的第五种可能的实现方式中,在该内存配置装置根据该W个缓冲区中第一缓冲区的标识,将该第一缓冲区释放至该内存中与该第一缓冲区对应的第三存储块之前,还包括:该内存配置装置统计在该待配置本地内存池中与第二缓冲区对应的存储块内,除该第二缓冲区外的其他缓冲区是否处于空闲状态,该第二缓冲区为该W个缓冲区中的任一个;若该其他缓冲区均处于空闲状态,该内存配置装置则将该第二缓冲区确定为该第一缓冲区。
结合第一方面以及第一方面的第一至第五种可能的实现方式中的任一种实现方式,在第一方面的第六种可能的实现方式中,在内存配置装置统计内存中待配置本地内存池内处于空闲状态的J个缓冲区之前,还包括:该内存配置装置将该内存中预定大小的存储空间划分为该公共内存池,该公共内存池包含Z个存储块,Z≥N。
第二方面,本发明的实施例提供一种内存配置装置,该内存配置装置与内存相连,该内存中包含公共内存池以及至少一个待配置本地内存池,该装置包括:统计单元,用于统计该至少一个本地内存池中的待配置本地内存池内处于空闲状态的缓冲区的个数为J,
该待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;;申请单元,用于若J小于第一阈值,则从该公共内存池中申请至少一个存储块至该待配置本地内存池,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于该第一阈值;释放单元,用于若J大于第二阈值,则从该待配置本地内存池中释放至少一个存储块至该公共内存池,直至该待配置本地内存池内处于空闲状态的缓冲区个数等于或小于该第二阈值,该第二阈值大于该第一阈值。
可以看出,待配置本地内存池可以通过内存配置装置从公共内存池中申请其他内存池释放的内存块,并将自身空闲的内存块释放至公共内存池,这样,被释放的内存块还可以根据其他本地内存池的申请,被其他本地内存池循环利用,可避免分配内存时对内存中各个缓冲区大小的比例关系限制,同时,由于不同内存池可分别用于不同制式的操作场景,因此,本发明方案还可以提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
结合第二方面,在第二方面的第一种可能的实现方式中,该申请单元,具体用于:A、从公共内存池中申请第一存储块至该待配置本地内存池,该第一存储块为该公共内存池中的任意存储块;B、将该第一存储块划分为M个缓冲区;C、统计当前的该待配置本地内存池内处于空闲状态的缓冲区个数;若当前的该待配置本地内存池内处于空闲状态的缓冲区个数小于该第一阈值,则循环执行步骤A、B和C,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于该第一阈值。
结合第二方面,在第二方面的第二种可能的实现方式中,该释放单元,具体用于:D、从该待配置本地内存池中释放第二存储块至该公共内存池,该第二存储块为该待配置本地内存池中的处于空闲状态的存储块;E、统计当前的该待配置本地内存池内处于空闲状态的缓冲区个数;若当前的该待配置本地内存池内处于空闲状态的缓冲区个数大于该第二阈值,则循环执行步骤D和E,直至该待配置
本地内存池中处于空闲状态的缓冲区个数等于或小于该第二阈值。
结合第二方面以及第二方面的第一至第二种可能的实现方式中的任一种实现方式,在第二方面的第三种可能的实现方式中,该装置中存储有该待配置本地内存池中处于空闲状态的W个缓冲区的标识,W≤J;其中,该统计单元,具体用于计算在该内存配置装置中的缓冲区的个数W,与在该内存中该待配置本地内存池内处于空闲状态的缓冲区的个数Q之和,其中,J=W+Q。
结合第二方面的第三种可能的实现方式,在第二方面的第四种可能的实现方式中,该释放单元,具体用于:根据该W个缓冲区中至少一个第一缓冲区的标识,将该至少一个第一缓冲区释放至该待配置本地内存池中该第一缓冲区所处的第三存储块中,该至少一个第一缓冲区与该第三存储块内的缓冲区均处于空闲状态;从该待配置本地内存池中释放该第三存储块至该公共内存池。
结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,该装置还包括确定单元,其中,该统计单元,还用于统计在该待配置本地内存池中与第二缓冲区对应的存储块内,除该第二缓冲区外的其他缓冲区是否处于空闲状态,该第二缓冲区为该W个缓冲区中的任一个;该确定单元,用于若该其他缓冲区均处于空闲状态,则将该第二缓冲区确定为该第一缓冲区。
结合第二方面以及第二方面的第一至第五种可能的实现方式中的任一种实现方式,在第二方面的第六种可能的实现方式中,该装置还包括:配置单元,用于将该内存中预定大小的存储空间划分为该公共内存池,该公共内存池包含Z个存储块,Z≥N。
结合第二方面以及第二方面的第一至第六种可能的实现方式中的任一种实现方式,在第二方面的第七种可能的实现方式中,该装置可以为BMU。
第三方面,本发明的实施例还提供一种内存配置装置,其中,该内存配置装置包括:处理器、存储器、总线和通信接口;该存储器用于存储计算机执行指令,该处理器与该存储器通过该总线连接,
当该内存配置装置运行时,该处理器执行该存储器存储的该计算机执行指令,以使该内存配置装置执行如第一方面中任意之一所述的内存配置方法。
第四方面,本发明的实施例还提供一种内存配置系统,包括第二方面中任一项所述的内存配置装置,以及与该内存配置装置相连的内存,该内存中包含公共内存池以及至少一个本地内存池。
本发明的实施例提供一种内存配置方法、装置及系统,其中,内存配置装置统计待配置本地内存池内处于空闲状态的J个缓冲区,该待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;若J小于第一阈值,内存配置装置则从公共内存池中申请至少一个存储块至待配置本地内存池,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值;若J大于第二阈值,内存配置装置则从待配置本地内存池中释放至少一个存储块至公共内存池,直至待配置本地内存池内处于空闲状态的缓冲区个数等于或小于第二阈值。可以看出,待配置本地内存池可以通过内存配置装置从公共内存池中申请其他内存池释放的内存块,并将自身空闲的内存块释放至公共内存池,这样,被释放的内存块还可以根据其他本地内存池的申请,被其他本地内存池循环利用,可避免分配内存时对内存中各个缓冲区大小的比例关系限制,同时,由于不同内存池可分别用于不同制式的操作场景,因此,本发明方案还可以提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。
图1为现有技术中BMU进行内存分配的示意图;
图2为本发明实施例提供的内存配置系统的系统架构图;
图3为本发明实施例提供的存储块的结构示意图一;
图4为本发明实施例提供的一种内存配置方法的流程示意图;
图5为本发明实施例提供的存储块的结构示意图二;
图6为本发明实施例提供的一种内存配置装置的结构示意图一;
图7为本发明实施例提供的一种内存配置装置的结构示意图二;
图8为本发明实施例提供的一种内存配置装置的结构示意图三。
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。
另外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本发明的描述中,除非另有说明,“多个”的含义是两个或两个以上。
具体的,本发明实施例提供的内存配置方法可应用于内存配置系统,如图2所示,该内存配置系统中可以包括内存配置装置01,该内存配置装置01可以为BMU等硬件设备,并且,该内存配置装置01与内存02相连,该内存02中包含公共内存池以及至少一个本地内存池,另外,该内存配置系统中还可以包括处理器03,例如至少一个CPU等,内存配置装置01、内存02以及处理器03通过总线04通信,这样,内存配置装置01可以专门用于管理内存02中存储空间的申请和释放,减轻处理器03的负载。
另外需要说明的是,该内存02中包含的公共内存池和至少一个本地内存池可以为逻辑内存池或者物理内存池,本发明实施例对此不做限定,其中,该公共内存池和每个本地内存池中内可以包含多个存储块,每个存储块均为固定大小。例如,在内存配置装置01在管理内存02中存储空间的申请和释放之前,可以先将内存02中预
定大小的存储空间(例如,Z个存储块大小,Z>0)划分为公共内存池。
进一步地,如图3所示,一个存储块(block)中可以包含多个缓冲区(buffer),不同本地内存池中的buffer的大小可能不一,所以不同存储块中装的缓冲区的个数不同,那么,存储块的尾部可以有少许空闲内存无法被利用,即形成尾部碎片。
另外,不同的本地内存池,可以分别对应不同的制式(例如,本地内存池1对应2G网络制式,本地内存池2对应3G网络制式,本地内存池3对应4G网络制式等),或者,不同的本地内存池,也可以分别对应不同类型的软件(例如,本地内存池1对应视频类软件,本地内存池2对应即时通信类软件等),这是由于,不同本地内存池中存储块的缓冲区的大小可能不一致,而不同制式或不同类型软件所使用的内存的粒度也存在差别,例如,在2G网络制式下通常用于处理语音包等小包数据,而本地内存池1中存储块内的缓冲区的大小比较小,因此,在2G网络制式下使用本地内存池1中的存储块可提高内存的利用率。
具体的,为方便描述,以下以至少一个本地内存池中的任一个本地内存池(即待配置本地内存池)举例进行说明,如图4所示,本发明实施例提供的一种内存配置方法,包括下述步骤101-103。
步骤101、内存配置装置统计待配置本地内存池内处于空闲状态的J个缓冲区,该待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M。
步骤102、若J小于第一阈值,内存配置装置则从公共内存池中申请至少一个存储块至该待配置本地内存池,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值。
步骤103、若J大于第二阈值,内存配置装置则从待配置本地内存池中释放至少一个存储块至该公共内存池,直至待配置本地内存池内处于空闲状态的缓冲区个数等于或小于第二阈值。
在步骤101中,由于各个本地内存池内包含有N个存储块,而
每个存储块可划分为大小一定的M个缓冲区,当不同软件在运行时会向相应的本地内存池(例如待配置本地内存池)中申请若干个缓冲区进行数据处理等任务,此时,待配置本地内存池内的部分缓冲区被占用,而未被占用的缓冲区即为处于空闲状态的缓冲区。
而内存配置装置可以定期的统计待配置本地内存池(例如本地内存池1)内处于空闲状态的缓冲区的个数,得到待配置本地内存池1内处于空闲状态的J个缓冲区。
需要说明的是,待配置本地内存池中的各个存储块都有自己的标识,例如存储块的地址,用于表示每个存储块在内存中的位置。相应的,每个存储块的缓冲区也有自己的标识,例如缓冲区的地址,用于表示每个缓冲区在相应存储块中的位置,或者,直接用于指示该缓冲区在内存中的位置。
在步骤102中,若步骤101中得到的处于空闲状态的缓冲区的个数J小于第一阈值,即说明该待配置本地内存池中未被占用的缓冲区的个数较少,而大多数缓冲区已经被占用,此时,内存配置装置可以从公共内存池中申请至少一个存储块至该待配置本地内存池,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值。
具体的,若J小于第一阈值时,内存配置装置可首先从公共内存池中申请第一存储块至该待配置本地内存池,该第一存储块为公共内存池中的任意一个存储块;此时,内存配置装置按照预置的缓冲区的大小,将该第一存储块划分为M个缓冲区;进而,内存配置装置统计当前的待配置本地内存池内处于空闲状态的缓冲区个数;若当前的待配置本地内存池内处于空闲状态的缓冲区个数仍小于该第一阈值,则内存配置装置可循环执行上述步骤,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值,以保证该待配置本地内存池中有足够的处于空闲状态的缓冲区可提供给各个软件使用,从而提高存储资源的利用率。
相应的,在步骤103中,若步骤101中得到的处于空闲状态的
缓冲区的个数J大于第二阈值,即说明该待配置本地内存池中未被占用的缓冲区的个数较多,为了避免存储资源浪费,此时,内存配置装置可以从该待配置本地内存池中释放至少一个存储块至该公共内存池,直至该待配置本地内存池内处于空闲状态的缓冲区个数等于或小于第二阈值,其中,该第二阈值大于上述第一阈值。
具体的,若J大于第二阈值时,内存配置装置首先从该待配置本地内存池中释放第二存储块至公共内存池,该第二存储块为待配置本地内存池中的处于空闲状态的存储块;进而,内存配置装置统计当前的待配置本地内存池内处于空闲状态的缓冲区个数;若当前的待配置本地内存池内处于空闲状态的缓冲区个数仍大于第二阈值,则内存配置装置循环执行上述步骤,直至该待配置本地内存池中处于空闲状态的缓冲区个数等于或小于第二阈值。这样一来,从该待配置本地内存池中释放至公共内存池的第二存储块可以被其他待配置本地内存池申请使用,从而提高存储资源的利用率。
例如,待配置本地内存池1内处于空闲状态的缓冲区的个数J大于第二阈值,内存配置装置从该待配置本地内存池1中释放存储块1至公共内存池后,待配置本地内存池1内处于空闲状态的缓冲区的个数J小于该第二阈值,此时,待配置本地内存池2内处于空闲状态的缓冲区的个数J小于第一阈值,那么,内存配置装置可以从公共内存池中取出该存储块1至待配置本地内存池2中,进而将该存储块1划分为P(P>0)个缓冲区进行使用,若待配置本地内存池1对应于2G网络制式的操作场景,而待配置本地内存池2对应于3G网络制式的操作场景,那么可以看出,被释放至公共内存池的存储块1可以跨制式实现内存共享,并且不需要对缓冲区的大小做特定的比例限制。
需要说明的是,本发明实施例中涉及的第一阈值和第二阈值均可由本领域技术人员根据实际经验或特定算法进行预先设置,本发明实施例对此不做限定。
至此,本发明的实施例提供一种内存配置方法,其中,内存配
置装置统计待配置本地内存池内处于空闲状态的J个缓冲区,该待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;若J小于第一阈值,内存配置装置则从公共内存池中申请至少一个存储块至待配置本地内存池,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值;若J大于第二阈值,内存配置装置则从待配置本地内存池中释放至少一个存储块至公共内存池,直至待配置本地内存池内处于空闲状态的缓冲区个数等于或小于第二阈值。可以看出,待配置本地内存池可以通过内存配置装置从公共内存池中申请其他内存池释放的内存块,并将自身空闲的内存块释放至公共内存池,这样,被释放的内存块还可以根据其他本地内存池的申请,被其他本地内存池循环利用,可避免分配内存时对内存中各个缓冲区大小的比例关系限制,同时,由于不同内存池可分别用于不同制式的操作场景,因此,本发明方案还可以提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
进一步地,在内存配置装置中还可以设有存储区,可将待配置本地内存池中处于空闲状态的W(W≤J)个缓冲区的标识存储在内存配置装置内的存储区中,例如,内存配置装置可将若干个空闲的缓冲区的标识放置在LIFO(Last In First Out,后进先出)堆栈中,这样一来,当内存配置装置为某软件从该待配置本地内存池中分配空闲的缓冲区时,内存配置装置可以直接将自身存储的处于空闲状态的缓冲区的标识分配给该软件,并标记该分配后的缓冲区为已占用状态,而无需从内存中的该待配置本地内存池中查询并确定处于空闲状态的缓冲区,进而加速内存配置装置申请缓冲区的速度。
然而,在上述过程中,由于待配置本地内存池中处于空闲状态的W个缓冲区的标识存储在内存配置装置内的存储区中,因此,对于内存来说,这W个缓冲区已经被占用了,但这W个缓冲区实质上只是被内存配置装置暂时占用,而并非真正被该软件使用,该软件仍然可以使用这W个缓冲区。
这样一来,在执行上述步骤101-103的内存配置方法时,在步骤101中,内存配置装置在统计待配置本地内存池内处于空闲状态的J个缓冲区时,具体包括:统计位于内存配置装置内的缓冲区的标识个数,即W个,以及在内存中的该待配置本地内存池内处于空闲状态的缓冲区的个数Q(Q≥0)之和,其中,J=W+Q。
进而,与步骤102相同的,若J小于第一阈值,内存配置装置则从公共内存池中申请至少一个存储块至该待配置本地内存池,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值。
而在步骤103中,若J大于第二阈值,内存配置装置则从待配置本地内存池中释放至少一个存储块至该公共内存池,此时,若该待配置本地内存池中某个存储块内所有的M个缓冲区的标识均不在该内存配置装置,且这M个缓冲区均处于空闲状态是时,内存配置装置可直接将该存储块释放至该公共内存池中。
但是,在经过多次存储块申请和存储块释放后,LIFO堆栈内的W个缓冲区的标识往往属于多个不同的存储块,如图5所示,对于内存中待配置本地内存池内的存储块1来说,缓冲区101-108均为空闲状态,而缓冲区109和110位于内存配置装置的LIFO堆栈内,即存储块1中的所有缓冲区为空闲状态,但是对于内存中的该待配置本地内存池内而言,其认为缓冲区109和110已被占用,由于本发明实施例中内存配置装置需要以存储块为单位进行存储块的申请和释放,因此会导致存储块1在步骤103中无法被释放至公共内存池,并共享给其他制式的待配置本地内存池。
为解决上述问题,在执行步骤103时,若J大于第二阈值,内存配置装置可以先根据该W个缓冲区中的至少一个第一缓冲区的标识,将该至少一个第一缓冲区释放至待配置本地内存池中该第一缓冲区所处的第三存储块中,其中,该第一缓冲区与该第三存储块内的其他缓冲区均处于空闲状态;进而,内存配置装置再从该待配置本地内存池中释放该第三存储块至公共内存池。
具体的,内存配置装置可以先统计该LIFO堆栈中W个缓冲区的标识所对应的每一个缓冲区在待配置本地内存池中所处的存储块的占用情况,以W个缓冲区中的第二缓冲区为例,若在该待配置本地内存池中与第二缓冲区对应的存储块3内,除该第二缓冲区外的其他缓冲区均处于空闲状态,内存配置装置则将该第二缓冲区确定为上述第一缓冲区,进而,内存配置装置根据该第一缓冲区的标识,将该第一缓冲区释放至内存中与该第一缓冲区对应的存储块3中,再从该待配置本地内存池中释放该存储块3至公共内存池。
示例性的,如图5所示,内存配置装置可统计该LIFO堆栈中每一个缓冲区的标识所对应的存储块的占用情况,若确定缓冲区109和缓冲区110所对应的存储块1中,缓冲区101-108均为空闲状态,内存配置装置则可以将该缓冲区109和缓冲区110确定为上述第一缓冲区,进而,内存配置装置根据缓冲区109的标识和缓冲区110的标识,将该缓冲区109和缓冲区110释放至内存中的存储块1中,再从待配置本地内存池中释放该存储块3至公共内存池。这样一来,从该待配置本地内存池中释放至公共内存池的存储块3可以被其他待配置本地内存池申请使用,从而提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
至此,本发明的实施例提供一种内存配置方法,其中,内存配置装置统计待配置本地内存池内处于空闲状态的J个缓冲区,该待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;若J小于第一阈值,内存配置装置则从公共内存池中申请至少一个存储块至待配置本地内存池,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值;若J大于第二阈值,内存配置装置则从待配置本地内存池中释放至少一个存储块至公共内存池,直至待配置本地内存池内处于空闲状态的缓冲区个数等于或小于第二阈值。可以看出,待配置本地内存池可以通过内存配置装置从公共内存池中申请其他内存池释放的内存块,并将自身空闲的内存块释放至公共内存池,这样,被释放的内
存块还可以根据其他本地内存池的申请,被其他本地内存池循环利用,可避免分配内存时对内存中各个缓冲区大小的比例关系限制,同时,由于不同内存池可分别用于不同制式的操作场景,因此,本发明方案还可以提高多制式的操作场景下存储块的共享率,使整个内存中存储资源的利用率升高。
另外,图6为本发明实施例提供的一种内存配置装置的结构示意图,本发明实施例提供的内存配置装置可以用于实施上述图1-图5所示的本发明各实施例实现的方法,为了便于说明,仅示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照图1-图5所示的本发明各实施例。
其中,该内存配置装置可以为BMU等硬件设备,本发明对此不作任何限制,可满足运算能力需求的所有硬件产品都适用。
具体的,如图6所示,该内存配置装置包括:
统计单元11,用于统计待配置本地内存池内处于空闲状态的缓冲区的个数为J,所述待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;
申请单元12,用于若J小于第一阈值,则从所述公共内存池中申请至少一个存储块至所述待配置本地内存池,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值;
释放单元13,用于若J大于第二阈值,则从所述待配置本地内存池中释放至少一个存储块至所述公共内存池,直至所述待配置本地内存池内处于空闲状态的缓冲区个数等于或小于所述第二阈值,所述第二阈值大于所述第一阈值。
进一步地,所述申请单元12,具体用于:A、从公共内存池中申请第一存储块至所述待配置本地内存池,所述第一存储块为所述公共内存池中的任意存储块;B、将所述第一存储块划分为M个缓冲区;C、统计当前的所述待配置本地内存池内处于空闲状态的缓冲区个数;若当前的所述待配置本地内存池内处于空闲状态的缓冲区个数小于所述第一阈值,则循环执行步骤A、B和C,直至所述待配置
本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值。
进一步地,所述释放单元13,具体用于:D、从所述待配置本地内存池中释放第二存储块至所述公共内存池,所述第二存储块为所述待配置本地内存池中的处于空闲状态的存储块;E、统计当前的所述待配置本地内存池内处于空闲状态的缓冲区个数;若当前的所述待配置本地内存池内处于空闲状态的缓冲区个数大于所述第二阈值,则循环执行步骤D和E,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或小于所述第二阈值。
进一步地,所述装置中存储有所述待配置本地内存池中处于空闲状态的W个缓冲区的标识,W≤J;其中,
所述统计单元11,具体用于计算在所述内存配置装置中的缓冲区的个数W,与在所述内存中所述待配置本地内存池内处于空闲状态的缓冲区的个数Q之和,其中,J=W+Q。
进一步地,所述释放单元13,具体用于:根据所述W个缓冲区中至少一个第一缓冲区的标识,将所述至少一个第一缓冲区释放至所述待配置本地内存池中所述第一缓冲区所处的第三存储块中,所述至少一个第一缓冲区与所述第三存储块内的缓冲区均处于空闲状态;从所述待配置本地内存池中释放所述第三存储块至所述公共内存池。
进一步地,如图7所示,所述装置还包括确定单元14,其中
所述统计单元11,还用于统计在所述待配置本地内存池中与第二缓冲区对应的存储块内,除所述第二缓冲区外的其他缓冲区是否处于空闲状态,所述第二缓冲区为所述W个缓冲区中的任一个;
所述确定单元14,用于若所述其他缓冲区均处于空闲状态,则将所述第二缓冲区确定为所述第一缓冲区。
进一步地,如图8所示,所述装置还包括:
配置单元15,用于将所述内存中预定大小的存储空间划分为所述公共内存池,所述公共内存池包含Z个存储块,Z≥N。
相应的,本发明的实施例提供还一种内存配置装置01,该内存配置装置可以为BMU等硬件设备,其中,该内存配置装置01包括:处理器、存储器、总线和通信接口;该存储器用于存储计算机执行指令,该处理器与该存储器通过该总线连接,当该内存配置装置01运行时,该处理器执行该存储器存储的该计算机执行指令,以使该内存配置装置01执行如图2-图5任意之一所述的内存配置方法。具体的内存配置方法可参见上述如图2-图5任意之一所示的实施例中的相关描述,此处不再赘述。
进一步地,本发明实施例还提供的一种内存配置系统的结构示意图,具体可参见图2,该系统包括上述任一种内存配置装置01,以及与该内存配置装置01相连的内存02,该内存02中包含公共内存池以及至少一个待配置本地内存池,本发明实施例提供的内存配置系统可以用于实施上述图1-图5所示的本发明各实施例实现的方法,故此处不再赘述。
至此,本发明的实施例提供一种内存配置装置及系统,其中,内存配置装置统计待配置本地内存池内处于空闲状态的J个缓冲区,该待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;若J小于第一阈值,内存配置装置则从公共内存池中申请至少一个存储块至待配置本地内存池,直至待配置本地内存池中处于空闲状态的缓冲区个数等于或大于第一阈值;若J大于第二阈值,内存配置装置则从待配置本地内存池中释放至少一个存储块至公共内存池,直至待配置本地内存池内处于空闲状态的缓冲区个数等于或小于第二阈值。可以看出,待配置本地内存池可以通过内存配置装置从公共内存池中申请其他内存池释放的内存块,并将自身空闲的内存块释放至公共内存池,这样,被释放的内存块还可以根据其他本地内存池的申请,被其他本地内存池循环利用,可避免分配内存时对内存中各个缓冲区大小的比例关系限制,同时,由于不同内存池可分别用于不同制式的操作场景,因此,本发明方案还可以提高多制式的操作场景下存储块的共享率,
使整个内存中存储资源的利用率升高。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用
以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。
Claims (16)
- 一种内存配置方法,其特征在于,所述内存中包含公共内存池以及至少一个本地内存池,所述方法包括:所述内存配置装置统计所述至少一个本地内存池中的待配置本地内存池内处于空闲状态的缓冲区的个数为J,所述待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;若J小于第一阈值,所述内存配置装置则从所述公共内存池中申请至少一个存储块至所述待配置本地内存池,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值;若J大于第二阈值,所述内存配置装置则从所述待配置本地内存池中释放至少一个存储块至所述公共内存池,直至所述待配置本地内存池内处于空闲状态的缓冲区个数等于或小于所述第二阈值,所述第二阈值大于所述第一阈值。
- 根据权利要求1所述的方法,其特征在于,所述内存配置装置则从所述公共内存池中申请至少一个存储块至所述待配置本地内存池,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值,包括:A、所述内存配置装置从公共内存池中申请第一存储块至所述待配置本地内存池,所述第一存储块为所述公共内存池中的任意存储块;B、所述内存配置装置将所述第一存储块划分为M个缓冲区;C、所述内存配置装置统计当前的所述待配置本地内存池内处于空闲状态的缓冲区个数;若当前的所述待配置本地内存池内处于空闲状态的缓冲区个数小于所述第一阈值,则所述内存配置装置循环执行步骤A、B和C,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值。
- 根据权利要求1所述的方法,其特征在于,所述内存配置装 置则从所述待配置本地内存池中释放至少一个存储块至所述公共内存池,直至所述待配置本地内存池内处于空闲状态的缓冲区个数等于或小于所述第二阈值,包括:D、所述内存配置装置从所述待配置本地内存池中释放第二存储块至所述公共内存池,所述第二存储块为所述待配置本地内存池中的处于空闲状态的存储块;E、所述内存配置装置统计当前的所述待配置本地内存池内处于空闲状态的缓冲区个数;若当前的所述待配置本地内存池内处于空闲状态的缓冲区个数大于所述第二阈值,则所述内存配置装置循环执行步骤D和E,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或小于所述第二阈值。
- 根据权利要求1-3中任一项所述的方法,其特征在于,所述内存配置装置中存储有所述待配置本地内存池中处于空闲状态的W个缓冲区的标识,W≤J;其中,所述内存配置装置统计所述待配置本地内存池内处于空闲状态的J个缓冲区,包括:所述内存配置装置计算在所述内存配置装置中的缓冲区的个数W,与在所述内存中所述待配置本地内存池内处于空闲状态的缓冲区的个数Q之和,其中,J=W+Q。
- 根据权利要求4所述的方法,其特征在于,所述内存配置装置则从所述待配置本地内存池中释放至少一个存储块至所述公共内存池,直至所述待配置本地内存池内处于空闲状态的缓冲区个数等于或小于所述第二阈值,包括:所述内存配置装置根据所述W个缓冲区中至少一个第一缓冲区的标识,将所述至少一个第一缓冲区释放至所述待配置本地内存池中所述第一缓冲区所处的第三存储块中,所述至少一个第一缓冲区与所述第三存储块内的缓冲区均处于空闲状态;所述内存配置装置从所述待配置本地内存池中释放所述第三存 储块至所述公共内存池。
- 根据权利要求5所述的方法,其特征在于,在所述内存配置装置根据所述W个缓冲区中至少一个第一缓冲区的标识,将所述至少一个第一缓冲区释放至所述待配置本地内存池中所述第一缓冲区所处的第三存储块之前,还包括:所述内存配置装置统计在所述待配置本地内存池中与第二缓冲区对应的存储块内,除所述第二缓冲区外的其他缓冲区是否处于空闲状态,所述第二缓冲区为所述W个缓冲区中的任一个;若所述其他缓冲区均处于空闲状态,所述内存配置装置则将所述第二缓冲区确定为所述第一缓冲区。
- 根据权利要求1-6中任一项所述的方法,其特征在于,在内存配置装置统计内存中待配置本地内存池内处于空闲状态的J个缓冲区之前,还包括:所述内存配置装置将所述内存中预定大小的存储空间划分为所述公共内存池,所述公共内存池包含Z个存储块,Z≥N。
- 一种内存配置装置,其特征在于,所述内存中包含公共内存池以及至少一个本地内存池,所述装置包括:统计单元,用于统计所述至少一个本地内存池中的待配置本地内存池内处于空闲状态的缓冲区的个数为J,所述待配置本地内存池中包含N个存储块,每个存储块中包含M个缓冲区,N≥0,M>0,0≤J≤N*M;申请单元,用于若J小于第一阈值,则从所述公共内存池中申请至少一个存储块至所述待配置本地内存池,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值;释放单元,用于若J大于第二阈值,则从所述待配置本地内存池中释放至少一个存储块至所述公共内存池,直至所述待配置本地内存池内处于空闲状态的缓冲区个数等于或小于所述第二阈值,所述第二阈值大于所述第一阈值。
- 根据权利要求8所述的装置,其特征在于,所述申请单元,具体用于:A、从公共内存池中申请第一存储块至所述待配置本地内存池,所述第一存储块为所述公共内存池中的任意存储块;B、将所述第一存储块划分为M个缓冲区;C、统计当前的所述待配置本地内存池内处于空闲状态的缓冲区个数;若当前的所述待配置本地内存池内处于空闲状态的缓冲区个数小于所述第一阈值,则循环执行步骤A、B和C,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或大于所述第一阈值。
- 根据权利要求8所述的装置,其特征在于,所述释放单元,具体用于:D、从所述待配置本地内存池中释放第二存储块至所述公共内存池,所述第二存储块为所述待配置本地内存池中的处于空闲状态的存储块;E、统计当前的所述待配置本地内存池内处于空闲状态的缓冲区个数;若当前的所述待配置本地内存池内处于空闲状态的缓冲区个数大于所述第二阈值,则循环执行步骤D和E,直至所述待配置本地内存池中处于空闲状态的缓冲区个数等于或小于所述第二阈值。
- 根据权利要求8-10中任一项所述的装置,其特征在于,所述装置中存储有所述待配置本地内存池中处于空闲状态的W个缓冲区的标识,W≤J;其中,所述统计单元,具体用于计算在所述内存配置装置中的缓冲区的个数W,与在所述内存中所述待配置本地内存池内处于空闲状态的缓冲区的个数Q之和,其中,J=W+Q。
- 根据权利要求11所述的装置,其特征在于,所述释放单元,具体用于:根据所述W个缓冲区中至少一个第一缓冲区的标识,将所述至少一个第一缓冲区释放至所述待配置本地内存池中所述第一缓冲区所处的第三存储块中,所述至少一个第一缓冲区与所述第三存储块内的缓冲区均处于空闲状态;从所述待配置本地内存池中释放所述第三存储块至所述公共内存池。
- 根据权利要求12所述的装置,其特征在于,所述装置还包括确定单元,其中,所述统计单元,还用于统计在所述待配置本地内存池中与第二缓冲区对应的存储块内,除所述第二缓冲区外的其他缓冲区是否处于空闲状态,所述第二缓冲区为所述W个缓冲区中的任一个;所述确定单元,用于若所述其他缓冲区均处于空闲状态,则将所述第二缓冲区确定为所述第一缓冲区。
- 根据权利要求8-13中任一项所述的装置,其特征在于,所述装置还包括:配置单元,用于将所述内存中预定大小的存储空间划分为所述公共内存池,所述公共内存池包含Z个存储块,Z≥N。
- 根据权利要求8-14中任一项所述的装置,其特征在于,所述装置为缓冲区管理单元BMU。
- 一种内存配置系统,其特征在于,包括权利要求8-15中任一项所述的内存配置装置,以及与所述内存配置装置相连的内存,所述内存中包含公共内存池以及至少一个本地内存池。
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2015/093113 WO2017070869A1 (zh) | 2015-10-28 | 2015-10-28 | 一种内存配置方法、装置及系统 |
| CN201580083925.XA CN108139969B (zh) | 2015-10-28 | 2015-10-28 | 一种内存配置方法、装置及系统 |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2015/093113 WO2017070869A1 (zh) | 2015-10-28 | 2015-10-28 | 一种内存配置方法、装置及系统 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2017070869A1 true WO2017070869A1 (zh) | 2017-05-04 |
Family
ID=58630464
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2015/093113 Ceased WO2017070869A1 (zh) | 2015-10-28 | 2015-10-28 | 一种内存配置方法、装置及系统 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN108139969B (zh) |
| WO (1) | WO2017070869A1 (zh) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109992347A (zh) * | 2019-04-10 | 2019-07-09 | Oppo广东移动通信有限公司 | 界面显示方法、装置、终端及存储介质 |
| CN115525443A (zh) * | 2021-06-25 | 2022-12-27 | 超聚变数字技术有限公司 | 一种数据存储方法以及相关设备 |
| CN117056099A (zh) * | 2023-08-14 | 2023-11-14 | 中国铁道科学研究院集团有限公司 | 一种铁路信号安全计算机平台及其内存共享方法 |
| CN120371724A (zh) * | 2025-06-26 | 2025-07-25 | 浪潮电子信息产业股份有限公司 | 一种内存分配方法、装置及电子设备和存储介质 |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115794368A (zh) | 2021-09-11 | 2023-03-14 | 华为技术有限公司 | 业务系统、内存管理方法及装置 |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6848033B2 (en) * | 2001-06-07 | 2005-01-25 | Hewlett-Packard Development Company, L.P. | Method of memory management in a multi-threaded environment and program storage device |
| CN101122883A (zh) * | 2006-08-09 | 2008-02-13 | 中兴通讯股份有限公司 | 一种避免内存碎片化的内存分配方法 |
| CN102156675A (zh) * | 2010-02-12 | 2011-08-17 | 中兴通讯股份有限公司 | 一种内存分配方法及装置 |
| CN103077126A (zh) * | 2012-12-24 | 2013-05-01 | 中兴通讯股份有限公司 | 一种内存管理方法和装置 |
| CN103399821A (zh) * | 2013-06-28 | 2013-11-20 | 贵阳朗玛信息技术股份有限公司 | jitterbuf内存处理方法及装置 |
| CN103810115A (zh) * | 2012-11-15 | 2014-05-21 | 深圳市腾讯计算机系统有限公司 | 一种内存池的管理方法和装置 |
| CN103885569A (zh) * | 2014-04-11 | 2014-06-25 | 珠海全志科技股份有限公司 | 内存的管理方法及装置 |
Family Cites Families (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JPS593567A (ja) * | 1982-06-29 | 1984-01-10 | Fujitsu Ltd | ツリ−構造のバツフア数設定方式 |
| US6918021B2 (en) * | 2001-05-10 | 2005-07-12 | Hewlett-Packard Development Company, L.P. | System of and method for flow control within a tag pipeline |
| US6898679B2 (en) * | 2001-09-28 | 2005-05-24 | Intel Corporation | Method and apparatus for reordering memory requests for page coherency |
| CN101739354B (zh) * | 2009-12-14 | 2011-07-06 | 浙江大学 | 基于内存池技术的brew手机h.264解码优化方法 |
| CN101834796B (zh) * | 2010-05-06 | 2015-01-28 | 中兴通讯股份有限公司 | 一种双控制器通信系统和方法 |
| CN101847127B (zh) * | 2010-06-18 | 2012-01-25 | 福建星网锐捷网络有限公司 | 一种内存管理方法及装置 |
| CN102662891B (zh) * | 2012-03-22 | 2014-11-26 | 北京北大众志微系统科技有限责任公司 | 基于亲和性感知的dma缓冲区管理方法及装置 |
| CN103761192B (zh) * | 2014-01-20 | 2016-08-17 | 华为技术有限公司 | 一种内存分配的方法和装置 |
-
2015
- 2015-10-28 CN CN201580083925.XA patent/CN108139969B/zh active Active
- 2015-10-28 WO PCT/CN2015/093113 patent/WO2017070869A1/zh not_active Ceased
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US6848033B2 (en) * | 2001-06-07 | 2005-01-25 | Hewlett-Packard Development Company, L.P. | Method of memory management in a multi-threaded environment and program storage device |
| CN101122883A (zh) * | 2006-08-09 | 2008-02-13 | 中兴通讯股份有限公司 | 一种避免内存碎片化的内存分配方法 |
| CN102156675A (zh) * | 2010-02-12 | 2011-08-17 | 中兴通讯股份有限公司 | 一种内存分配方法及装置 |
| CN103810115A (zh) * | 2012-11-15 | 2014-05-21 | 深圳市腾讯计算机系统有限公司 | 一种内存池的管理方法和装置 |
| CN103077126A (zh) * | 2012-12-24 | 2013-05-01 | 中兴通讯股份有限公司 | 一种内存管理方法和装置 |
| CN103399821A (zh) * | 2013-06-28 | 2013-11-20 | 贵阳朗玛信息技术股份有限公司 | jitterbuf内存处理方法及装置 |
| CN103885569A (zh) * | 2014-04-11 | 2014-06-25 | 珠海全志科技股份有限公司 | 内存的管理方法及装置 |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109992347A (zh) * | 2019-04-10 | 2019-07-09 | Oppo广东移动通信有限公司 | 界面显示方法、装置、终端及存储介质 |
| CN109992347B (zh) * | 2019-04-10 | 2022-03-25 | Oppo广东移动通信有限公司 | 界面显示方法、装置、终端及存储介质 |
| CN115525443A (zh) * | 2021-06-25 | 2022-12-27 | 超聚变数字技术有限公司 | 一种数据存储方法以及相关设备 |
| CN117056099A (zh) * | 2023-08-14 | 2023-11-14 | 中国铁道科学研究院集团有限公司 | 一种铁路信号安全计算机平台及其内存共享方法 |
| CN117056099B (zh) * | 2023-08-14 | 2024-06-07 | 中国铁道科学研究院集团有限公司 | 一种铁路信号安全计算机平台及其内存共享方法 |
| CN120371724A (zh) * | 2025-06-26 | 2025-07-25 | 浪潮电子信息产业股份有限公司 | 一种内存分配方法、装置及电子设备和存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108139969A (zh) | 2018-06-08 |
| CN108139969B (zh) | 2021-06-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN107241281B (zh) | 一种数据处理方法及其装置 | |
| US9652150B2 (en) | Global memory sharing method and apparatus, and communications system | |
| CN107426274B (zh) | 基于时序的业务应用及监控分析调度的方法和系统 | |
| JP5510556B2 (ja) | 仮想マシンのストレージスペースおよび物理ホストを管理するための方法およびシステム | |
| CN103412786B (zh) | 一种高性能服务器架构系统及数据处理方法 | |
| CN109697122B (zh) | 任务处理方法、设备及计算机存储介质 | |
| US9801204B2 (en) | Sending node and buffer status reporting method | |
| CN112214313A (zh) | 内存分配方法及相关设备 | |
| WO2020019743A1 (zh) | 流量控制方法及装置 | |
| WO2016011894A1 (zh) | 报文处理方法和装置 | |
| WO2017070869A1 (zh) | 一种内存配置方法、装置及系统 | |
| US20200364080A1 (en) | Interrupt processing method and apparatus and server | |
| CN113986497B (zh) | 基于多租户技术的队列调度方法、装置及系统 | |
| CN112799824B (zh) | 一种限流方法、装置、设备和存储介质 | |
| WO2017028696A1 (zh) | 分布式存储系统的负载监控方法及设备 | |
| CN113767368A (zh) | 资源获取方法、相关装置及计算机存储介质 | |
| CN107347039A (zh) | 一种共享缓存空间的管理方法及装置 | |
| CN106664259B (zh) | 虚拟网络功能扩容的方法和装置 | |
| WO2016202153A1 (zh) | 一种gpu资源的分配方法及系统 | |
| CN111857992A (zh) | 一种Radosgw模块中线程资源分配方法和装置 | |
| CN113886082A (zh) | 请求处理方法、装置、计算设备及介质 | |
| WO2024213065A1 (zh) | 资源控制方法、装置及设备 | |
| CN106776393B (zh) | 一种无中断的串口数据接收方法和装置 | |
| CN105637483B (zh) | 线程迁移方法、装置和系统 | |
| CN109302353B (zh) | 一种分配报文缓存空间的方法及装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 15906935 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 15906935 Country of ref document: EP Kind code of ref document: A1 |