CN1287290C - Dynamic allocation method for non-buffering memory in embedded real-time operating system - Google Patents
Dynamic allocation method for non-buffering memory in embedded real-time operating system Download PDFInfo
- Publication number
- CN1287290C CN1287290C CN 03132075 CN03132075A CN1287290C CN 1287290 C CN1287290 C CN 1287290C CN 03132075 CN03132075 CN 03132075 CN 03132075 A CN03132075 A CN 03132075A CN 1287290 C CN1287290 C CN 1287290C
- Authority
- CN
- China
- Prior art keywords
- memory
- buffering
- array
- operating system
- memory block
- 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.)
- Expired - Fee Related
Links
Images
Landscapes
- Memory System (AREA)
Abstract
The present invention relates to a dynamic allocation method for a non-buffering memory in an embedded real-time operating system. The method comprises the following steps: applying a large memory area towards the operating system in advance; setting the applied memory area as a user reserved area; setting a non-buffering description array; looking up non-buffering blocks which are released and are identified as non-allocation in the non-buffering description array, and distributing the non-buffering blocks to required programs in turn; simultaneously modifying the identification of the memory block in the non-buffering description array as allocation; looking up the position of the memory block in the non-buffering description array and releasing the memory block; simultaneously modifying the identification of the memory block in the non-buffering description array as non-allocation. The present invention overcomes the defects of statistical operation and space waste existing in the former algorithms, and enhances the utilization rate of the memory to a certain extent. The dynamic allocation method has elasticity, and is suitable for embedded systems of different scales.
Description
Technical field
The present invention relates to computer realm, specifically, relate to the internal memory dynamic allocation method in a kind of embedded real-time multi-task operating system.
Background technology
Embedded real-time operating system generally by task scheduling management, time management, tasks synchronization and communicate by letter, several parts such as memory management form.Because real time operating system is very strong to the dependence of internal memory, so memory management just seems very important as the core of operating system.
UB (Unbuffer, non-buffering) its specific algorithm of block-distributing algorithm that fixed size Memory Allocation algorithm commonly used now is to use is as follows:
To big memory field of operating system application, it is defined as user's retaining space to the bulk free space in advance in advance, can not all be defined as user's retaining space to whole spaces, because operating system itself and the operation of some protocol stacks also need some spaces.Again this memory field is divided into some memory pools, the size of memory block is fixed in each memory pool, and the quantity of the memory block of all size can dispose as required.In order to make initial configuration and the actual UB of use quantity coincide to the full extent, in program, can increase the statistics that various UB peak values use, adjust the quantity of various UB with these data.
Buffer Pool can be divided into 64,128 according to actual conditions, 256,512,1024,2048,4096,8,192 eight kinds of sizes, the Buffer Pool of every kind of size manages with round-robin queue, and the interface of application internal memory and releasing memory is provided.Memory management provides its Debugging message and statistic information.Select administration queue according to the size of application internal memory during the application internal memory, win a buffer zone return pointer from the head of formation and give the applicant, during release internal memory is appended to rear of queue.
The memory block of every kind of size all has a memory management structure, notes the operating position (free memory number, maximum utilize number and accumulative total to apply for the number of times of this kind internal memory) of this kind internal memory.Memory queue uses the one-level index, and the size of application internal memory maps directly to the numbering of formation.
The Operation and Maintenance algorithm of pool structure and internal memory is divided and cushioned to internal memory:
Shown in Figure 1 is the situation of memory block division and the structural drawing of Buffer Pool POOL.Shown in Figure 2 is the Operation and Maintenance algorithm pattern of internal memory, and memory queue is a simple round-robin queue, gets a free block from queue heads during application, is placed on the row tail when giving back.Because memory queue is that each task of system all can be applied for and give back, and is provided with a semaphore and comes mutual exclusion.In order to raise the efficiency, memory queue adopts secondary index: the size of memory block obtains the one-level index value through simple displacement, and the one-level index value is the numbering of memory queue.
Application and releasing memory algorithm
(1) application according to the displacement of required memory numerical value, obtains the one-level index value during internal memory, finds corresponding POOL and corresponding memory queue thereof, according to the head of formation, the pointer value of available block is returned to caller.As shown in Figure 3.
When (2) giving back internal memory, find corresponding Buffer Pool POOL and corresponding memory queue thereof from HEAD, the pointer value of the internal memory that will discharge is put into the tail pointer of correspondence memory formation.
The allocation list of internal memory UB is as follows:
The allocation list * of/* internal memory UB/
T_UBCT g_aUBPoolConfigTable[]=
{
/ * size total reservation */
{0, 0, 0},
{1, 120, 40},
{4, 100, 30},
{8, 80, 20},
{16, 50, 10},
{32, 20, 5},
{64, 10, 0},
{0, 0, 0}
};
In sum, the UB block-distributing algorithm is owing at first need in the practice to carry out static configuration according to the usage quantity of the fixed size memory block of the different sizes of the statistics of use amount at ordinary times, so need reconfigure the static configuration table when can occur facing new upper layer application, will need the use amount of the memory block of the different sizes of regular hour statistics like this.And may be owing to allocation list is revised in the variation of different UB number of blocks demands.If Pei Zhi UB number of blocks can not satisfy the demands and the situation of internal memory application failure can occur in addition.
Summary of the invention
Technical matters to be solved by this invention provides a kind of dynamic allocation algorithm based on now used UB Memory Allocation algorithm, the shortcoming of statistical operation that must exist in the algorithm before solving and space waste, improved the utilization of internal memory to a certain extent, and have retractility, can adapt to the embedded system of different scales.
Non-buffer memory dynamic allocation method of the present invention comprises:
(1) in advance to big memory field of operating system application;
(2) memory field with application is set at the user reserved area;
(3) be provided with 64,128,256,512,1024,2048, the description array of 4096,8,192 eight kinds of UB;
(4) when program needs memory block, at first in the description array of this big or small UB, search according to required memory block size and not discharged the vacant UB piece that comes out (be not designated and distribute), if having, then distribute to the program that needs in order; If no, then from the memory field, apply for memory block in order, and describe the array afterbody according to the size of application memory block at this big or small UB and add that distribute then, this piece memory mark is for distributing in the array of modification description simultaneously;
(5) in the time of the releasing memory piece, at UB the position and the release of searching this memory block in the array is described according to the size of memory block, this piece memory mark is not distribution in the array of modification description simultaneously.
Adopt the internal memory dynamic allocation method of UB of the present invention, compared with prior art, solved the static configuration problem that memory modules must have, solved incorrect simultaneously and situation that internal memory application that cause is failed when the static configuration number, thereby reached the effect of simplicity, scalability, the required statistical static of memory management of having saved embedded system disposes the problem of quantity, has reduced the incorrect risk of configured number.
Description of drawings
Shown in Figure 1 is the situation of memory block division and the structural drawing of Buffer Pool POOL;
Shown in Figure 2 is the Operation and Maintenance algorithm pattern of internal memory;
Shown in Figure 3 is the algorithm pattern of application internal memory;
Fig. 4 is that the memory field of application and the UB of different sizes describe the array synoptic diagram;
Fig. 5 is the synoptic diagram of internal memory application;
Fig. 6 is the synoptic diagram that internal memory discharges;
Fig. 7 is the process flow diagram of internal memory application of the present invention.
Embodiment
Below in conjunction with accompanying drawing, concrete enforcement of the present invention is described in further detail.
Fig. 4 has shown in advance and shown in grey among the figure, and to be provided with 64,128,256,512,1024,2048, the description array of 4096,8,192 eight kinds of UB to big memory field 1 of operating system application.
When needing operating system to distribute the internal memory of one 64 byte, at first in the description array of this 64 byte UB, search according to required memory block size and not discharged the vacant UB piece that comes out (be not designated and distribute), at Fig. 5, represent with point 4 and slash 3 among the memory field b of application and the c, in the description array of 64 bytes, represent with point 4, if have, then distribute in order; If do not have, then from the memory field, apply for memory block in order, point 4 expressions among the memory field d of Fig. 5 application, and describe the array afterbody according to the size of application memory block at this big or small UB and add, represent with perpendicular thick stick 5 in the description array of 64 bytes among Fig. 5, distribute then, this piece memory mark is for distributing in the array of modification description simultaneously.
When discharging 64 byte of memorys known to Fig. 6, describe the position of searching this memory block in the array and discharge at 64 byte UB, revise simultaneously and describe in the array this piece memory mark for not distributing, with slash 6 memory block after the release is described among Fig. 6.
Fig. 7 is the process flow diagram of internal memory application.The memory block size of Fen Peiing searches whether assignable memory block is arranged in corresponding description array as required, has, just storage allocation piece in order; No, an internal memory of the identical size of application in the memory field just if application is unsuccessful, does not promptly have the memory headroom that can give, then storage allocation failure; If apply for successfully then describe the array afterbody at this big or small UB and add and distribute this memory block then.
In sum, the required statistical static of memory management that the present invention adopts UB internal memory dynamic allocation algorithm UB algorithm than before to save embedded system disposes the problem of quantity, has reduced the incorrect risk of configured number.
Claims (4)
1. non-buffer memory dynamic allocation method in the embedded real-time operating system comprises the steps:
(1) in advance to big memory field of described embedded real-time operating system application;
(2) memory field with application is set at the user reserved area;
It is characterized in that, also comprise:
(3) UB that different memory sizes are set in the user reserved area describes array;
When (4) needing memory block, according to the required memory size, describe to search in the array at the described UB of corresponding size and discharged the vacant non-buffer stopper that does not distribute that comes out, is designated, distribute to the program that needs in order, revise described non-buffering simultaneously and describe in the array this piece memory mark for distributing;
(5) during the releasing memory piece,, describe the position of searching this memory block in the array and discharge, revise simultaneously and describe in the array this memory block and be not designated and distribute in the described non-buffering of corresponding size according to the size of memory block.
2. non-buffer memory dynamic allocation method is characterized in that in the embedded real-time operating system as claimed in claim 1, and the non-buffering of the described different memory sizes of step (3) is described array and be can be 64,128,256,512,1024,2048,4096,8,192 eight kinds.
3. non-buffer memory dynamic allocation method in the embedded real-time operating system as claimed in claim 1, it is characterized in that, step (4) also comprises, if do not discharged the vacant non-buffer stopper that comes out, then from the memory field, apply for memory block in order, and describe the array afterbody according to the size of application memory block in the described non-buffering of corresponding size and add, distribute then, revise described non-buffering simultaneously and describe in the array this piece memory mark for distributing.
4. non-buffer memory dynamic allocation method is characterized in that in the embedded real-time operating system as claimed in claim 3, does not have the memory headroom that can give in the memory field, the storage allocation failure.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 03132075 CN1287290C (en) | 2003-07-15 | 2003-07-15 | Dynamic allocation method for non-buffering memory in embedded real-time operating system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 03132075 CN1287290C (en) | 2003-07-15 | 2003-07-15 | Dynamic allocation method for non-buffering memory in embedded real-time operating system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1570883A CN1570883A (en) | 2005-01-26 |
CN1287290C true CN1287290C (en) | 2006-11-29 |
Family
ID=34469861
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN 03132075 Expired - Fee Related CN1287290C (en) | 2003-07-15 | 2003-07-15 | Dynamic allocation method for non-buffering memory in embedded real-time operating system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN1287290C (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103399831A (en) * | 2013-08-14 | 2013-11-20 | 江西航天海虹测控技术有限责任公司 | Implementation method for automatic circulating memory of NANDFLASH memorizer |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101937398B (en) * | 2010-09-14 | 2014-03-12 | 中兴通讯股份有限公司 | Configuration method and device for built-in system memory pool |
US8407506B2 (en) * | 2011-03-30 | 2013-03-26 | Symbol Technologies, Inc. | Dynamic allocation of processor cores running an operating system |
CN102981919B (en) * | 2012-11-02 | 2015-07-01 | 福建升腾资讯有限公司 | Memory management method of quickly positioning sources of errors |
CN103064754A (en) * | 2012-11-14 | 2013-04-24 | 福建升腾资讯有限公司 | Memory management method capable of fast positioning sources of errors |
CN104090848B (en) * | 2014-07-16 | 2017-03-08 | 云南大学 | EMS memory management process and device that a kind of periodicity big data is processed |
CN105700952A (en) * | 2014-11-26 | 2016-06-22 | 中兴通讯股份有限公司 | Embedded system memory statistics method and apparatus |
CN105183542B (en) * | 2015-08-13 | 2019-07-12 | 上海斐讯数据通信技术有限公司 | A kind of EMS memory management process and system |
CN109298888B (en) | 2018-10-31 | 2021-08-24 | 杭州迪普科技股份有限公司 | Queue data access method and device |
-
2003
- 2003-07-15 CN CN 03132075 patent/CN1287290C/en not_active Expired - Fee Related
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103399831A (en) * | 2013-08-14 | 2013-11-20 | 江西航天海虹测控技术有限责任公司 | Implementation method for automatic circulating memory of NANDFLASH memorizer |
CN103399831B (en) * | 2013-08-14 | 2015-11-18 | 江西航天海虹测控技术有限责任公司 | The implementation method that NANDFLASH storer automatic cycle stores |
Also Published As
Publication number | Publication date |
---|---|
CN1570883A (en) | 2005-01-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1276361C (en) | A memory management method for embedded system | |
CN1287290C (en) | Dynamic allocation method for non-buffering memory in embedded real-time operating system | |
CN1271524C (en) | Static internal storage management method | |
CN1266590C (en) | Progress pole/linear procedure pole management method of construction member oriented backbone system internal core | |
CN1604051A (en) | Method and apparatus for dynamic memory management within an object-oriented program | |
CN1874538A (en) | Concurrent method for treating calling events | |
CN1815629A (en) | Dirty block recovery method for flash memory device | |
CN1722106A (en) | Method for internal memory allocation in the embedded real-time operation system | |
CN101847127A (en) | Memory management method and device | |
CN1684040A (en) | Information processor capable of using past processing space | |
CN103455433A (en) | Memory management method and system | |
CN100351792C (en) | A real-time task management and scheduling method | |
CN1770125A (en) | Memory allocation method | |
CN103488577A (en) | Method and device of memory allocation and batch recovery for user applications based on use numbering | |
CN1851671A (en) | Method for saving global varible internal memory space | |
CN1851676A (en) | Embedded system buffer internal memory distribution method | |
CN106598736A (en) | Memory block calling method and memory block releasing method for memory pool and server | |
CN1287291C (en) | Method of internal storage releasing in embedded type real time operation system | |
CN1881895A (en) | Apparatus operation method in network management system | |
CN1553693A (en) | Universal charging method | |
CN1295613C (en) | Method for general windows program to operate journal information record | |
CN1946225A (en) | Full distributive resource managing method and system | |
CN1567249A (en) | Internal memory managerial approach for computer system | |
CN103853713A (en) | Efficient storage method of mass data | |
CN1489334A (en) | Method for storage area management with static and dynamic joint |
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 | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20061129 Termination date: 20190715 |
|
CF01 | Termination of patent right due to non-payment of annual fee |