CN104199781A - Memory fragment allocation method and device based on shared memory - Google Patents

Memory fragment allocation method and device based on shared memory Download PDF

Info

Publication number
CN104199781A
CN104199781A CN201410401240.2A CN201410401240A CN104199781A CN 104199781 A CN104199781 A CN 104199781A CN 201410401240 A CN201410401240 A CN 201410401240A CN 104199781 A CN104199781 A CN 104199781A
Authority
CN
China
Prior art keywords
fragment
memory
fragmentation
free
length
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
CN201410401240.2A
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.)
BAC INFORMATION TECHNOLOGY Co Ltd
Original Assignee
BAC 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 BAC INFORMATION TECHNOLOGY Co Ltd filed Critical BAC INFORMATION TECHNOLOGY Co Ltd
Priority to CN201410401240.2A priority Critical patent/CN104199781A/en
Publication of CN104199781A publication Critical patent/CN104199781A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a memory fragment allocation method and device based on a shared memory. According to the method and device, problem that information is copied for many times in the information transmission and processing process is solved, an information buffer queue is moved from a trusted receiver to the shared memory, and an information queue building and memory fragment allocation method is disclosed on the basis of the shared memory. Copying frequency can be reduced in the information transmission and processing process, system efficiency is improved, and concurrency of a network server is improved; meanwhile, io is separated from logical processing, and lateral expansion capability and flexibility of the network server can be improved.

Description

A kind of memory fragmentation distribution method and device based on shared drive
Technical field
The present invention relates to mobile Internet memory management field, relate in particular to a kind of memory fragmentation distribution method and device based on shared drive.
Background technology
Io event read-write separation is that read operation and write operation be not in same thread or process.Can avoid like this one of them operation to block thread, also can not have influence on another.
Io is separated from logical process be io operation thread and worker thread respectively in different threads, can avoid like this influencing each other.
A part of physical memory that shared drive is shared by a plurality of processes.Shared drive is a kind of the fastest method of process data sharing, and a process has write data to shared drive region, shares all processes of this region of memory and just can see at once content wherein.
Network I/O read-write thread is separated with Message Processing worker thread, can keep away read-write and processing and influence each other, and causes a sheet resistance plug.Affect the performance of system performance, be separated into two independently modules simultaneously, can be according to application characteristic, recombination module, adapts to various demands and is also convenient to the extending transversely of whole system flexibly, has well flexible and extendability.Although this is a kind of trend at present, be not that it does not just introduce some problems.Memory copying is exactly in some problems of introducing.
Thread and thread, the interactive information in process and process, endlessly by the mode of communication in various processes, mutually transmit, and the transmission of this message can't be processed immediately, thereby to set up message buffer formation be a kind of general way.Originator, from IO message buffer copy one piece of data, forms message, by communication modes in process, sends take over party to, and this is to copy for the first time; Trusted parties is pressed into the message of receiving in message queue, certainly will want mono-section of internal memory of new, and copy one piece of data, then inserts queue, and this is second copy; Trusted parties processing threads is cancelled breath from message queue, and also can to copy one piece of data medium pending to processing buffer zone, and this is to copy for the third time.
Communication between process need to be carried out repeatedly memory copying, memory copying repeatedly, and the particularly larger application of interaction data amount, special consume system resources, affects the efficiency of software systems.The concurrent number that at present high concurrent service needs is more and more higher, and improving processing power is more and more to thirst for, more and more harsher to the requirement meeting of technology.Under this background, the message queue administrative mechanism based on shared drive is answered pregnant and is given birth to.
Summary of the invention
The object of the embodiment of the present invention is to propose a kind of memory fragmentation distribution method based on shared drive, be intended to solve prior art message transmit with processing procedure in repeatedly copy, consume system resources, affects the problem of software systems efficiency.
The embodiment of the present invention is achieved in that a kind of memory fragmentation distribution method based on shared drive, said method comprising the steps of:
According to the long L of the message of message to be stored, from first to last travel through FREE EXTENT FRAGMENTATION IN chained list, search the free memory fragment that fragment overall length is greater than " fragment head length+L ";
Judge whether to find fragment overall length to be greater than the free memory fragment of " fragment head length+L ", if do not find fragment overall length to be greater than the free memory fragment of " fragment head length+L ", adjacent idle memory fragmentation is recombinated, return to step and " according to the long L of the message of message to be stored; from first to last travel through FREE EXTENT FRAGMENTATION IN chained list, search the free memory fragment that fragment overall length is greater than " fragment head length+L " ";
If find fragment overall length to be greater than the free memory fragment of " fragment head length+L ",
The fragment overall length that judges whether described free memory fragment is greater than " two fragment heads of L+ are long ", if, described free memory fragment is removed from idle chained list, split into two memory fragmentations, last length is the memory fragmentation of " fragment head length+L ", being more made as memory fragmentation to be allocated after new fragment header structure, be inserted into the last-of-chain of using fragment chained list; A rear length is the memory fragmentation of " described fragment overall length-fragment head length-L ", inserts FREE EXTENT FRAGMENTATION IN chained list afterbody after fragment header structure is set; Otherwise directly described FREE EXTENT FRAGMENTATION IN is removed from FREE EXTENT FRAGMENTATION IN chained list, and be inserted into and use fragment chained list afterbody.
Another object of the embodiment of the present invention is to propose a kind of memory fragmentation distributor based on shared drive, and described device comprises:
FREE EXTENT FRAGMENTATION IN chained list spider module, for according to the long L of the message of message to be stored, from first to last travels through FREE EXTENT FRAGMENTATION IN chained list, searches the free memory fragment that fragment overall length is greater than " fragment head length+L ";
The first judge module, finds fragment overall length to be greater than the free memory fragment of " fragment head length+L " for judging whether, if so, enters the second judge module, otherwise, enter fragment recombination module,
The second judge module, for judging whether that the fragment overall length of described free memory fragment is greater than " two fragment heads of L+ are long ", if so, enters fragment division module, otherwise enter, fragment removes and insert module;
Fragment recombination module, for adjacent idle memory fragmentation is recombinated, then returns to FREE EXTENT FRAGMENTATION IN chained list spider module;
Fragment division module, for described free memory fragment is removed from idle chained list, split into two memory fragmentations, last length is the memory fragmentation of " fragment head length+L ", being more made as memory fragmentation to be allocated after new fragment header structure, be inserted into the last-of-chain of using fragment chained list; A rear length is the memory fragmentation of " described fragment overall length-fragment head length-L ", inserts FREE EXTENT FRAGMENTATION IN chained list afterbody after fragment header structure is set;
Fragment removes and insert module, for directly described FREE EXTENT FRAGMENTATION IN being removed from FREE EXTENT FRAGMENTATION IN chained list, and is inserted into and uses fragment chained list afterbody.
Beneficial effect of the present invention
The present invention improves the repeatedly problem of copy in message transmission and processing procedure, message buffering queue is moved on to shared drive from trusted parties, and proposed to create message queue and memory fragmentation distribution method based on shared drive; The present invention can reduce the repeatedly copy in message transmission and processing procedure, improves system effectiveness, improves the concurrent number of the webserver, io is separated with logical process simultaneously, can improve ability extending transversely and the dirigibility of the webserver.
Accompanying drawing explanation
Fig. 1 is a kind of memory fragmentation distribution method process flow diagram based on shared drive of the preferred embodiment of the present invention;
Fig. 2 is preferred embodiment of the present invention memory fragmentation structural representation;
Fig. 3 is the method flow diagram of in Fig. 1, adjacent idle memory fragmentation being recombinated;
Fig. 4 is preferred embodiment of the present invention memory pool structural representation;
Fig. 5 is a kind of memory fragmentation distributor structural drawing based on shared drive of the preferred embodiment of the present invention;
Fig. 6 is the structural drawing of fragment recombination module in Fig. 5 structure drawing of device.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated, for convenience of explanation, only show the part relevant to the embodiment of the present invention.Should be appreciated that the specific embodiment that this place is described, only for explaining the present invention, not in order to limit the present invention.
The embodiment of the present invention is improved the repeatedly problem of copy in message transmission and processing procedure, message buffering queue is moved on to shared drive from trusted parties, and proposed to create message queue and memory fragmentation distribution method based on shared drive; The embodiment of the present invention can reduce the repeatedly copy in message transmission and processing procedure, improves system effectiveness, improves the concurrent number of the webserver, io is separated with logical process simultaneously, can improve ability extending transversely and the dirigibility of the webserver.
Embodiment mono-
Fig. 1 is a kind of memory fragmentation distribution method process flow diagram based on shared drive of the preferred embodiment of the present invention; Said method comprising the steps of:
S101, according to the long L of the message of message to be stored, from first to last travels through FREE EXTENT FRAGMENTATION IN chained list, searches the free memory fragment that fragment overall length is greater than " fragment head length+L ";
Preferred embodiment of the present invention memory fragmentation structural representation as shown in Figure 2;
Memory fragmentation is the storage space of the certain length that distributes from shared drive of read or write;
Memory fragmentation comprises fragment head and fragment entity; Fragment head comprises fragment overall length, uses length, last fragment pointer, a rear fragment pointer, 5 fields of use state; Fragment entity is the internal memory of actual allocated, is the carrier of message stores, carries a message in a fragment entity;
Fragment overall length is the total length (i.e. " length of fragment head length+fragment entity ") of each memory fragmentation;
The length of having used for each memory fragmentation by length (being the length of the message of its storage, is also " length of the length+message body of message header ");
Use state comprises the free time and has used two states;
Last fragment pointer is for indicating at affiliated fragment chained list, the previous memory fragmentation of current memory fragmentation, if the gauge outfit that current memory fragmentation is chained list, last fragment pointed itself;
A rear fragment pointer is for indicating at affiliated fragment chained list, a rear memory fragmentation of current memory fragmentation, if the table tail that current memory fragmentation is chained list, after a fragment pointed itself;
Fragment chained list comprises uses fragment chained list and FREE EXTENT FRAGMENTATION IN chained list;
By fragment chained list pointed, used fragment chained list gauge outfit, all is associated with the last fragment pointer in the fragment head of memory fragmentation and a rear fragment pointer by each with memory fragmentation, forms and has used fragment chained list;
FREE EXTENT FRAGMENTATION IN chained list pointed FREE EXTENT FRAGMENTATION IN chained list gauge outfit; FREE EXTENT FRAGMENTATION IN chained list pointed FREE EXTENT FRAGMENTATION IN chained list gauge outfit, all free memory fragments are associated by the last fragment pointer in the fragment head of each free memory fragment and a rear fragment pointer, form FREE EXTENT FRAGMENTATION IN chained list;
Message comprises message header and message body; Message header is for storing message long (being the length of the length+message body of message header) and the associated web socket handle (and IO handle) of message, the migration of described web socket handle for guiding message.Message body is the particular content of message, and it can passage or picture etc.
S102, judges whether to find fragment overall length to be greater than the free memory fragment of " fragment head length+L ", if so, enters step S103; Otherwise adjacent idle memory fragmentation is recombinated, return to step S101;
In embodiment of the present invention step S101-S102, if carried out after first round fragment restructuring, from first to last travel through for the second time FREE EXTENT FRAGMENTATION IN chained list and still can not find the free memory fragment that fragment overall length is greater than " fragment head length+L ", return to memory allocation error.In the searching loop of step S101-S102, the number of times of searching loop also can be set according to demand, if still can not find the free memory fragment that fragment overall length is greater than " fragment head length+L ", then return to memory allocation error.
The adjacent idle memory fragmentation method of (merging of free memory fragment) of recombinating is specially to (being illustrated in figure 3 the method flow diagram that adjacent idle memory fragmentation is recombinated):
S1020, the first address of content regions is set to the start address of traversal;
S1021, travels through content regions, searches two free memory fragments of adjacent (physical address is continuous);
S1022, if find two adjacent free memory fragments, enters step S1023; Otherwise enter step S1020;
S1023 removes described two adjacent free memory fragments from free memory chained list, then merges, then the gauge outfit of adding FREE EXTENT FRAGMENTATION IN chained list to; The method that merges described two adjacent free memory fragments is:
First, the fragment entity of the free memory fragment after merging using " the fragment entity of the fragment head of the fragment entity of last memory fragmentation+rear memory fragmentation+rear memory fragmentation " in adjacent idle memory fragmentation;
Then, the chip length in the fragment head of the last memory fragmentation of corresponding modify, last fragment pointer, a rear fragment pointer field;
Finally, the fragment entity of the free memory fragment by the fragment head of amended last memory fragmentation and after merging combines, and forms the free memory fragment after merging.
S1024, the start address of traversal is set to next physical address of the free memory fragment after merging, returns to step S1021;
In step S1020-S1024, though adjacent memory fragment length may be different, physical address is continuous, joins end to end; The first address of known memory pool content regions and tail address, start traversal from first address, searches two adjacent FREE EXTENT FRAGMENTATION IN of front and back, after finding, first described two adjacent FREE EXTENT FRAGMENTATION IN remove from free memory chained list, and then they merge, then the gauge outfit of adding FREE EXTENT FRAGMENTATION IN chained list to.With this rule, travel through whole memory pool content area backward, all two adjacent memory fragmentations are merged.Preliminary merging through the method is processed, and little memory fragmentation is integrated into larger memory fragmentation, for distributing large memory fragmentation to prepare.
A part of physical memory that shared drive is shared by a plurality of processes; Memory pool is open up in shared drive one section fixedly continuous physical memory.Memory pool comprises directorial area and content regions; Directorial area storage comprises first fragment pointer, tail fragment pointer, uses fragment chain list index, FREE EXTENT FRAGMENTATION IN chain list index, 5 signs of content regions length.Content regions is for storing all memory fragmentations, and described memory fragmentation comprises uses memory fragmentation and free memory fragment; When original state, in memory pool, only have a length to equal the memory fragmentation of content regions overall length.
Be illustrated in figure 4 the structural drawing of memory pool; Frag1, frag2, frag3 that the content regions storage of described memory pool is arranged in order ... fragN+1 is N fragment altogether, first fragment pointed fragment frag1, tail fragment pointed fragment fragN+1;
Supposing has 5 with memory fragmentation in content regions: frag2, frag3, frag5, frag8, frag12, these 5 have formed and have used fragment chained list with memory fragmentation, frag2 is gauge outfit, frag12 is table tail, now in directorial area, uses fragment chained list pointed memory fragmentation frag2 (having used fragment chained list gauge outfit); And last fragment pointed itself in the fragment head of memory fragmentation frag2, a rear fragment pointed frag3; Last fragment pointed frag2 in the fragment head of memory fragmentation frag3, a rear fragment pointed frag5, in like manner, can derive last fragment pointer in the fragment head of frag5, frag8, frag12 and the sensing of a rear fragment pointer, not repeat them here.
And free memory fragment has N-5: frag1, frag4, frag6, frag7, frag9, frag10, frag11, frag13, frag14 ... fragN+1, this N-5 free memory fragment formed and used fragment chained list, frag1 is gauge outfit, fragN+1 is table tail, now in directorial area, uses fragment chained list pointed memory fragmentation frag1 (being FREE EXTENT FRAGMENTATION IN chained list gauge outfit); And last fragment pointed itself in the fragment head of memory fragmentation frag1, a rear fragment pointed frag4; Last fragment pointed frag1 in the fragment head of memory fragmentation frag4, a rear fragment pointed frag6, in like manner, can derive frag6, frag7, frag9, frag10, frag11, frag13, frag14 ... last fragment pointer in the fragment head of fragN+1 and the sensing of a rear fragment pointer, do not repeat them here.
S103, judges whether that the fragment overall length of described free memory fragment is greater than " fragment head length+L+ fragment head length " (i.e. " two fragment heads of L+ are long "), if so, enters step S104, otherwise enters step S105;
S104, described free memory fragment is removed from idle chained list, split into two memory fragmentations, last length is the memory fragmentation of " fragment head length+L ", being more made as memory fragmentation to be allocated after new fragment header structure, be inserted into the last-of-chain of using fragment chained list; A rear length is the memory fragmentation of " described fragment overall length-fragment head length-L ", inserts FREE EXTENT FRAGMENTATION IN chained list afterbody after fragment header structure is set.
The described method that splits into two memory fragmentations is specially:
The fragment physical length of the last memory fragmentation after division is set to L, the described message to be stored of its fragment entity carrying, fragment overall length in the fragment head of the last memory fragmentation after corresponding modify division, with length, last fragment pointer, a rear fragment pointer, use mode field, the fragment head of the last memory fragmentation after amended division and fragment entity are combined, form the new memory fragmentation of using.
By the fragment physical length of the rear memory fragmentation after division, be to be set to " the fragment overall length-fragment head length-L before division ", its fragment entity carrying content is empty, fragment overall length in the fragment head of the rear memory fragmentation after relative set division, with length, last fragment pointer, a rear fragment pointer, use mode field, the fragment head of the rear memory fragmentation after amended division and fragment entity are combined, form new free memory fragment.
S105, does not divide, and directly described FREE EXTENT FRAGMENTATION IN is removed from FREE EXTENT FRAGMENTATION IN chained list, and is inserted into and uses fragment chained list afterbody.
Embodiment bis-
Fig. 5 is a kind of memory fragmentation distributor structural drawing based on shared drive of the preferred embodiment of the present invention.Described device comprises:
FREE EXTENT FRAGMENTATION IN chained list spider module, for according to the long L of the message of message to be stored, from first to last travels through FREE EXTENT FRAGMENTATION IN chained list, searches the free memory fragment that fragment overall length is greater than " fragment head length+L ";
The first judge module, finds fragment overall length to be greater than the free memory fragment of " fragment head length+L " for judging whether, if so, enters the second judge module, otherwise, enter fragment recombination module,
The second judge module, for judging whether that the fragment overall length of described free memory fragment is greater than " fragment head length+L+ fragment head length " (i.e. " two fragment heads of L+ are long "), if so, enter fragment division module, otherwise enter, fragment removes and insert module;
Fragment recombination module, for adjacent idle memory fragmentation is recombinated, then returns to FREE EXTENT FRAGMENTATION IN chained list spider module;
Fragment division module, for described free memory fragment is removed from idle chained list, split into two memory fragmentations, last length is the memory fragmentation of " fragment head length+L ", being more made as memory fragmentation to be allocated after new fragment header structure, be inserted into the last-of-chain of using fragment chained list; A rear length is the memory fragmentation of " described fragment overall length-fragment head length-L ", inserts FREE EXTENT FRAGMENTATION IN chained list afterbody after fragment header structure is set.
The described method that splits into two memory fragmentations is specially:
The fragment physical length of the last memory fragmentation after division is set to L, the described message to be stored of its fragment entity carrying, fragment overall length in the fragment head of the last memory fragmentation after corresponding modify division, with length, last fragment pointer, a rear fragment pointer, use mode field, the fragment head of the last memory fragmentation after amended division and fragment entity are combined, form the new memory fragmentation of using.
By the fragment physical length of the rear memory fragmentation after division, be to be set to " the fragment overall length-fragment head length-L before division ", its fragment entity carrying content is empty, fragment overall length in the fragment head of the rear memory fragmentation after relative set division, with length, last fragment pointer, a rear fragment pointer, use mode field, the fragment head of the rear memory fragmentation after amended division and fragment entity are combined, form new free memory fragment.
Fragment removes and insert module, for directly described FREE EXTENT FRAGMENTATION IN being removed from FREE EXTENT FRAGMENTATION IN chained list, and is inserted into and uses fragment chained list afterbody.
Further, described fragment recombination module also comprises (structural drawing that shown in Fig. 6 is fragment recombination module):
Traversal start address initialization module, for initialization, the first address of content regions is set to the start address of traversal;
Content regions spider module, travels through content regions, searches two free memory fragments of adjacent (physical address is continuous);
The 3rd judge module, finds two adjacent free memory fragments for judging whether, if enter fragment, merges module; Otherwise return to traversal start address initialization module;
Fragment merges module, for described two adjacent free memory fragments are removed from free memory chained list, then merges, then the gauge outfit of adding FREE EXTENT FRAGMENTATION IN chained list to;
The method that merges described two adjacent free memory fragments is:
First, the fragment entity of the free memory fragment after merging using " the fragment entity of the fragment head of the fragment entity of last memory fragmentation+rear memory fragmentation+rear memory fragmentation " in adjacent idle memory fragmentation;
Then, the chip length in the fragment head of the last memory fragmentation of corresponding modify, last fragment pointer, a rear fragment pointer field;
Finally, the fragment entity of the free memory fragment by the fragment head of amended last memory fragmentation and after merging combines, and forms the free memory fragment after merging.
Next physical address arranges module, is set to next physical address of the free memory fragment after merging, then returned content district spider module for the start address of traversal;
Those having ordinary skill in the art will appreciate that, the all or part of step realizing in above-described embodiment method can complete by programmed instruction related hardware, described program can be stored in a computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any modifications of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., within all should being included in protection scope of the present invention.

Claims (10)

1. the memory fragmentation distribution method based on shared drive, is characterized in that, said method comprising the steps of:
According to the long L of the message of message to be stored, from first to last travel through FREE EXTENT FRAGMENTATION IN chained list, search the free memory fragment that fragment overall length is greater than " fragment head length+L ";
Judge whether to find fragment overall length to be greater than the free memory fragment of " fragment head length+L ", if do not find fragment overall length to be greater than the free memory fragment of " fragment head length+L ", adjacent idle memory fragmentation is recombinated, return to step and " according to the long L of the message of message to be stored; from first to last travel through FREE EXTENT FRAGMENTATION IN chained list, search the free memory fragment that fragment overall length is greater than " fragment head length+L " ";
If find fragment overall length to be greater than the free memory fragment of " fragment head length+L ",
The fragment overall length that judges whether described free memory fragment is greater than " two fragment heads of L+ are long ", if, described free memory fragment is removed from idle chained list, split into two memory fragmentations, last length is the memory fragmentation of " fragment head length+L ", being more made as memory fragmentation to be allocated after new fragment header structure, be inserted into the last-of-chain of using fragment chained list; A rear length is the memory fragmentation of " described fragment overall length-fragment head length-L ", inserts FREE EXTENT FRAGMENTATION IN chained list afterbody after fragment header structure is set; Otherwise directly described FREE EXTENT FRAGMENTATION IN is removed from FREE EXTENT FRAGMENTATION IN chained list, and be inserted into and use fragment chained list afterbody.
2. the memory fragmentation distribution method based on shared drive as claimed in claim 1, is characterized in that, the described method that adjacent idle memory fragmentation is recombinated is specially
The first address of content regions is set to the start address of traversal;
Traversal content regions, searches two adjacent free memory fragments;
If find two adjacent free memory fragments, described two adjacent free memory fragments are removed from free memory chained list, then merge, add again the gauge outfit of FREE EXTENT FRAGMENTATION IN chained list to, then the start address of traversal is set to next physical address of the free memory fragment after merging, return to step " traversal content regions, searches two adjacent free memory fragments "; Otherwise return to step " first address of content regions is set to the start address of traversal ".
3. the memory fragmentation distribution method based on shared drive as claimed in claim 2, is characterized in that,
The method that merges described two adjacent free memory fragments is:
First, the fragment entity of the free memory fragment after merging using " the fragment entity of the fragment head of the fragment entity of last memory fragmentation+rear memory fragmentation+rear memory fragmentation " in adjacent idle memory fragmentation;
Then, the chip length in the fragment head of the last memory fragmentation of corresponding modify, last fragment pointer, a rear fragment pointer field;
Finally, the fragment entity of the free memory fragment by the fragment head of amended last memory fragmentation and after merging combines, and forms the free memory fragment after merging.
4. the memory fragmentation distribution method based on shared drive as claimed in claim 2, is characterized in that,
The described method that splits into two memory fragmentations is specially:
The fragment physical length of the last memory fragmentation after division is set to L, the described message to be stored of its fragment entity carrying, fragment overall length in the fragment head of the last memory fragmentation after corresponding modify division, with length, last fragment pointer, a rear fragment pointer, use mode field, the fragment head of the last memory fragmentation after amended division and fragment entity are combined, form the new memory fragmentation of using.
By the fragment physical length of the rear memory fragmentation after division, be to be set to " the fragment overall length-fragment head length-L before division ", its fragment entity carrying content is empty, fragment overall length in the fragment head of the rear memory fragmentation after relative set division, with length, last fragment pointer, a rear fragment pointer, use mode field, the fragment head of the rear memory fragmentation after amended division and fragment entity are combined, form new free memory fragment.
5. the memory fragmentation distribution method based on shared drive as described in any one claim in claim 1-4, is characterized in that,
Memory fragmentation comprises fragment head and fragment entity;
Fragment entity is the internal memory of actual allocated, is the carrier of message stores, carries a message in a fragment entity;
Fragment head comprises fragment overall length, uses length, last fragment pointer, a rear fragment pointer, 5 fields of use state;
Fragment overall length is each memory fragmentation " length of fragment head length+fragment entity ";
By length, be " length of the length+message body of message header " in each memory fragmentation;
Use state comprises the free time and has used two states;
Last fragment pointer is for indicating at affiliated fragment chained list, the previous memory fragmentation of current memory fragmentation, if the gauge outfit that current memory fragmentation is chained list, last fragment pointed itself;
A rear fragment pointer is for indicating at affiliated fragment chained list, a rear memory fragmentation of current memory fragmentation, if the table tail that current memory fragmentation is chained list, after a fragment pointed itself;
Message comprises message header and message body; Message header comprises message length and IO handle field, the migration of described IO handle for guiding message; Message body is the particular content of message.
6. the memory fragmentation distribution method based on shared drive as claimed in claim 5, is characterized in that,
Fragment chained list comprises uses fragment chained list and FREE EXTENT FRAGMENTATION IN chained list;
By fragment chained list pointed, used fragment chained list gauge outfit, all is associated with the last fragment pointer in the fragment head of memory fragmentation and a rear fragment pointer by each with memory fragmentation, forms and has used fragment chained list;
FREE EXTENT FRAGMENTATION IN chained list pointed FREE EXTENT FRAGMENTATION IN chained list gauge outfit; FREE EXTENT FRAGMENTATION IN chained list pointed FREE EXTENT FRAGMENTATION IN chained list gauge outfit, all free memory fragments are associated by the last fragment pointer in the fragment head of each free memory fragment and a rear fragment pointer, form FREE EXTENT FRAGMENTATION IN chained list.
7. the memory fragmentation distribution method based on shared drive as claimed in claim 1, is characterized in that,
The number of times of searching loop is set according to demand, if still can not find the free memory fragment that fragment overall length is greater than " fragment head length+L ", then returns to memory allocation error.
8. the memory fragmentation distribution method based on shared drive as claimed in claim 1, is characterized in that,
A part of physical memory that shared drive is shared by a plurality of processes; Memory pool is open up in shared drive one section fixedly continuous physical memory;
Memory pool comprises directorial area and content regions; Directorial area storage comprises first fragment pointer, tail fragment pointer, uses fragment chain list index, FREE EXTENT FRAGMENTATION IN chain list index, 5 signs of content regions length;
Content regions is for storing all memory fragmentations, and described memory fragmentation comprises uses memory fragmentation and free memory fragment; When original state, in memory pool, only have a length to equal the memory fragmentation of content regions overall length.
9. the memory fragmentation distributor based on shared drive, is characterized in that, described device comprises:
FREE EXTENT FRAGMENTATION IN chained list spider module, for according to the long L of the message of message to be stored, from first to last travels through FREE EXTENT FRAGMENTATION IN chained list, searches the free memory fragment that fragment overall length is greater than " fragment head length+L ";
The first judge module, finds fragment overall length to be greater than the free memory fragment of " fragment head length+L " for judging whether, if so, enters the second judge module, otherwise, enter fragment recombination module;
The second judge module, for judging whether that the fragment overall length of described free memory fragment is greater than " two fragment heads of L+ are long ", if so, enters fragment division module, otherwise enter, fragment removes and insert module;
Fragment recombination module, for adjacent idle memory fragmentation is recombinated, then returns to FREE EXTENT FRAGMENTATION IN chained list spider module;
Fragment division module, for described free memory fragment is removed from idle chained list, split into two memory fragmentations, last length is the memory fragmentation of " fragment head length+L ", being more made as memory fragmentation to be allocated after new fragment header structure, be inserted into the last-of-chain of using fragment chained list; A rear length is the memory fragmentation of " described fragment overall length-fragment head length-L ", inserts FREE EXTENT FRAGMENTATION IN chained list afterbody after fragment header structure is set;
Fragment removes and insert module, for directly described FREE EXTENT FRAGMENTATION IN being removed from FREE EXTENT FRAGMENTATION IN chained list, and is inserted into and uses fragment chained list afterbody.
10. the memory fragmentation distributor based on shared drive as claimed in claim 9, is characterized in that:
Described fragment recombination module also comprises:
Traversal start address initialization module, for initialization, the first address of content regions is set to the start address of traversal;
Content regions spider module, traversal content regions, searches two adjacent free memory fragments;
The 3rd judge module, finds two adjacent free memory fragments for judging whether, if enter fragment, merges module; Otherwise return to traversal start address initialization module;
Fragment merges module, for described two adjacent free memory fragments are removed from free memory chained list, then merges, then the gauge outfit of adding FREE EXTENT FRAGMENTATION IN chained list to;
Next physical address arranges module, is set to next physical address of the free memory fragment after merging, then returned content district spider module for the start address of traversal.
CN201410401240.2A 2014-08-14 2014-08-14 Memory fragment allocation method and device based on shared memory Pending CN104199781A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410401240.2A CN104199781A (en) 2014-08-14 2014-08-14 Memory fragment allocation method and device based on shared memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410401240.2A CN104199781A (en) 2014-08-14 2014-08-14 Memory fragment allocation method and device based on shared memory

Publications (1)

Publication Number Publication Date
CN104199781A true CN104199781A (en) 2014-12-10

Family

ID=52085077

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410401240.2A Pending CN104199781A (en) 2014-08-14 2014-08-14 Memory fragment allocation method and device based on shared memory

Country Status (1)

Country Link
CN (1) CN104199781A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107092206A (en) * 2016-02-17 2017-08-25 霍尼韦尔国际公司 With automatic International Electrotechnical Commission(IEC)The input/output of address generation(I/O)Binding
CN108108307A (en) * 2016-11-24 2018-06-01 中移(杭州)信息技术有限公司 A kind of method for processing resource and terminal
CN109710408A (en) * 2018-12-24 2019-05-03 杭州迪普科技股份有限公司 EMS memory management process and device
US10409684B2 (en) 2016-04-29 2019-09-10 Beijing Xiaomi Mobile Software Co., Ltd. Method, device and storage medium for cleaning memory
CN110941564A (en) * 2018-09-25 2020-03-31 杭州海康威视数字技术股份有限公司 Storage space allocation method and device, electronic equipment and storage medium

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1963788A (en) * 2005-11-08 2007-05-16 中兴通讯股份有限公司 A managing method for EMS memory
CN101093455A (en) * 2006-06-21 2007-12-26 中兴通讯股份有限公司 Allocation method for internal memory pool in embedded type operation system
CN101320351A (en) * 2008-06-27 2008-12-10 华中科技大学 Internal memory distribution, cleaning and releasing method, and internal memory management apparatus
CN101853210A (en) * 2010-05-25 2010-10-06 惠州华阳通用电子有限公司 Memory management method and device
CN102156675A (en) * 2010-02-12 2011-08-17 中兴通讯股份有限公司 Method and device for allocating memory
US20110225182A1 (en) * 2010-03-10 2011-09-15 Fujitsu Limited Data management device and data management method
CN102332029A (en) * 2011-10-15 2012-01-25 西安交通大学 Hadoop-based mass classifiable small file association storage method
CN102455976A (en) * 2010-11-02 2012-05-16 上海宝信软件股份有限公司 Middleware memory management scheme
CN103176911A (en) * 2011-12-20 2013-06-26 陕西银河网电科技有限公司 Embedded type software security memory management method
CN103226520A (en) * 2013-04-02 2013-07-31 中国科学院信息工程研究所 Self-adaptive cluster memory management method and server clustering system
CN103389945A (en) * 2013-07-05 2013-11-13 杭州华三通信技术有限公司 Memory management method and device
CN103617123A (en) * 2013-11-21 2014-03-05 珠海金山网络游戏科技有限公司 Method and system for memory management by memory block

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1963788A (en) * 2005-11-08 2007-05-16 中兴通讯股份有限公司 A managing method for EMS memory
CN101093455A (en) * 2006-06-21 2007-12-26 中兴通讯股份有限公司 Allocation method for internal memory pool in embedded type operation system
CN101320351A (en) * 2008-06-27 2008-12-10 华中科技大学 Internal memory distribution, cleaning and releasing method, and internal memory management apparatus
CN102156675A (en) * 2010-02-12 2011-08-17 中兴通讯股份有限公司 Method and device for allocating memory
US20110225182A1 (en) * 2010-03-10 2011-09-15 Fujitsu Limited Data management device and data management method
CN101853210A (en) * 2010-05-25 2010-10-06 惠州华阳通用电子有限公司 Memory management method and device
CN102455976A (en) * 2010-11-02 2012-05-16 上海宝信软件股份有限公司 Middleware memory management scheme
CN102332029A (en) * 2011-10-15 2012-01-25 西安交通大学 Hadoop-based mass classifiable small file association storage method
CN103176911A (en) * 2011-12-20 2013-06-26 陕西银河网电科技有限公司 Embedded type software security memory management method
CN103226520A (en) * 2013-04-02 2013-07-31 中国科学院信息工程研究所 Self-adaptive cluster memory management method and server clustering system
CN103389945A (en) * 2013-07-05 2013-11-13 杭州华三通信技术有限公司 Memory management method and device
CN103617123A (en) * 2013-11-21 2014-03-05 珠海金山网络游戏科技有限公司 Method and system for memory management by memory block

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107092206A (en) * 2016-02-17 2017-08-25 霍尼韦尔国际公司 With automatic International Electrotechnical Commission(IEC)The input/output of address generation(I/O)Binding
CN107092206B (en) * 2016-02-17 2022-01-04 霍尼韦尔国际公司 Input/output (I/O) binding with automatic International Electrotechnical Commission (IEC) address generation
US10409684B2 (en) 2016-04-29 2019-09-10 Beijing Xiaomi Mobile Software Co., Ltd. Method, device and storage medium for cleaning memory
CN108108307A (en) * 2016-11-24 2018-06-01 中移(杭州)信息技术有限公司 A kind of method for processing resource and terminal
CN110941564A (en) * 2018-09-25 2020-03-31 杭州海康威视数字技术股份有限公司 Storage space allocation method and device, electronic equipment and storage medium
CN110941564B (en) * 2018-09-25 2022-03-04 杭州海康威视数字技术股份有限公司 Storage space allocation method and device, electronic equipment and storage medium
CN109710408A (en) * 2018-12-24 2019-05-03 杭州迪普科技股份有限公司 EMS memory management process and device

Similar Documents

Publication Publication Date Title
TWI660281B (en) Method and device for writing blockchain business data and method for determining business subset
US8930593B2 (en) Method for setting parameters and determining latency in a chained device system
US8984085B2 (en) Apparatus and method for controlling distributed memory cluster
US8381230B2 (en) Message passing with queues and channels
CN104199781A (en) Memory fragment allocation method and device based on shared memory
CN102045258B (en) Data caching management method and device
TWI604371B (en) System and method for enabling high read rates to data element lists
CN102142032B (en) Method and system for reading and writing data of distributed file system
US10114866B2 (en) Memory-constrained aggregation using intra-operator pipelining
CN103425435B (en) Disk storage method and disk storage system
CN111124270B (en) Method, apparatus and computer program product for cache management
KR102028428B1 (en) Distributed file system using torus network and method for configuring and operating of the distributed file system using torus network
CN102622412A (en) Method and device of concurrent writes for distributed file system
CN103389945B (en) Memory management method and device
CN112905342A (en) Resource scheduling method, device, equipment and computer readable storage medium
US20160301754A1 (en) Distributed file system using torus network and method for configuring and operating distributed file system using torus network
TWI704488B (en) Network device, memory system for the network device, and method for operating the network device
TW201716983A (en) System and method for implementing hierarchical distributed-linked lists for network devices
CN103986585A (en) Message preprocessing method and device
US8543722B2 (en) Message passing with queues and channels
CN102270207B (en) Online multimedia information mining oriented data caching method and system
CN108833200A (en) A kind of adaptive unidirectional transmission method of large data files and device
CN112099728B (en) Method and device for executing write operation and read operation
CN115758975A (en) Layout optimization method, device and equipment and computer readable storage medium
CN104598390B (en) A kind of date storage method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C53 Correction of patent of invention or patent application
CB02 Change of applicant information

Address after: 518057 Guangdong Province, Shenzhen city Nanshan District District Science Park Keyuan Road branch science park A1 unit 4 Building 403-405 unit

Applicant after: BAC Information Technology Co., Ltd.

Address before: Unit B1 9 building 518057 Guangdong city of Shenzhen province Nanshan District high in the four EVOC Technology Building No. 31

Applicant before: BAC Information Technology Co., Ltd.

SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 518057 Guangdong city of Shenzhen province Nanshan District Guangdong streets high in the four Longtaili Technology Building Room 325 No. 30

Applicant after: BAC Information Technology Co., Ltd.

Address before: 518057 Guangdong Province, Shenzhen city Nanshan District District Science Park Keyuan Road branch science park A1 unit 4 Building 403-405 unit

Applicant before: BAC Information Technology Co., Ltd.

CB02 Change of applicant information
CB02 Change of applicant information

Address after: 518057 Guangdong city of Shenzhen province Nanshan District Guangdong streets high in the four Longtaili Technology Building Room 325 No. 30

Applicant after: Shenzhen Monternet encyclopedia Information Technology Co. Ltd.

Address before: 518057 Guangdong city of Shenzhen province Nanshan District Guangdong streets high in the four Longtaili Technology Building Room 325 No. 30

Applicant before: BAC Information Technology Co., Ltd.

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20141210