[go: up one dir, main page]

CN108920276A - Linux system memory allocation method, system and equipment and storage medium - Google Patents

Linux system memory allocation method, system and equipment and storage medium Download PDF

Info

Publication number
CN108920276A
CN108920276A CN201810679069.XA CN201810679069A CN108920276A CN 108920276 A CN108920276 A CN 108920276A CN 201810679069 A CN201810679069 A CN 201810679069A CN 108920276 A CN108920276 A CN 108920276A
Authority
CN
China
Prior art keywords
memory
allocated
target
cutting unit
size
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.)
Pending
Application number
CN201810679069.XA
Other languages
Chinese (zh)
Inventor
王洋
张雪庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810679069.XA priority Critical patent/CN108920276A/en
Publication of CN108920276A publication Critical patent/CN108920276A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

本申请公开了一种Linux系统内存分配方法、系统及设备和计算机可读存储介质,该方法包括:接收分配命令;其中,所述分配命令至少包括目标内存大小;根据所述目标内存大小在待分配内存中确定目标切割单位;其中,所述待分配内存的物理地址连续、内存大小大于预设值且包括N个切割单位,N为正整数;为所述分配命令对应的请求方分配所述目标切割单位。本申请提供的Linux系统内存分配方法,将待分配内存划分为大小相同或不同的切割单位,内存以切割单位的方式分配给请求方,每个切割单位为相对独立和隔离的内存区域,每个请求方只能操作已分配的各自的内存区域,保证了每个请求方之间内存申请与释放的独立性。

The present application discloses a Linux system memory allocation method, system and device, and a computer-readable storage medium. The method includes: receiving an allocation command; wherein, the allocation command includes at least a target memory size; Determine the target cutting unit in the allocated memory; wherein, the physical address of the memory to be allocated is continuous, the memory size is greater than a preset value, and includes N cutting units, and N is a positive integer; the requester corresponding to the allocation command is allocated the Target cutting unit. The Linux system memory allocation method provided by this application divides the memory to be allocated into cutting units of the same size or different sizes. The memory is allocated to the requester in the form of cutting units. Each cutting unit is a relatively independent and isolated memory area. The requester can only operate the allocated memory area, which ensures the independence of memory application and release between each requester.

Description

Linux system memory allocation method, system and equipment and storage medium
Technical field
This application involves technical field of memory, more specifically to a kind of linux system memory allocation method, system And equipment and a kind of computer readable storage medium.
Background technique
In (SuSE) Linux OS, the management of memory and share out the work be influence system stable operation an important factor for.It is existing Distribution method in technology is based on buddy algorithm, and buddy algorithm reduces the fragment of memory, data structure to greatest extent In include chained list and bitmap, chained list organizes together the memory block of same rank, and it is corresponding that bitmap denotes each memory block Partner's block state, in Memory Allocation will according to the state determine memory how to distribute.
Memory allocation method based on buddy algorithm, without specific region division, there is no the memories of relatively independent isolation Region, memory application and release is not independent between each consumer, is unfavorable for the real-time statistics and management of memory.
Therefore, how to realize that the division in the independent memory region of linux system is user's problem to be solved.
Summary of the invention
The application's is designed to provide a kind of linux system memory allocation method, system and equipment and a kind of computer Readable storage medium storing program for executing realizes the division in the independent memory region of linux system.
To achieve the above object, this application provides a kind of linux system memory allocation methods, including:
Receive distribution order;Wherein, the distribution order includes at least target memory size;
Determine that target cuts unit in memory to be allocated according to the target memory size;Wherein, described to be allocated interior The physical address deposited is continuous, memory size is greater than preset value and including N number of cutting unit, and N is positive integer;
It orders corresponding requesting party to distribute the target for the distribution and cuts unit.
Wherein, before the reception distribution order, further include:
It determines memory to be allocated, and is described wait divide according to the virtual memory address of the memory to be allocated and physical address Promiscuous device is created with memory;
The memory to be allocated is cut into cutting unit by preset cutting mode;
Correspondingly, described order corresponding requesting party to distribute the target cutting unit for the distribution, including:
It is that the distribution orders corresponding requesting party to distribute the target cutting unit using the promiscuous device.
Wherein, the memory to be allocated is cut into cutting unit by preset cutting mode, including:
The memory to be allocated is averagely cut into preset quantity cutting unit.
Wherein, after the memory to be allocated being cut into cutting unit by preset cutting mode, further include:
Sort operation is carried out by memory size to the cutting unit, and is every one kind cutting unit creation chained list.
Wherein, determine that target cuts unit in memory to be allocated according to the target memory size in the distribution order, Including:
Judge single with the presence or absence of memory size and target memory target cutting of the same size in all chained lists Position;
If it is not, then choose cutting unit to be allocated from all chained lists according to the target memory size, and by institute It states cutting unit to be allocated and is cut into first part and second part;Wherein, the memory size of the first part and the mesh It is consistent to mark memory size;
The first part is determined as the target cutting unit, and the second part is articulated in corresponding chained list In.
Wherein, described that cutting unit to be allocated is chosen from all chained lists according to the target memory size, including:
The cutting unit that memory size in all chained lists is greater than the target memory size is determined as candidate cutting Unit;
The smallest cutting unit of memory size in all candidate cutting units is determined as cutting unit to be allocated.
Wherein, further include:
When memory release, judge whether there is and the continuous cutting unit to be combined of releasing memory physical address;
If so, merging the releasing memory and the cutting unit to be combined, and hang the region of memory completed is merged It connects in corresponding chained list.
To achieve the above object, this application provides a kind of linux system Memory Allocation systems, including:
Receiving module, for receiving distribution order;Wherein, the distribution order includes at least target memory size;
Determining module, for determining that target cuts unit in memory to be allocated according to the target memory size;Wherein, The physical address of the memory to be allocated is continuous, memory size is greater than preset value and including N number of cutting unit, and N is positive integer;
Distribution module cuts unit for ordering corresponding requesting party to distribute the target for the distribution.
To achieve the above object, this application provides a kind of linux system Memory Allocation equipment, including:
Memory, for storing computer program;
Processor is realized when for executing the computer program such as the step of above-mentioned linux system memory allocation method.
To achieve the above object, this application provides a kind of computer readable storage medium, the computer-readable storages It is stored with computer program on medium, realizes when the computer program is executed by processor such as above-mentioned linux system memory point The step of method of completing the square.
By above scheme it is found that a kind of linux system memory allocation method provided by the present application, including:Receive distribution Order;Wherein, the distribution order includes at least target memory size;According to the target memory size in memory to be allocated Determine that target cuts unit;Wherein, the physical address of the memory to be allocated is continuous, memory size is greater than preset value and including N A cutting unit, N are positive integer;It orders corresponding requesting party to distribute the target for the distribution and cuts unit.
It is identical or different to be divided into size by linux system memory allocation method provided by the present application for memory to be allocated Unit is cut, memory distributes to requesting party in a manner of cutting unit, and each cutting unit is relatively independent and isolation memory Region, each requesting party can only operate allocated respective region of memory, ensure that between each requesting party memory application with The independence of release, i.e., the internal memory operation of each requesting party by mutual interference, are not convenient for real-time statistics and management. Disclosed herein as well is a kind of linux system Memory Allocation system and equipment and a kind of computer readable storage medium, same energy Realize above-mentioned technical effect.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of application for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is a kind of flow chart of linux system memory allocation method disclosed in the embodiment of the present application;
Fig. 2 is the flow chart of another kind linux system memory allocation method disclosed in the embodiment of the present application;
Fig. 3 is a kind of structure chart of linux system Memory Allocation system disclosed in the embodiment of the present application;
Fig. 4 is a kind of structure chart of linux system Memory Allocation equipment disclosed in the embodiment of the present application;
Fig. 5 is the structure chart of another kind linux system Memory Allocation equipment disclosed in the embodiment of the present application.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete Site preparation description, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on Embodiment in the application, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall in the protection scope of this application.
The embodiment of the present application discloses a kind of linux system memory allocation method, realizes the independent memory of linux system The division in region.The present embodiment can be divided into kernel state and User space two parts in software architecture, and the two responsibility is clear, kernel state Driving is mainly responsible for bulk contiguous memory distribution management role, while needing to create the standby user state mapping of corresponding promiscuous device It uses;User space, which drives, to be responsible for memory sections, linked list maintenance, the cutting for cutting unit and merging, random memory etc. and appoints Business.
Referring to Fig. 1, a kind of flow chart of linux system memory allocation method disclosed in the embodiment of the present application, such as Fig. 1 institute Show, including:
S101:Receive distribution order;Wherein, the distribution order includes at least target memory size;
In specific implementation, which includes at least the target memory size of request, certainly can also include other Information, herein without specifically limiting.
S102:Determine that target cuts unit in memory to be allocated according to the target memory size;Wherein, described wait divide Physical address with memory is continuous, memory size is greater than preset value and including N number of cutting unit, and N is positive integer;
In specific implementation, determine that target cuts unit according to target memory size, the present embodiment is not determined to specific Mode is defined, for example, can by the memory size for cutting unit with target memory size is immediate is determined as the target Cut unit.
It is understood that this step defaults the minimum memory unit of memory to be allocated for cutting unit, therefore in S101 Need to do memory to be allocated according to the characteristics of storing data the division of cutting unit before.Determine memory to be allocated, and root Virtual memory address and physical address according to the memory to be allocated are that the memory to be allocated creates promiscuous device, and provides it The memory to be allocated is cut into cutting unit by preset cutting mode by mmap method and vma_fault method.Creation is mixed It using the promiscuous device is that distribution orders corresponding requesting party to distribute cutting unit that the purpose of miscellaneous equipment, which is convenient for subsequent step,.
It should be noted that saving as the memory that physical address is continuous, memory size is greater than preset value in be allocated.Determine to The strategy of storage allocation is to apply enough 4M (at present using kmalloc (a kind of function name of computer language, storage allocation) Kmalloc once runs the maximum memory of application) memory block, the contiguous memory of meet demand is then searched using sort algorithm.
The specific division mode that the present embodiment does not treat storage allocation is defined, and user can according to the actual situation flexibly Selection.Memory to be allocated is averagely cut into preset quantity cutting unit as a preferred implementation manner,.For example, one If the memory to be allocated that total memory capacity is 100G is used to, storage volume is smaller but a fairly large number of data file, then can be with The size of suitable minimum memory unit is set according to the mean size of the data file, because every layer between GB and MB and KB Conversion multiple be all 1024.For example, the mean size of the data file is all in 450K or so, and is no more than 512K, then just The minimum memory unit can be sized to 512K, in order to the write-in to file and reduced in each minimum memory unit Remaining space proportion, then the preset quantity of equal part is exactly 100*1024*2=in the memory to be allocated of 100G 204800, i.e., the memory space of the 100G is divided by 204800 minimum memory lists according to the mean size of storage file Member, the size of each storage unit are 512K.
Certainly, the mode specifically how divided to a memory to be allocated is varied, simplest to be classified as Two kinds, i.e., serially divide or parallel patition, serial division mode be one by one divide, divided one it is subdivided It is next;Parallel division mode is the division being completed at the same time to all quantity minimum memory units.Both modes respectively have respectively The advantages of and suitable usage scenario.
For example, the mean size when data file is larger, that is, the size of the minimum memory unit divided is also larger, corresponding The quantity of minimum memory unit will be less, serial division mode can be used in the case where division numbers are less, Because time required for partition process and the size marked off are substantially proportional, consumed using parallel division mode Time can't be fewer than serial, and if once occurring abnormal, also only can damage a storage unit, will not draw as parallel Point mode is likely to result in whole scrap;When the mean size of data file is smaller, that is, the size of the minimum memory unit divided Also smaller, the quantity of corresponding minimum memory unit will be more, can be using simultaneously in the case where division numbers are more Capable division mode can be completed to divide with higher efficiency, it is contemplated that safety and unusual condition can carry out in batches simultaneously Row divides, without once completing total amount of division.
Only two kinds of simplest division modes above-mentioned, there is also many other division modes, based on various Principle and method can achieve certain special effects, not make specific restriction herein, should regard actual conditions in conjunction with various shadows The factor of sound makes the selection for being best suitable for number one.
S103:It orders corresponding requesting party to distribute the target for the distribution and cuts unit.
In specific implementation, distribute the distribution order corresponding requesting party the target cutting unit that above-mentioned steps determine, For requesting party's use.
Linux system memory allocation method provided by the embodiments of the present application, by memory to be allocated be divided into size it is identical or Different cutting units, memory distribute to requesting party in a manner of cutting unit, and each cutting unit is relatively independent and isolation Region of memory, each requesting party can only operate allocated respective region of memory, ensure that memory between each requesting party The independence of application and release, i.e., the internal memory operation of each requesting party by mutual interference, are not convenient for real-time statistics And management.
The embodiment of the present application discloses a kind of linux system memory allocation method, relative to a upper embodiment, the present embodiment Further instruction and optimization have been made to technical solution.Specifically:
Referring to fig. 2, the flow chart of another linux system memory allocation method provided by the embodiments of the present application, such as Fig. 2 institute Show, including:
S211:It determines memory to be allocated, and is institute according to the virtual memory address of the memory to be allocated and physical address State memory creation promiscuous device to be allocated;
S212:The memory to be allocated is averagely cut into preset quantity cutting unit;
S213:Sort operation is carried out by memory size to the cutting unit, and is every one kind cutting unit creation Chained list;
In this embodiment, cutting unit can be safeguarded in the form of chained list, i.e., memory size is same or similar cutting Unit is divided into one kind, and is one chained list of every a kind of creation, and the same or similar cutting unit of each memory size is articulated in together On one chained list.For example, 0-2 can be created8、28-210... chained list.
S202:Receive distribution order;Wherein, the distribution order includes at least target memory size;
S231:Judge to cut with the presence or absence of memory size with target memory target of the same size in all chained lists Cut unit;If so, into S204;If it is not, then entering S232;
In specific implementation, Memory Allocation demand (i.e. target memory size) and practical cutting unit under normal circumstances is interior The probability for depositing size exact matching is not high, therefore needs to carry out element segmentation.Memory size and target memory size one if it exists The target of cause cuts unit, then is directly entered S204, if it does not exist, then enters the segmentation that S232 carries out cutting unit.
S232:Cutting unit to be allocated is chosen from all chained lists according to the target memory size, and will be described Cutting unit to be allocated is cut into first part and second part;Wherein, the memory size of the first part and the target Memory size is consistent;
S233:The first part is determined as the target cutting unit, and the second part is articulated in correspondence Chained list in;
In specific implementation, cutting unit to be allocated is determined according to target memory size, i.e., according to the demand of distribution order Search matched chained list.The cutting unit that memory size in all chained lists is greater than the target memory size is determined as waiting Choosing cutting unit, and the smallest cutting unit of memory size in all candidate cutting units is determined as cutting list to be allocated Position.For example, it is 2 that target memory size, which is the chained list that 4k is found,8-210, then from the chained list select memory size be greater than target The minimum cut unit of memory size is as cutting unit to be allocated.
Need to be cut into size and target memory part of the same size (i.e. first after determining cutting unit to be allocated Part) and remainder (i.e. second part), the first address of first part is returned to after the completion of segmentation, while again by second part It is encapsulated as new cutting unit and is articulated on matched chained list.
S204:It orders corresponding requesting party to distribute the target for the distribution and cuts unit.
It is understood that needing to judge whether there is and discharge when memory discharges as a preferred implementation manner, The continuous cutting unit to be combined of memory physical address, judges whether there is and releasing memory physical address is continuous to be combined cuts Cut unit, if so, merge releasing memory and cutting unit to be combined, and will merge the region of memory completed be articulated in it is corresponding In chained list, if it is not, then directly releasing memory is articulated on matched chained list.
A kind of linux system Memory Allocation system provided by the embodiments of the present application is introduced below, it is described below A kind of linux system Memory Allocation system can be cross-referenced with a kind of above-described linux system memory allocation method.
Referring to Fig. 3, a kind of structure chart of linux system Memory Allocation system provided by the embodiments of the present application, such as Fig. 3 institute Show, including:
Receiving module 301, for receiving distribution order;Wherein, the distribution order includes at least target memory size;
Determining module 302, for determining that target cuts unit in memory to be allocated according to the target memory size;Its In, the physical address of the memory to be allocated is continuous, memory size is greater than preset value and including N number of cutting unit, and N is positive whole Number;
Distribution module 303 cuts unit for ordering corresponding requesting party to distribute the target for the distribution.
Linux system Memory Allocation system provided by the embodiments of the present application, by memory to be allocated be divided into size it is identical or Different cutting units, memory distribute to requesting party in a manner of cutting unit, and each cutting unit is relatively independent and isolation Region of memory, each requesting party can only operate allocated respective region of memory, ensure that memory between each requesting party The independence of application and release, i.e., the internal memory operation of each requesting party by mutual interference, are not convenient for real-time statistics And management.
On the basis of the above embodiments, further include as a preferred implementation manner,:
Creation module, for determining memory to be allocated, and according to the virtual memory address and physics of the memory to be allocated Address is that the memory to be allocated creates promiscuous device;
Cutting module, for the memory to be allocated to be cut into cutting unit by preset cutting mode;
Correspondingly, it is that corresponding request is ordered in the distribution that the distribution module 303, which is specially using the promiscuous device, Side distributes the module of the target cutting unit.
On the basis of the above embodiments, as a preferred implementation manner, the cutting module be specially will it is described to Storage allocation is averagely cut into the module of preset quantity cutting unit.
On the basis of the above embodiments, further include as a preferred implementation manner,:
Categorization module for carrying out sort operation by memory size to the cutting unit, and is every one kind cutting Unit creation chained list.
On the basis of the above embodiments, the determining module 302 includes as a preferred implementation manner,:
Judging unit, it is in the same size with the presence or absence of memory size and the target memory in all chained lists for judging Target cut unit;If it is not, then starting the workflow of the selection unit;
The selection unit, it is single for choosing cutting to be allocated from all chained lists according to the target memory size Position, and the cutting unit to be allocated is cut into first part and second part;Wherein, the memory size of the first part It is in the same size with the target memory;
Determination unit cuts unit for the first part to be determined as the target, and the second part is hung It connects in corresponding chained list.
On the basis of the above embodiments, the selection unit includes as a preferred implementation manner,:
First determines subelement, for memory size in all chained lists to be greater than to the cutting of the target memory size Unit is determined as candidate cutting unit;
Second determines subelement, for determining the smallest cutting unit of memory size in all candidate cutting units For cutting unit to be allocated.
On the basis of the above embodiments, further include as a preferred implementation manner,:
Release module, for judging whether there is continuously to be combined with releasing memory physical address when memory release Cut unit;If so, merging the releasing memory and the cutting unit to be combined, and hang the region of memory completed is merged It connects in corresponding chained list.
Present invention also provides a kind of linux system Memory Allocation equipment, referring to fig. 4, provided by the embodiments of the present application one The structure chart of kind linux system Memory Allocation equipment, as shown in figure 4, including:
Memory 100, for storing computer program;
Linux provided by any of the above-described embodiment may be implemented in processor 200 when for executing the computer program The step of Installed System Memory distribution method.
Specifically, memory 100 includes non-volatile memory medium, built-in storage.Non-volatile memory medium storage There are operating system and computer-readable instruction, which is that the operating system and computer in non-volatile memory medium can The operation of reading instruction provides environment.Processor 200 provides calculating and control ability for linux system Memory Allocation equipment, executes When the computer program saved in the memory 100, linux system memory provided by any of the above-described embodiment may be implemented The step of distribution method.
Linux system Memory Allocation equipment provided by the embodiments of the present application, by memory to be allocated be divided into size it is identical or Different cutting units, memory distribute to requesting party in a manner of cutting unit, and each cutting unit is relatively independent and isolation Region of memory, each requesting party can only operate allocated respective region of memory, ensure that memory between each requesting party The independence of application and release, i.e., the internal memory operation of each requesting party by mutual interference, are not convenient for real-time statistics And management.
On the basis of the above embodiments, preferably, referring to Fig. 5, the linux system Memory Allocation is set It is standby to further include:
Input interface 300 is connected with processor 200, for obtaining computer program, parameter and the instruction of external importing, It saves through the control of processor 200 into memory 100.The input interface 300 can be connected with input unit, and it is manual to receive user The parameter or instruction of input.The input unit can be the touch layer covered on display screen, be also possible to be arranged in terminal enclosure Key, trace ball or Trackpad, be also possible to keyboard, Trackpad or mouse etc..
Display unit 400 is connected with processor 200, the data sent for video-stream processor 200.The display unit 400 It can be display screen, liquid crystal display or the electric ink display screen etc. in PC machine.It, can be with specifically, in the present embodiment By the distribution of display unit 400 order whether successful execution etc..
The network port 500 is connected with processor 200, for being communicatively coupled with external each terminal device.The communication link The communication technology used by connecing can be cable communicating technology or wireless communication technique, and such as mobile high definition chained technology (MHL) leads to It is blue with universal serial bus (USB), high-definition media interface (HDMI), adopting wireless fidelity technology (WiFi), Bluetooth Communication Technology, low-power consumption The tooth communication technology, communication technology based on IEEE802.11s etc..Specifically, in the present embodiment, the network port can be passed through 500 import cutting unit chained list etc. to processor 200.
Present invention also provides a kind of computer readable storage medium, which may include:USB flash disk, mobile hard disk, Read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic The various media that can store program code such as dish or CD.Computer program, the calculating are stored on the storage medium Machine program realizes the step of linux system memory allocation method provided by any of the above-described embodiment when being executed by processor.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with other The difference of embodiment, the same or similar parts in each embodiment may refer to each other.
The foregoing description of the disclosed embodiments makes professional and technical personnel in the field can be realized or use the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein General Principle can be realized in other embodiments without departing from the spirit or scope of the application.Therefore, the application It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one The widest scope of cause.
Each embodiment is described in a progressive manner in specification, the highlights of each of the examples are with other realities The difference of example is applied, the same or similar parts in each embodiment may refer to each other.For system disclosed in embodiment Speech, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part illustration ?.It should be pointed out that for those skilled in the art, under the premise of not departing from the application principle, also Can to the application, some improvement and modification can also be carried out, these improvement and modification also fall into the protection scope of the claim of this application It is interior.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to by One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged Except there is also other identical elements in the process, method, article or apparatus that includes the element.

Claims (10)

1.一种Linux系统内存分配方法,其特征在于,包括:1. A Linux system memory allocation method, characterized in that, comprising: 接收分配命令;其中,所述分配命令至少包括目标内存大小;receiving an allocation command; wherein, the allocation command includes at least a target memory size; 根据所述目标内存大小在待分配内存中确定目标切割单位;其中,所述待分配内存的物理地址连续、内存大小大于预设值且包括N个切割单位,N为正整数;Determine the target cutting unit in the memory to be allocated according to the size of the target memory; wherein, the physical address of the memory to be allocated is continuous, the memory size is greater than a preset value, and includes N cutting units, where N is a positive integer; 为所述分配命令对应的请求方分配所述目标切割单位。Allocating the target cutting unit to the requester corresponding to the allocation command. 2.根据权利要求1所述Linux系统内存分配方法,其特征在于,所述接收分配命令之前,还包括:2. according to the described Linux system memory allocation method of claim 1, it is characterized in that, before described receiving allocation order, also comprise: 确定待分配内存,并根据所述待分配内存的虚拟内存地址和物理地址为所述待分配内存创建混杂设备;determining the memory to be allocated, and creating a hybrid device for the memory to be allocated according to the virtual memory address and the physical address of the memory to be allocated; 将所述待分配内存按预设的切割方式切割为切割单位;cutting the memory to be allocated into cutting units according to a preset cutting method; 相应的,所述为所述分配命令对应的请求方分配所述目标切割单位,包括:Correspondingly, the allocating the target cutting unit to the requester corresponding to the allocation command includes: 利用所述混杂设备为所述分配命令对应的请求方分配所述目标切割单位。Using the hybrid device to allocate the target cutting unit to the requester corresponding to the allocation command. 3.根据权利要求2所述Linux系统内存分配方法,其特征在于,将所述待分配内存按预设的切割方式切割为切割单位,包括:3. according to the described Linux system memory allocation method of claim 2, it is characterized in that, the memory to be allocated is cut into cutting units according to a preset cutting mode, comprising: 将所述待分配内存平均切割为预设数量个切割单位。Divide the memory to be allocated into a preset number of division units on average. 4.根据权利要求2所述Linux系统内存分配方法,其特征在于,将所述待分配内存按预设的切割方式切割为切割单位之后,还包括:4. according to the described Linux system memory allocation method of claim 2, it is characterized in that, after the memory to be allocated is cut into cutting units according to the preset cutting mode, it also includes: 对所述切割单位按内存大小进行分类操作,并为每一类所述切割单位创建链表。Classify the cutting units according to memory size, and create a linked list for each type of cutting units. 5.根据权利要求4所述Linux系统内存分配方法,其特征在于,根据所述分配命令中的目标内存大小在待分配内存中确定目标切割单位,包括:5. according to the described Linux system memory allocation method of claim 4, it is characterized in that, according to the target memory size in the allocation command, determine the target cutting unit in the memory to be allocated, comprising: 判断所有所述链表中是否存在内存大小与所述目标内存大小一致的目标切割单位;Judging whether there is a target cutting unit whose memory size is consistent with the target memory size in all the linked lists; 若否,则根据所述目标内存大小从所有所述链表中选取待分配切割单位,并将所述待分配切割单位切割为第一部分和第二部分;其中,所述第一部分的内存大小与所述目标内存大小一致;If not, then select the cutting unit to be allocated from all the linked lists according to the target memory size, and cut the cutting unit to be allocated into a first part and a second part; wherein, the memory size of the first part is the same as the The size of the target memory is the same; 将所述第一部分确定为所述目标切割单位,并将所述第二部分挂接在对应的链表中。The first part is determined as the target cutting unit, and the second part is linked in a corresponding linked list. 6.根据权利要求5所述Linux系统内存分配方法,其特征在于,所述根据所述目标内存大小从所有所述链表中选取待分配切割单位,包括:6. according to the described Linux system memory allocation method of claim 5, it is characterized in that, described according to described target memory size, select to be allocated cutting unit from all described linked lists, comprising: 将所有所述链表中内存大小大于所述目标内存大小的切割单位确定为候选切割单位;Determining all cutting units whose memory size is larger than the target memory size in the linked list as candidate cutting units; 将所有所述候选切割单位中内存大小最小的切割单位确定为待分配切割单位。Determining the cutting unit with the smallest memory size among all the candidate cutting units as the cutting unit to be allocated. 7.根据权利要求4-6任一项所述Linux系统内存分配方法,其特征在于,还包括:7. according to the described Linux system memory allocation method according to any one of claim 4-6, it is characterized in that, also comprising: 当内存释放时,判断是否存在与释放内存物理地址连续的待合并切割单位;When the memory is released, determine whether there is a unit to be merged and cut that is continuous with the physical address of the released memory; 若是,则合并所述释放内存和所述待合并切割单位,并将合并完成的内存区域挂接在对应的链表中。If yes, merge the released memory and the cutting unit to be merged, and mount the merged memory area in the corresponding linked list. 8.一种Linux系统内存分配系统,其特征在于,包括:8. A Linux system memory allocation system, characterized in that, comprising: 接收模块,用于接收分配命令;其中,所述分配命令至少包括目标内存大小;A receiving module, configured to receive an allocation command; wherein, the allocation command includes at least a target memory size; 确定模块,用于根据所述目标内存大小在待分配内存中确定目标切割单位;其中,所述待分配内存的物理地址连续、内存大小大于预设值且包括N个切割单位,N为正整数;A determining module, configured to determine a target cutting unit in the memory to be allocated according to the size of the target memory; wherein, the physical address of the memory to be allocated is continuous, the memory size is larger than a preset value, and includes N cutting units, and N is a positive integer ; 分配模块,用于为所述分配命令对应的请求方分配所述目标切割单位。An allocation module, configured to allocate the target cutting unit to the requester corresponding to the allocation command. 9.一种Linux系统内存分配设备,其特征在于,包括:9. A Linux system memory allocation device, characterized in that, comprising: 存储器,用于存储计算机程序;memory for storing computer programs; 处理器,用于执行所述计算机程序时实现如权利要求1至7任一项所述Linux系统内存分配方法的步骤。The processor is configured to implement the steps of the Linux system memory allocation method according to any one of claims 1 to 7 when executing the computer program. 10.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述Linux系统内存分配方法的步骤。10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the Linux system according to any one of claims 1 to 7 is realized The steps of the memory allocation method.
CN201810679069.XA 2018-06-27 2018-06-27 Linux system memory allocation method, system and equipment and storage medium Pending CN108920276A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810679069.XA CN108920276A (en) 2018-06-27 2018-06-27 Linux system memory allocation method, system and equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810679069.XA CN108920276A (en) 2018-06-27 2018-06-27 Linux system memory allocation method, system and equipment and storage medium

Publications (1)

Publication Number Publication Date
CN108920276A true CN108920276A (en) 2018-11-30

Family

ID=64422707

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810679069.XA Pending CN108920276A (en) 2018-06-27 2018-06-27 Linux system memory allocation method, system and equipment and storage medium

Country Status (1)

Country Link
CN (1) CN108920276A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674051A (en) * 2019-09-24 2020-01-10 中国科学院微电子研究所 Data storage method and device
CN111078408A (en) * 2019-12-10 2020-04-28 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN111078410A (en) * 2019-12-11 2020-04-28 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
WO2021077917A1 (en) * 2019-10-24 2021-04-29 华为技术有限公司 Memory configuration method and device, and storage medium
CN113010453A (en) * 2021-04-12 2021-06-22 杭州和利时自动化有限公司 Memory management method, system, equipment and readable storage medium
CN113076266A (en) * 2021-06-04 2021-07-06 深圳华云信息系统有限公司 Memory management method and device, electronic equipment and storage medium
CN114706686A (en) * 2022-04-20 2022-07-05 深圳市华宝电子科技有限公司 Dynamic memory management method, device, equipment and storage medium
CN120821439A (en) * 2025-09-12 2025-10-21 山东云海国创云计算装备产业创新中心有限公司 A dynamic memory allocation method, device, medium and product

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030028739A1 (en) * 2001-07-18 2003-02-06 Li Richard Chi Leung Method and apparatus of storage allocation/de-allocation in object-oriented programming environment
US20060150195A1 (en) * 2003-06-30 2006-07-06 Microsoft Corporation System and method for interprocess communication
CN101122883A (en) * 2006-08-09 2008-02-13 中兴通讯股份有限公司 A Memory Allocation Method Avoiding Memory Fragmentation
CN101227341A (en) * 2007-12-18 2008-07-23 浪潮电子信息产业股份有限公司 Method of fast packet capture of Ethernet card on Linux system
CN101320351A (en) * 2008-06-27 2008-12-10 华中科技大学 Method for allocating, cleaning and releasing memory and device for memory management
CN102968378A (en) * 2012-10-23 2013-03-13 深圳市融创天下科技股份有限公司 Method, device and system for allocating and releasing memory
CN103106147A (en) * 2013-03-08 2013-05-15 中国科学院上海微系统与信息技术研究所 Memory allocation method and system
CN103150265A (en) * 2013-02-04 2013-06-12 山东大学 Fine grit data distributing method orienting to embedded on-chip heterogeneous memory
CN103500145A (en) * 2013-09-17 2014-01-08 首都师范大学 Method for improving utilization ratio of Linux idle memory blocks
CN103593243A (en) * 2013-11-01 2014-02-19 浪潮电子信息产业股份有限公司 Dynamic extensible method for increasing virtual machine resources
CN105302737A (en) * 2015-11-24 2016-02-03 浪潮(北京)电子信息产业有限公司 Memory allocation management method and memory allocation management system
CN105404590A (en) * 2015-11-10 2016-03-16 浪潮(北京)电子信息产业有限公司 Memory block combination method and system
CN106201910A (en) * 2016-08-27 2016-12-07 浪潮(北京)电子信息产业有限公司 The management method of a kind of fritter internal memory and device
CN106294198A (en) * 2016-08-05 2017-01-04 浪潮(北京)电子信息产业有限公司 The memory allocation method of a kind of (SuSE) Linux OS and method for releasing
CN106844041A (en) * 2016-12-29 2017-06-13 华为技术有限公司 The method and internal storage management system of memory management

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030028739A1 (en) * 2001-07-18 2003-02-06 Li Richard Chi Leung Method and apparatus of storage allocation/de-allocation in object-oriented programming environment
US20060150195A1 (en) * 2003-06-30 2006-07-06 Microsoft Corporation System and method for interprocess communication
CN101122883A (en) * 2006-08-09 2008-02-13 中兴通讯股份有限公司 A Memory Allocation Method Avoiding Memory Fragmentation
CN101227341A (en) * 2007-12-18 2008-07-23 浪潮电子信息产业股份有限公司 Method of fast packet capture of Ethernet card on Linux system
CN101320351A (en) * 2008-06-27 2008-12-10 华中科技大学 Method for allocating, cleaning and releasing memory and device for memory management
CN102968378A (en) * 2012-10-23 2013-03-13 深圳市融创天下科技股份有限公司 Method, device and system for allocating and releasing memory
CN103150265A (en) * 2013-02-04 2013-06-12 山东大学 Fine grit data distributing method orienting to embedded on-chip heterogeneous memory
CN103106147A (en) * 2013-03-08 2013-05-15 中国科学院上海微系统与信息技术研究所 Memory allocation method and system
CN103500145A (en) * 2013-09-17 2014-01-08 首都师范大学 Method for improving utilization ratio of Linux idle memory blocks
CN103593243A (en) * 2013-11-01 2014-02-19 浪潮电子信息产业股份有限公司 Dynamic extensible method for increasing virtual machine resources
CN105404590A (en) * 2015-11-10 2016-03-16 浪潮(北京)电子信息产业有限公司 Memory block combination method and system
CN105302737A (en) * 2015-11-24 2016-02-03 浪潮(北京)电子信息产业有限公司 Memory allocation management method and memory allocation management system
CN106294198A (en) * 2016-08-05 2017-01-04 浪潮(北京)电子信息产业有限公司 The memory allocation method of a kind of (SuSE) Linux OS and method for releasing
CN106201910A (en) * 2016-08-27 2016-12-07 浪潮(北京)电子信息产业有限公司 The management method of a kind of fritter internal memory and device
CN106844041A (en) * 2016-12-29 2017-06-13 华为技术有限公司 The method and internal storage management system of memory management

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
JOHN MEIER .ETAL: "Towards More Effective Spectrum Use Based on Memory Allocation Models", 《IEEE》 *
孙钟秀 等: "《面向21世纪课程教材:操作系统教程 (第3版)》", 31 August 2003, 高等教育出版社 *
李毅: "集中式三层交换机设备软件模块的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
胡元义 等: "《操作系统原理教程》", 31 July 2014, 西安电子科技大学出版社 *
谢文娣 等: "一种Linux内存管理机制", 《新乡学院学报》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110674051A (en) * 2019-09-24 2020-01-10 中国科学院微电子研究所 Data storage method and device
WO2021077917A1 (en) * 2019-10-24 2021-04-29 华为技术有限公司 Memory configuration method and device, and storage medium
CN111078408A (en) * 2019-12-10 2020-04-28 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN111078408B (en) * 2019-12-10 2022-10-21 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN111078410A (en) * 2019-12-11 2020-04-28 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN113010453A (en) * 2021-04-12 2021-06-22 杭州和利时自动化有限公司 Memory management method, system, equipment and readable storage medium
CN113076266A (en) * 2021-06-04 2021-07-06 深圳华云信息系统有限公司 Memory management method and device, electronic equipment and storage medium
CN114706686A (en) * 2022-04-20 2022-07-05 深圳市华宝电子科技有限公司 Dynamic memory management method, device, equipment and storage medium
CN114706686B (en) * 2022-04-20 2026-02-03 深圳市华宝电子科技有限公司 Memory dynamic management method, device, equipment and storage medium
CN120821439A (en) * 2025-09-12 2025-10-21 山东云海国创云计算装备产业创新中心有限公司 A dynamic memory allocation method, device, medium and product
CN120821439B (en) * 2025-09-12 2026-01-27 山东云海国创云计算装备产业创新中心有限公司 A dynamic memory allocation method, device, medium, and product

Similar Documents

Publication Publication Date Title
CN108920276A (en) Linux system memory allocation method, system and equipment and storage medium
CN110471861B (en) A data storage method in a flash memory device and a flash memory device
CN105190567B (en) Systems and methods for managing storage system snapshots
CN103425538B (en) Process communication method and system
CN109815162A (en) Memory management method and device, mobile terminal and storage medium
CN109684074A (en) Physical machine resource allocation methods and terminal device
US10254993B2 (en) Selecting first data sets in a first storage group to swap with second data sets in a second storage group
CN103927261A (en) Efficient Allocation And Reclamation Method For Thin-provisioned Storage And System Thereof
WO2023000673A1 (en) Hardware accelerator device management method and apparatus, and electronic device and storage medium
US11971771B2 (en) Peer storage device messaging for power management
WO2025112885A1 (en) Resource adjustment method and apparatus, electronic device, storage medium and training platform
US20190004703A1 (en) Method and computer system for managing blocks
CN110928803B (en) Memory management method and device
CN116483740B (en) Memory data migration method and device, storage medium and electronic device
US7590816B2 (en) Computer system, management computer and storage system, and storage area allocation amount controlling method
CN119088287A (en) System and method for data storage and storage device
CN109783283A (en) A kind of processing method, device and the terminal device of hardware detection information
CN120144324A (en) A memory resource processing method, device, system and electronic device
CN113867644B (en) Disk array optimization method, device, computer equipment and storage medium
CN109992536A (en) Data processing method, solid state hard disk and computer equipment
CN113655963A (en) Data storage system and method based on memory bridging and computer equipment
CN108255526B (en) A system startup and operation method and device
CN115344358A (en) Resource scheduling method, device and management node
CN117348973A (en) BI-Server cluster deployment method
CN116708303A (en) Traffic distribution method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20181130

RJ01 Rejection of invention patent application after publication