CN101676883A - Memory allocation and management method - Google Patents

Memory allocation and management method Download PDF

Info

Publication number
CN101676883A
CN101676883A CN200810211521A CN200810211521A CN101676883A CN 101676883 A CN101676883 A CN 101676883A CN 200810211521 A CN200810211521 A CN 200810211521A CN 200810211521 A CN200810211521 A CN 200810211521A CN 101676883 A CN101676883 A CN 101676883A
Authority
CN
China
Prior art keywords
memory
block
memory block
header
field
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
CN200810211521A
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.)
Inventec Corp
Original Assignee
Inventec Corp
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 Inventec Corp filed Critical Inventec Corp
Priority to CN200810211521A priority Critical patent/CN101676883A/en
Publication of CN101676883A publication Critical patent/CN101676883A/en
Pending legal-status Critical Current

Links

Images

Landscapes

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

Abstract

The invention relates to a memory allocation and management method, which is used for allocating space of a memory under an environment with the absence of an operating system. The method comprises the following steps: receiving an allocation request; searching a memory to obtain a plurality of memory blocks meeting the allocation request; selecting the smallest memory block in a plurality of memory blocks meeting the allocation request; allocating the allocation request to the smallest memory block and dividing the smallest memory block into a used memory block and an unused memory block; andproviding the used memory block with a first block heading and providing the unused memory block with a second block heading.

Description

The method of Memory Allocation and management
Technical field
The invention relates to the method for a kind of Memory Allocation and management, and particularly do not have the Memory Allocation of operating system and a method of management relevant for a kind of.
Background technology
Along with the development of computing machine is maked rapid progress, the computer utility scope is also calculated from early stage science, to each aspects relevant with the human lives such as data processing, production management, computer aided system and liaisons.In the electronic industry, memory device for various arithmetic systems, computing machine, and peripheral unit in considerable application is all arranged, the raising day by day along with to the operating speed and the usefulness of system also improves for the speed of internal memory and the requirement of management thereof thereupon.
Has operating system (operation system; OS) under the environment, the management of internal memory can be carried out reality by a cover corresponding algorithm (algorithms) and does with distributing, and makes the programmer when developing software, and can consider that internal memory effectively uses and distribution.
But, if at the environment that does not have operating system, or after being assigned to a memory headroom, how in this environment, to manage voluntarily and the use internal memory, especially simple and efficient use internal memory is just become an important problem.
Therefore the present invention proposes a kind of can be under the environment that does not have operating system, distribute and the method for MOS.
Summary of the invention
Therefore purpose of the present invention is exactly in the method that a kind of Memory Allocation and management are provided, with management and storage allocation under the environment that does not have operating system.
To achieve these goals, the present invention proposes the method for a kind of Memory Allocation and management, with under the environment that does not have operating system, distributes the space of an internal memory, comprises: receive one and distribute requirement; Search internal memory, to obtain meeting a plurality of memory blocks that distribute requirement; In satisfactory memory block, select a minimum memory block; To distribute to require to be dispensed to minimum memory block, and make minimum memory block be cut into one and used memory block and not use memory block; Provide one first block header to using memory block; And provide one second block header to not using memory block.
Provide the step of the first block header to comprise the 4th field that the position of one time one block header is write the first block header, the size of using memory block is write the 5th field of the first block header, with the 6th field mark of the first block header for using.Provide the step of one second block header to comprise the 4th field that the position of one time one block header is write the second block header, the size of not using memory block is write the 5th field of the second block header, is to use with the 6th field mark of the second block header.The method more comprises an internal memory header of revising internal memory.
To achieve these goals, another embodiment of the present invention provides the method for a kind of Memory Allocation and management, with under the environment that does not have operating system, discharges the space of an internal memory, comprises: the release request that receives memory block; Judge the memory block discharged last memory block whether be used with back one memory block; And the block header of revising the memory block that is discharged, the 6th field in the block header is not denoted as use.
Wherein when last memory block is not used, comprises and merge last memory block and the memory block that is discharged, wherein also comprise a block header of revising last memory block, and the block header of deleting the memory block that is discharged.When back one memory block when not being used, comprise the memory block that merges back one memory block and discharged, the block header of the memory block that wherein also comprises modification and discharged, and the block header of deletion back one memory block.Also comprise an internal memory header of revising internal memory in the method.
The method of Memory Allocation of the present invention and management can see through simple and efficient mode, under the environment that does not have operating system, under the environment as Option ROM, distributes and the managing internal memory space voluntarily.OptionROM can be included in Basic Input or Output System (BIOS) (Basic Input-output system; BIOS) among, or build on video graphics array card (VGA card), local area network card (Lan card), the disk array card hardware such as (RAIDcard).
Description of drawings
For described and other purpose of the present invention, feature, advantage and embodiment can be become apparent, being described in detail as follows of appended accompanying drawing:
Fig. 1 is the synoptic diagram of method one preferred embodiment of Memory Allocation of the present invention and management;
Fig. 2 is the process flow diagram of Memory Allocation of the present invention and management method first embodiment;
Fig. 3 A and Fig. 3 B are the enforcement synoptic diagram of Memory Allocation of the present invention and management method first embodiment;
Fig. 4 is the process flow diagram of method second embodiment of Memory Allocation of the present invention and management;
Fig. 5 A and Fig. 5 B are the enforcement synoptic diagram of Memory Allocation of the present invention and management method second embodiment;
Fig. 6 A and Fig. 6 B are another enforcement synoptic diagram of Memory Allocation of the present invention and management method second embodiment.
[primary clustering symbol description]
100: internal memory 102: used memory block
104: do not use memory block 110: the internal memory header
114: the second fields of 112: the first fields
Field 120 in 116: the three: the block header
124: the five fields of 122: the four fields
Field 210~260 in 126: the six: step
300: internal memory 302: the internal memory header
306: the second fields of 304: the first fields
Field 310 in 308: the three: memory block
312: 314: the four fields of block header
318: the six fields of 316: the five fields
330: used 332: the first block headers of memory block
336: the five fields of 334: the four fields
Field 340 in 338: the six: do not use memory block
344: the four fields of 342: the second block headers
348: the six fields of 346: the five fields
410~470: step 500: internal memory
520: the second memory blocks of 510: the first memory blocks
528: the six fields of 522: the second block headers
Memory block 600 in 530: the three: internal memory
612: the first block headers of 610: the first memory blocks
616: the five fields of 614: the four fields
620: the second memory blocks of 618: the six fields
630: the three memory blocks of 622: the second block headers
632: the three block headers 640: big memory block
Embodiment
Below will clearly demonstrate spirit of the present invention with accompanying drawing and detailed description, have in the technical field under any and know that usually the knowledgeable is after understanding preferred embodiment of the present invention, when can be by the technology of teachings of the present invention, change and modification, it does not break away from spirit of the present invention and scope.
When the continuous memory headroom of one of request memory, even if the memory headroom of all untapped fragments (fragmentation) add up and satisfy the demands, still can't meet the memory requirements of continuous space, this time require failure.Therefore, the present invention just proposes the method for a kind of Memory Allocation and management, particularly be applied under the environment of no operating system and carry out dynamic-configuration, with when not knowing next required memory size or not knowing d/d space big or small, distribute a bulk of contiguous memory space as much as possible.
With reference to Fig. 1, it is the synoptic diagram of method one preferred embodiment of Memory Allocation of the present invention and management.Internal memory 100 has an internal memory header (memory header) 110, and when storage allocation each time, using memory block 102 to add block header (block header) 120 in the memory block 104 with not using, with the relevant information of record Memory Allocation.
Include one first field 112, one second field 114, one the 3rd field 116 in the internal memory header 110.Wherein first field 112 is in order to writing down the reference position of first block header 120, and second field 114 is that 116 of the 3rd fields are the memory headroom sizes that has distributed away in order to record in order to the size in record monoblock internal memory 100 spaces.Wherein first field 112, second field 114, the 3rd field 116 respectively take 4 positions (byte), and internal memory header 110 takies 12 positions altogether.
Then include one the 4th field 122, one the 5th field 124, one the 3rd field 126 in the block header 120.Wherein the 4th field 122 is in order to writing down the reference position of a time block header, and the 5th field 124 is in order to write down the size that this has used memory block 102 or has not used memory block 104.126 of the 6th fields are that this block of expression is for using or not using.Wherein the 4th field 122, the 5th field 124 respectively take 4 positions, the 6th field 126 takies 1 position, each block header 120 takies 9 positions altogether, shared space is quite few, can provide more memory headroom for distribution, and pass through the state that the 6th header 126 indicates blocks, make distribution more easy.
With reference to Fig. 2, it is the process flow diagram of Memory Allocation of the present invention and management method first embodiment.Present embodiment is in order to when receiving the storage allocation requirement, finds out in the memory block of fragment the memory headroom that I is utilized and distributes, and to keep the bigger internal memory of block, the requirement after keeping for.
Step 210 is for receiving the requirement of a storage allocation, and step 220 meets the not use memory block that this requires size at present for searching, if can not find the satisfactory memory block that do not use, then enters step 230, and replying the result is zero.If find the satisfactory memory block that do not use, then enter step 240, these satisfactory uses in the memory block, selecting a minimum and satisfactory memory block distributes it, then, step 250 is for adding the block header at the memory block that is assigned to, and the data of correspondence are write the 4th field, the 5th field in the block header, and changes the state in the 6th field.At last, step 260 is for revising the 3rd field in the internal memory header.
With reference to Fig. 3 A and Fig. 3 B, it is the enforcement synoptic diagram of Memory Allocation of the present invention and management method first embodiment.Among Fig. 3 A, internal memory 300 only meets this requirement at a bulk of memory block 310 that do not use of reference position, block header 312 positions of first field, 304 these memory blocks 310 of record in the internal memory header 302, second field 306 is the size in record full memory space, the memory size that the 3rd field 308 has been distributed for record.314 of the 4th blocks of the block header 312 of memory block 310 are positions of a record time block header (not shown), and 316 of the 5th fields are the block sizes of this memory block 310 of record, and 318 of the 6th fields are that this block of expression is not used.
After requiring to be dispensed to this memory block 310, shown in Fig. 3 B, this block is split into and uses memory block 330 and do not use memory block 340, and before using memory block 330 and not using memory block 340, providing the first block header 332, the second block header 342 separately, the size of wherein having used memory block 330 is for requiring to distribute according to this.
First field 304 of internal memory header 302 is for pointing to the reference position of the first block header 332 that has used memory block 330, and second field 306 is the size of all memory headrooms of record, and 308 of the 3rd fields are the memory headroom size of record to dispense.
The position of having used the first block header 332 of memory block 330 can continue to use former block header 312, the 4th field 334 of the first block header 332 is not promptly used the reference position of the second block header 342 of memory block 340 for pointing to a time memory block.336 of the 5th fields of the first block header 332 are in order to writing down the size of using memory block 330 of this distribution, and 338 of the 6th fields are that this block of mark is for using.
Not using the 4th field 344 of the second block header 342 of memory block 340 is to point to the secondly block header reference position of a memory block (not shown), this does not use the size of memory block 340 to the 5th field 346 for record, requires next time to compare to provide.This block of the 6th field 348 marks is not used.
Memory Allocation of the present invention and management method, can see through reference position, block size, the user mode that the block header is understood each memory block, distribute in being labeled as untapped memory block, to choose a minimum memory block that meets the distribution requirement, keep bigger memory block then and give requirement afterwards.
With reference to figure, it is the process flow diagram of method second embodiment of Memory Allocation of the present invention and management.Present embodiment is in order to after finishing instruction, rewrites the 6th field of block header, this memory block is not labeled as uses, and discharging the space of this memory block, and the data of the size of storage allocation in the 3rd field of updating memory header.
Step 410 is for receiving the requirement that discharges a memory block, whether step 420 all is used for the front and back block of judging the memory block that is discharged, memory block as front and back all is used, then enter step 430, the 6th field in the block header of the memory block that modification is discharged, it is not labeled as use, and then, step 440 is finished for replying action.
If in step 420, the last memory block of the memory block that is discharged and/or back one memory block are not used, and then enter step 450, merge the memory block and untapped last memory block and/or back one memory block that are discharged.In the step 450, also include to keep and arrange block header the preceding, the block header after deletion is arranged in is to discharge the shared space of block header.In the step 460, also comprise the data of not using memory block after merging are write the block header that is kept, and further revise the data in the internal memory header.Then step 470 is finished for replying action.
With reference to Fig. 5 A and Fig. 5 B, it is the enforcement synoptic diagram of Memory Allocation of the present invention and management method second embodiment simultaneously.Among Fig. 5 A, include one first memory block 510, one second memory block 520, one the 3rd memory block 530 in the internal memory 500.At this moment, first memory block 510, second memory block 520, the 3rd memory block 530 all are to be in the user mode.
Among Fig. 5 B, the work of second memory block 520 finishes, and first memory block 510 before and after it and the work of the 3rd memory block 530 are still underway.After second memory block 520 is discharged, revise the 6th field 528 in the second block header 522 of second memory block 520, the state of the 6th field 528 is not changed into use, and further revise the 3rd field in the internal memory header (not shown).
With reference to Fig. 6 A and Fig. 6 B, it is another enforcement synoptic diagram of Memory Allocation of the present invention and management method second embodiment simultaneously.In the present embodiment, include one first memory block 610, one second memory block 620, one the 3rd memory block 630 in the internal memory 600, wherein second memory block 620 has been assigned with away and has carried out work, and first memory block 610 and 630 of the 3rd memory blocks before and after it are not to be used.Behind the end-of-job of second memory block 620, the space of second memory block 620 can be released.
Because first memory block 610 and second memory block 630 of second memory block, 620 front and back all are untapped memory blocks, therefore, after second memory block 620 is discharged, can merge first memory block 610, second memory block 620, the 3rd memory block 630 and be one as 6B figure as shown in memory block 640 greatly.
Wherein, the arrangement first block header 612 the preceding is retained when merging, and the second block header 622 and 632 of the 3rd block headers after being arranged in are deleted, to discharge the space of the second block header 622 and the 3rd block header 632.Among Fig. 6 B, the first block header 612 is the data of this big memory block 640 of record, the 4th field 614 is the reference position of the block header of a sensing time memory block, the 5th field 616 is the space size of this big memory block 640 of record, the 6th field 618 is a unused state for indicating this big memory block 640, and further revises the 3rd field of internal memory header (not shown).
The method of Memory Allocation of the present invention and management can see through simple and efficient mode, under the environment that does not have operating system, under the environment as Option ROM, distributes and the managing internal memory space voluntarily.OptionROM can be included in Basic Input or Output System (BIOS) (Basic Input-output system; BIOS) among, or build on video graphics array card (VGA card), local area network card (Lan card), the disk array card hardware such as (RAIDcard).
Though the present invention discloses as above with a preferred embodiment; right its is not in order to limit the present invention; any person skilled in the art; without departing from the spirit and scope of the present invention; when can being used for a variety of modifications and variations, so protection scope of the present invention is as the criterion when looking the scope that claims define.

Claims (10)

1. the method for Memory Allocation and management is characterized in that, with under the environment that does not have operating system, distributes the space of an internal memory, comprises:
Receive one and distribute requirement;
Search this internal memory, to obtain meeting a plurality of memory blocks that this distribution requires;
In satisfactory described a plurality of memory blocks, select a minimum memory block;
Should distribute to require to be dispensed to this minimum memory block, and make this minimum memory block be cut into one and used memory block and not use memory block;
Provide one first block header to use memory block to this; And
Provide one second block header not use memory block to this.
2. want the method for 1 described Memory Allocation and management according to right, it is characterized in that, provide the step of one first block header to comprise one the 4th field that the position of one time one block header is write this first block header.
3. want the method for 1 described Memory Allocation and management according to right, it is characterized in that, provide the step of one first block header to comprise and used the size of memory block to write one the 5th field of this first block header this.
4. want the method for 1 described Memory Allocation and management according to right, it is characterized in that, provide the step of one first block header to comprise one the 6th field mark with this first block header for using.
5. want the method for 1 described Memory Allocation and management according to right, it is characterized in that, provide the step of one second block header to comprise one the 4th field that the position of one time one block header is write this second block header.
6. want the method for 1 described Memory Allocation and management according to right, it is characterized in that, provide the step of one second block header to comprise and do not use the size of memory block to write one the 5th field of this second block header this.
7. want the method for 1 described Memory Allocation and management according to right, it is characterized in that, one the 6th field mark that provides the step of one second block header to comprise this second block header is to use.
8. the method for Memory Allocation and management is characterized in that, with under the environment that does not have operating system, discharges the space of an internal memory, comprises:
Receive the release request of a memory block;
Judge this memory block discharged a last memory block with one afterwards a memory block whether be used; And
Revise a block header of this memory block that is discharged, one the 6th field in this block header is not denoted as uses.
9. want the method for 8 described Memory Allocation and management according to right, it is characterized in that, when this last memory block is not used, comprises and merge this last memory block and this memory block that is discharged.
10. want the method for 8 described Memory Allocation and management according to right, it is characterized in that, when this back one memory block is not used, comprise this memory block that merges this back one memory block and discharged.
CN200810211521A 2008-09-17 2008-09-17 Memory allocation and management method Pending CN101676883A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200810211521A CN101676883A (en) 2008-09-17 2008-09-17 Memory allocation and management method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200810211521A CN101676883A (en) 2008-09-17 2008-09-17 Memory allocation and management method

Publications (1)

Publication Number Publication Date
CN101676883A true CN101676883A (en) 2010-03-24

Family

ID=42029453

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200810211521A Pending CN101676883A (en) 2008-09-17 2008-09-17 Memory allocation and management method

Country Status (1)

Country Link
CN (1) CN101676883A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853210A (en) * 2010-05-25 2010-10-06 惠州华阳通用电子有限公司 Memory management method and device
CN104111896A (en) * 2014-07-30 2014-10-22 云南大学 Virtual memory management method and virtual memory management device for mass data processing
CN106469121A (en) * 2016-09-09 2017-03-01 深圳大学 A kind of method and device of Memory Allocation
CN107015914A (en) * 2016-01-28 2017-08-04 长城汽车股份有限公司 Data scaling method and system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853210A (en) * 2010-05-25 2010-10-06 惠州华阳通用电子有限公司 Memory management method and device
CN104111896A (en) * 2014-07-30 2014-10-22 云南大学 Virtual memory management method and virtual memory management device for mass data processing
CN104111896B (en) * 2014-07-30 2017-07-14 云南大学 Virtual memory management method and its device in big data processing
CN107015914A (en) * 2016-01-28 2017-08-04 长城汽车股份有限公司 Data scaling method and system
CN106469121A (en) * 2016-09-09 2017-03-01 深圳大学 A kind of method and device of Memory Allocation
CN106469121B (en) * 2016-09-09 2019-12-13 深圳大学 Memory allocation method and device

Similar Documents

Publication Publication Date Title
CN101606130B (en) Method and apparatus for enabling resource allocation identification at the instruction level in a processor system
CN101221536B (en) Internal memory managing method and device of embedded system
EP1619584A1 (en) Memory allocation
CN102169461B (en) Memory system
CN101344861B (en) Smart card internal memory management method
CN103384877A (en) Storage system comprising flash memory, and storage control method
US20170286008A1 (en) Smart storage platform apparatus and method for efficient storage and real-time analysis of big data
CN102707966A (en) Method and device for acceleratively starting operating system, and method, device and terminal for generating prefetched information
CN1996258A (en) Method for implementing dynamic memory pool
CN101180612A (en) Computer system, memory management method, and program thereof
CN103455379A (en) Resource allocation method and system
US9697111B2 (en) Method of managing dynamic memory reallocation and device performing the method
CN101918913A (en) Reclaiming storage on a thin-provisioning storage device
CN104850505B (en) The EMS memory management process and system stacked based on chain type
US10049035B1 (en) Stream memory management unit (SMMU)
CN106557427A (en) The EMS memory management process and device of shared drive data base
CN101676883A (en) Memory allocation and management method
CN102819494A (en) Optimization method for writing in flash memory in sequence
CN103365784A (en) Method and device for memory recycle and allocation
CN100583064C (en) Method and equipment for removing alias addresses from an alias address pool
CN105469173A (en) Method of optimal management on static memory
CN104156316B (en) A kind of method and system of Hadoop clusters batch processing job
CN108255526B (en) System starting and running method and device
CN103514098B (en) For reclaiming the method and system of memory space
CN101008923A (en) Segmentation and paging data storage space management method facing heterogeneous polynuclear system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Open date: 20100324