CN101976224B - Memory management method of embedded system - Google Patents

Memory management method of embedded system Download PDF

Info

Publication number
CN101976224B
CN101976224B CN201010512683.0A CN201010512683A CN101976224B CN 101976224 B CN101976224 B CN 101976224B CN 201010512683 A CN201010512683 A CN 201010512683A CN 101976224 B CN101976224 B CN 101976224B
Authority
CN
China
Prior art keywords
memory
thread
thread heap
free memory
function
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.)
Active
Application number
CN201010512683.0A
Other languages
Chinese (zh)
Other versions
CN101976224A (en
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.)
Tsinghua University
Original Assignee
Tsinghua University
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 Tsinghua University filed Critical Tsinghua University
Priority to CN201010512683.0A priority Critical patent/CN101976224B/en
Publication of CN101976224A publication Critical patent/CN101976224A/en
Application granted granted Critical
Publication of CN101976224B publication Critical patent/CN101976224B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention relates to a memory management method of an embedded system, which comprises the steps of: (1), opening up a physical memory, managing the physical memory by using a turnover thread heap management system, and allocating a memory space for data requirement from the tail end and the head end of a thread heap free memory by the thread heap management system, wherein the thread heap free memory has a normal state N and a turnover state F; (2), dividing all data requirements into a temporary space requirement and an output space requirement, and allocating one end of the thread heap free memory to be a temporary end or an output end by a type thread heap management system according to the data requirements; (3), allocating a head end memory to data required in a temporary space by the thread heap management system; and (4), when a superior function calls a subordinate function, controlling the thread heap free memory to turn over by the thread heap management system, when exiting the subordinate function, releasing a temporary space at the current temporary end, preserving the output space of the output end and merging with the temporary space of the temporary end of the superior function. The invention can realize timely release of the memory, has high operating efficiency, does not generate memory fragments, and can operate stably and efficiently for a long time.

Description

A kind of EMS memory management process of embedded system
Technical field
The present invention relates to a kind of embedded system, particularly about a kind of EMS memory management process of embedded system.
Background technology
The application of embedded system is very extensive, and the function of application program is also very abundant.But because its arithmetic capability and storage capacity are very limited, therefore, the application program that operates on the embedded system must possess the high-efficiency reliable EMS memory management process, could long-time steady operation.Be used for the operating system on the embedded device; Basic memory management mechanism also can be provided self; But for the application program that needs long-time steady operation, repeated multiple times application memory headroom, the base memory administrative mechanism of operating system can't meet the demands.
Theoretically, in the Memory Allocation process, if can realize using in order, backward discharges, then internal memory can in time discharge after using, and can not produce memory fragmentation, and allocative efficiency is the highest, and is minimum to the waste of physical memory resource.But in the general application program, program is very complicated to the demand of internal memory, and the timely release of internal memory is a very big problem.Existing internal memory pool managing method and internal memory garbage reclamation mechanism can partly address this problem, but after long-time the use, negative effects such as a large amount of memory fragmentations, allocative efficiency reduction can generally occur.
Summary of the invention
To the problems referred to above, the purpose of this invention is to provide a kind of can stability and high efficiency for various memory requirements allocation space, effectively solve the memory fragmentation problem, avoid memory overflow, and monitor the EMS memory management process of the embedded system of internal memory behaviour in service in real time.
For realizing above-mentioned purpose; The present invention takes following technical scheme: a kind of EMS memory management process of embedded system; It comprises the steps: that (1) open up a physical memory and pile as thread in the thread radical function of embedded system; And utilize convertible thread heap manager system that this physical memory is managed; From then on all Dram all distributes in the thread heap free memory in the physical memory in this thread, and thread heap manager system is demand data storage allocation space from the head and the tail two ends of thread heap free memory, and thread heap free memory has the normal state N and the attitude F two states that overturns; (2) all demand datas are divided into two types of temporary space demand and output region demands; In same function; To distribute the data of temporary space demand to be interim end at the end that thread is piled free memory according to the type thread heap manager system of demand data, or distribute the data of output region demand to be output terminal; (3) thread heap manager system gives the head end Memory Allocation data of temporary space demand; (4) when higher level's function call subordinate function, thread heap manager system control thread heap free memory overturns, and interim end and output end position are exchanged; When withdrawing from subordinate's function, thread heap free memory discharges the temporary space of current interim end, keeps the output region of output terminal simultaneously, and merges with the interim temporary space of holding of higher level's function.
In the said step (1), said thread heap manager system is that the step of data allocations memory headroom is following from the head and the tail two ends of said thread heap free memory: 1. the head end address of thread heap free memory is S h, the tail end address is S t2. after distributing the internal memory of L length from thread heap free memory head end, the head end address becomes S ' h=S h+ L; 3. after distributing the internal memory of L length from thread heap free memory tail end, the tail end address becomes S ' t=S t-L; 4. S when occurring t≤S h, thread heap free memory exhausts, and thread heap manager system dishes out unusual and this mistake is adjusted, and the thread radical function withdraws from.
In the said step (2); Said demand data classification and corresponding distribution method may further comprise the steps: 1. when a data demand application memory headroom; Needing the type of the own demand of statement is output region demand or temporary space demand, and by thread heap manager system according to this statement with demand data at output terminal or hold allocation space temporarily; 2. when thread heap free memory was in normal state N, for the data of all temporary space demands, thread heap free memory was from head end order assignment internal memory; For the data of all output region demands, thread heap free memory is from tail end order assignment internal memory; 3. when the thread heap was in upset attitude F, for the data of all temporary space demands, thread heap free memory was from tail end order assignment internal memory; For the data of all output region demands, thread heap free memory is from head end order assignment internal memory.
In the said step (4), during the said subordinate of said higher level's function call function, the upset of said thread heap free memory is handled and is comprised the steps: 1. to get into a function f 1The time, the state of thread heap free memory is N or F, the start address of the interim end of thread heap is B 1,0, the start address of thread heap output terminal is D 1,02. function f 1Calling the next stage function f 2Before, the start address of interim end is B in the thread heap free memory 1,1, the start address of output terminal is D in the thread heap free memory 1,13. call the entering function f 2The time, interim end and output terminal overturn, and the state of thread heap free memory becomes anti-attitude F or the N of N or F, and the start address of interim end is B 2,0=D 1,1, the start address of thread heap output terminal is D 2,0=B 1,14. withdraw from function f 2The time, the start address of interim end reverts to B in the thread heap free memory 2,2=B 2,1, the start address of output terminal is D 2,2=D 2,15. get into function f again 1, the state of thread heap free memory becomes N or F again, the constant D of start address of output terminal in the thread heap free memory 1,2=D 1,1, the start address of interim end is B 1,2=D 2,1, function f 2Output data become function f 1Ephemeral data.
The EMS memory management process of said embedded system adopts convertible thread heap manager method.
The present invention is owing to take above technical scheme, and it has the following advantages: 1, the present invention piles as thread owing to opening up a physical memory in the thread radical function that is employed in embedded system, and all memory requirements all utilize this thread heap to satisfy.Thread heap can be from the head and the tail two ends allocation space, in use, both can keep output result's memory headroom, also can in time reclaim temporary space, can guarantee at any time that the remaining space on the thread heap is continuous.Therefore, after long-time the use, neither produce any fragment in the internal memory, allocative efficiency is not affected yet, and can guarantee that application software continues efficient, stable operation.2, the present invention is owing to adopt and to be divided into two types of temporary space demand and output region demands to all demand datas; Head and end from the thread heap obtains internal memory respectively; When function call took place, two kinds of pairing thread distribution end of demand were exchanged, when function withdraws from; Discharge the interim end spaces of current thread heap, reclaim internal memory.Therefore realized that internal memory in time discharges, operational efficiency is high, does not produce memory fragmentation, can efficient for a long time, stable operation.3, the present invention is owing to adopt convertible thread heap manager method that the internal memory of embedded system is managed; Therefore; Can stability and high efficiency be various memory requirements allocation space, and after use in the space, can in time discharge, can reduce the memory requirements peak value of built-in system software; Avoid memory overflow, and monitor the internal memory behaviour in service in real time.The present invention can be widely used in the memory management of embedded system.
Description of drawings
Fig. 1 is that demand data of the present invention distributes synoptic diagram;
Fig. 2 is a thread heap manager of the present invention system control thread heap free memory overturn structure synoptic diagram;
Fig. 3 is a convertible thread heap upset schematic flow sheet of the present invention.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is carried out detailed description.
Like Fig. 1, shown in Figure 2, EMS memory management process of the present invention adopts convertible thread heap manager method, and it may further comprise the steps:
1) in the thread radical function of embedded system, opening up a physical memory 1 piles as thread; And utilize 2 pairs of these physical memories of convertible thread heap manager system to manage; All distribution in the thread heap free memory 3 in the physical memory 1 from then on of all Dram in this thread; Thread heap manager system 2 can be demand data 4 storage allocation spaces from the head and the tail two ends that thread is piled free memory 3, and thread heap free memory 3 has normal state N and upset attitude F two states;
2) all demand datas 4 are divided into two types of temporary space demand and output region demands; In same function; To distribute the data of temporary space demand to be interim end 5 at the end that thread is piled free memory 3 based on the type thread heap manager system 2 of demand data 4, or distribute the data of output region demand to be output 6;
Wherein, the data of output region demand are meant that the memory headroom of a data demand 4 applications need withdraw from the back at function and keep; The data of temporary space demand are meant that the memory headroom of a data demand 4 applications just inner interim use of function, does not need to keep after function withdraws from;
3) owing in the thread radical function, do not have the data of output region demand, so thread heap manager system 2 gives the head end Memory Allocation data of temporary space demand;
Wherein, the thread radical function is meant the function of opening up the thread heap, in the thread radical function; Because the state of thread heap is normal state N, thread heap head end is interim end, and thread heap end is an output terminal; Therefore the space type of opening up in the thread heap radical function can not be appointed as the output region demand, and can only be appointed as the temporary space demand, and the thread heap is these demand order assignment spaces from head end; After the thread radical function withdraws from, the shared internal memory of thread heap will all discharge;
4) as shown in Figure 2, when higher level's function call subordinate function, thread heap manager system 2 control threads heap free memories 3 overturn, and interim end and output end position are exchanged; When withdrawing from subordinate's function, thread heap free memory 3 discharges the temporary space of current interim end, keeps the output region of output terminal simultaneously; And merge with the temporary space of the interim end of higher level's function; Use for higher level's function, so the present invention realized the function that can internal memory in time be discharged that its operational efficiency is high; Do not produce memory fragmentation, and can efficient for a long time, stable operation.
Above-mentioned steps 1) in, thread heap manager system 2 is that the step of data allocations memory headroom is following from the head and the tail two ends of thread heap free memory 3:
(1) the head end address of thread heap free memory 3 is S h, the tail end address is S t
(2) after distributing the internal memory of L length from thread heap free memory 3 head ends, the head end address becomes S ' h=S h+ L;
(3) after distributing the internal memory of L length from thread heap free memory 3 tail ends, the tail end address becomes S ' t=S t-L;
(4) S when occurring t≤S h, thread heap free memory 3 exhausts, and promptly the internal memory opened up of thread radical function does not satisfy the demand of himself operation, and thread heap manager system 2 dishes out unusually, and the thread radical function withdraws from; And adjust by 2 pairs of these mistakes of thread heap manager system.
Above-mentioned steps 2) in, demand data 4 classification and corresponding distribution method may further comprise the steps:
(1) when a data demand 4 application memory headrooms, needing the type of the own demand of statement is output region or temporary space; When demand data 4 statements were the output region demand, thread heap manager system 2 stated it in the output terminal allocation space according to this; When demand data 4 statements were the temporary space demand, thread heap manager system 2 held allocation space according to this statement with it temporarily;
(2) when thread heap free memory 3 is in normal state N, for the data of all temporary space demands, thread heap free memory 3 is from head end order assignment internal memory; For the data of all output region demands, thread heap free memory 3 is from tail end order assignment internal memory;
(3) when the thread heap is in upset attitude F, for the data of all temporary space demands, thread heap free memory 3 is from tail end order assignment internal memory; For the data of all output region demands, thread heap free memory 3 is from head end order assignment internal memory.
Above-mentioned steps 4) in, as shown in Figure 3, grey color part is represented the internal memory of having used up among the figure, and lattice portion is divided the expression internal memory that interim end occupies, and perpendicular lattice are partly represented the internal memory that output terminal occupies, and remainder is a free memory.During higher level's function call subordinate function, 3 upsets of thread heap free memory are handled and are comprised the steps:
(1) gets into a function f 1The time, the state of thread heap free memory 3 is N (or F), the start address of the interim end of thread heap is B 1,0, the start address of thread heap output terminal is D 1,0
(2) function f 1Calling the next stage function f 2Before, the start address of interim end is B in the thread heap free memory 3 1,1, the start address of output terminal is D in the thread heap free memory 3 1,1
(3) call, get into function f 2The time, interim end and output terminal overturn, and the state of thread heap free memory 3 becomes the anti-attitude F (or N) of N (or F), and the start address of interim end is B 2,0=D 1,1, the start address of thread heap output terminal is D 2,0=B 1,1
(4) withdraw from function f 2The time, the start address of interim end reverts to B in the thread heap free memory 3 2,2=B 2,1, the start address of output terminal is D 2,2=D 2,1
(5) get into function f again 1, the state of thread heap free memory 3 becomes N (or F) again, the constant D of start address of output terminal in the thread heap free memory 3 1,2=D 1,1, the start address of interim end is B 1,2=D 2,1, function f 2Output data become function f 1Ephemeral data.
Above-mentioned each embodiment only is used to explain the present invention; The structure of each parts, size, the position is set and shape all can change to some extent; On the basis of technical scheme of the present invention; All improvement and equivalents of individual component being carried out according to the principle of the invention all should not got rid of outside protection scope of the present invention.

Claims (5)

1. the EMS memory management process of an embedded system, it comprises the steps:
(1) in the thread radical function of embedded system, opening up a physical memory piles as thread; And utilize convertible thread heap manager system that this physical memory is managed; In this thread all Dram all from then in the physical memory thread pile in the free memory and distribute; Thread heap manager system is demand data storage allocation space from the head and the tail two ends of thread heap free memory, and thread heap free memory has normal state N and upset attitude F two states;
(2) all demand datas are divided into two types of temporary space demand and output region demands; In same function; To distribute the data of temporary space demand to be interim end at the end that thread is piled free memory based on the type thread heap manager system of demand data, or distribute the data of output region demand to be output; Said demand data classification and corresponding distribution method may further comprise the steps:
1. when a data demand application memory headroom, needing the type of the own demand of statement is output region demand or temporary space demand, and by thread heap manager system according to this statement with demand data at output terminal or hold allocation space temporarily;
2. when thread heap free memory was in normal state N, for the data of all temporary space demands, thread heap free memory was from head end order assignment internal memory; For the data of all output region demands, thread heap free memory is from tail end order assignment internal memory;
3. when the thread heap was in upset attitude F, for the data of all temporary space demands, thread heap free memory was from tail end order assignment internal memory; For the data of all output region demands, thread heap free memory is from head end order assignment internal memory;
(3) thread heap manager system gives the head end Memory Allocation data of temporary space demand;
(4) when higher level's function call subordinate function, thread heap manager system control thread heap free memory overturns, and interim end and output end position are exchanged; When withdrawing from subordinate's function, thread heap free memory discharges the temporary space of current interim end, keeps the output region of output terminal simultaneously, and merges with the interim temporary space of holding of higher level's function.
2. the EMS memory management process of a kind of embedded system as claimed in claim 1 is characterized in that: in the said step (1), said thread heap manager system is that the step of data allocations memory headroom is following from the head and the tail two ends of said thread heap free memory:
1. the head end address of thread heap free memory is S h, the tail end address is S t
2. after distributing the internal memory of L length from thread heap free memory head end, the head end address becomes S ' h=S h+ L;
3. after distributing the internal memory of L length from thread heap free memory tail end, the tail end address becomes S ' t=S t-L;
4. S when occurring t≤S h, thread heap free memory exhausts, and thread heap manager system dishes out unusual and this mistake is adjusted, and the thread radical function withdraws from.
3. according to claim 1 or claim 2 a kind of EMS memory management process of embedded system is characterized in that: in the said step (4), during the said subordinate of said higher level's function call function, the upset of said thread heap free memory is handled and is comprised the steps:
1. get into a function f 1The time, the state of thread heap free memory is N or F, the start address of the interim end of thread heap is B 1,0, the start address of thread heap output terminal is D 1,0
2. function f 1Calling the next stage function f 2Before, the start address of interim end is B in the thread heap free memory 1,1, the start address of output terminal is D in the thread heap free memory 1,1
3. call the entering function f 2The time, interim end and output terminal overturn, and the state of thread heap free memory becomes anti-attitude F or the N of N or F, and the start address of interim end is B 2,0=D 1,1, the start address of thread heap output terminal is D 2,0=B 1,1
4. withdraw from function f 2The time, the start address of interim end reverts to B in the thread heap free memory 2,2=B 2,1, the start address of output terminal is D 2,2=D 2,1
5. get into function f again 1, the state of thread heap free memory becomes N or F again, the constant D of start address of output terminal in the thread heap free memory 1,2=D 1,1, the start address of interim end is B 1,2=D 2,1, function f 2Output data become function f 1Ephemeral data.
4. according to claim 1 or claim 2 a kind of EMS memory management process of embedded system, it is characterized in that: the EMS memory management process of said embedded system adopts convertible thread heap manager method.
5. the EMS memory management process of a kind of embedded system as claimed in claim 3, it is characterized in that: the EMS memory management process of said embedded system adopts convertible thread heap manager method.
CN201010512683.0A 2010-10-13 2010-10-13 Memory management method of embedded system Active CN101976224B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010512683.0A CN101976224B (en) 2010-10-13 2010-10-13 Memory management method of embedded system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010512683.0A CN101976224B (en) 2010-10-13 2010-10-13 Memory management method of embedded system

Publications (2)

Publication Number Publication Date
CN101976224A CN101976224A (en) 2011-02-16
CN101976224B true CN101976224B (en) 2012-05-16

Family

ID=43576110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010512683.0A Active CN101976224B (en) 2010-10-13 2010-10-13 Memory management method of embedded system

Country Status (1)

Country Link
CN (1) CN101976224B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567107B (en) * 2011-10-31 2014-03-05 广东电网公司电力科学研究院 Highly-concurrent real-time memory resource management and scheduling method
CN111078587B (en) * 2019-12-10 2022-05-06 Oppo(重庆)智能科技有限公司 Memory allocation method and device, storage medium and electronic equipment
CN115269170A (en) * 2021-04-30 2022-11-01 华为技术有限公司 Memory application method and related equipment
CN115033378B (en) * 2022-06-06 2023-01-06 北京熵核科技有限公司 Management method for volatile memory

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5414842A (en) * 1989-08-02 1995-05-09 International Business Machines Corporation External sorting using virtual storage as a work device
CN1851676A (en) * 2006-05-25 2006-10-25 浙江大学 Embedded system buffer internal memory distribution method
CN101093455A (en) * 2006-06-21 2007-12-26 中兴通讯股份有限公司 Allocation method for internal memory pool in embedded type operation system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5414842A (en) * 1989-08-02 1995-05-09 International Business Machines Corporation External sorting using virtual storage as a work device
CN1851676A (en) * 2006-05-25 2006-10-25 浙江大学 Embedded system buffer internal memory distribution method
CN101093455A (en) * 2006-06-21 2007-12-26 中兴通讯股份有限公司 Allocation method for internal memory pool in embedded type operation system

Also Published As

Publication number Publication date
CN101976224A (en) 2011-02-16

Similar Documents

Publication Publication Date Title
CN101976224B (en) Memory management method of embedded system
CN101847127B (en) Memory management method and device
CN101859279B (en) Memory allocation and release method and device
CN102156675A (en) Method and device for allocating memory
CN101887383A (en) Process real-time scheduling method
CN102456048A (en) Method and system for processing mass data
CN103744723A (en) Thread pool managing method and system
CN1790270A (en) Java virtual machine implementation method supporting multi-process
CN105183549A (en) Automatic ticketing system based on task assignment
CN103605727A (en) Connection pool based efficient multiuser database access optimization method and framework
CN106383742B (en) A kind of I O scheduling method based on linux
CN107209716A (en) Memory management apparatus and method
CN104182356B (en) A kind of EMS memory management process, device and terminal device
CN107436735A (en) State of memory cells update method in a kind of distributed file system
CN106293885A (en) Task creation, hang-up and restoration methods
CN108255608A (en) A kind of management method of memory pool
CN108595259B (en) Memory pool management method based on global management
CN102999434A (en) Memory management method and device
CN1881895A (en) Apparatus operation method in network management system
CN106293939B (en) A method of the dynamic reuse object in memory garbage collector
CN106681692A (en) Control device, integrated circuit and management method of task stack
CN103870206A (en) Caching data receiving and reading method and device and router cache device
CN107566514A (en) A kind of method that metadata request quantity is controlled in distributed memory system
CN102279804A (en) Memory pool structure of video monitoring platform system and method for implementing memory pool structure
CN109522113A (en) A kind of EMS memory management process and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant