Vous êtes sur la page 1sur 5

International Journal of Computer Science and Information Security (IJCSIS),

Vol. 14, No. 5, May 2016

An Analysis and Review on Memory Management


Algorithms for Real Time Operating System
Vatsalkumar H. Shah Dr. Apurva Shah
PhD Scholar, Associate Professor
Computer Science and Engineering Department, Computer Science and Engineering Department,
M. S. University, India M. S. University, India

Abstract – Real Time Operating System (RTOS) is an operating Dynamic Memory management can be further divided
system which supports real-time application by giving correct in two category. 1) Manual memory management 2) Automatic
result within given dead line. There are so many features memory management. [10]. In Manual memory management,
supported by RTOS like synchronization, clock and timer programmer can allocate or deallocate memory manually as per
support, interrupt handling, memory management, task
the need, so advantage of this technology is that it is easier for
preemption etc. Among these all memory management is a crucial
component. Memory management is nothing but memory him/her, but disadvantage is that, the memory management
allocation/ deallocation technique for the process. bugs are common. While in automatic memory management,
This paper presents different memory management algorithms for memory management unit deallocate the memory if object is
RTOS and comparison between them. out of scope. So it overcome the disadvantage of manual system
of bugs, but it consume more processor time as well it causing
Keywords – Memory management, Memory Allocation, Real time
memory overflow issue it failure to deallocate the memory.
operating system
This paper presents certain conventional algorithms as
I. INTRODUCTION
well as unconventional algorithm which has been proposed by
Real time operating system (RTOS) is an operating certain inventors are explained. Both types of algorithms come
system which provides the correct result within given deadline into the category of Dynamic Memory Allocator (DMA). To
[10]. It support so many features like synchronization, interrupt permit the application to read/write segments of memory from
handling, memory management, task preemption etc. But available unallocated memory blocks is the main purpose of
memory management is one of the main part of any kind of Dynamic Memory Allocator.
operating system. Memory management is nothing but to
allocate or deallocate the part of memory to the process as per The main methodology of Dynamic Memory
the need. Allocator algorithm is keeping link list of unallocated memory
blocks and allocated memory blocks. So, as and when any
Memory management can be categorized as static process requires memory then it will allocate memory from list
memory management and Dynamic memory management [1] of unallocated memory blocks and then it will be put in the list
[10]. In Static memory management, memory is allocated at of allocated memory blocks. This is the simplest method.
compile time. While in Dynamic memory management, However to gain more performance, number of list of
memory is allocated at run time. In static memory management, unallocated memory blocks can be increased, where each list
required memory for given process is already known and once contain memory blocs of specific size [3][4][5].
the memory has been allocated, no changes can be done at run
time. While in dynamic memory management, memory In the following section, details of both type
management unit explicitly keeping track of allocated and free (Conventional as well as Unconventional) is explained.
memory. During process execution, memory
allocation/deallocation can be done in Dynamic memory II. CONVENTIONAL ALGORITHMS
management, while in static memory management this thing There are four types of conventional dynamic memory
can’t be done. The advantage of dynamic memory management allocation/deallocation algorithms. 1) Sequential fit 2) Buddy
is that it required less memory while in static management more allocator system 3) Indexed fit 4) Bitmapped fit [3]
memory required.

236 https://sites.google.com/site/ijcsis/
ISSN 1947-5500
International Journal of Computer Science and Information Security (IJCSIS),
Vol. 14, No. 5, May 2016

1. Sequential Fit Algorithm: This is the simplest new algorithms which are more accurate and perfect in terms
algorithm for dynamic memory allocator algorithm in of performance for allocating memory to the processes. Here
which it maintains single link list of unallocated three algorithms are explained. 1) Two level segregated fit
memory blocks and unallocated blocks are allocated algorithm (TLSF) 2) Improved two level segregated fit
from this link list via different mechanism. First Fit, algorithm 3) Smart memory allocator algorithm.
Next Fit, Best Fit, Worst Fit [3][10].
In first fit, the link list is searched from starting and it 1. Two level segregated fit algorithm: M. Masmano, I.
will return the first block which is large enough to Ripoll, A. Crespo, and J. Real have been invented this
satisfy the need. While in Next fit, unlike First fit it algorithm in 2004 [7]. This algorithm resolves the
will search from where the search was left off. In the problem of worst case bound by preserving the
Best Fit, the entire link list will be searched and return efficiency of allocation or deallocation. Where huge
the smallest block which will large enough to hold the amount of memory is required such as video
request. While in Worst Fit, unlike best fit it will surveillance, virtual reality in such application this
return the largest block [3][10]. algorithm is useful.
In order to meet embedded system constraint
2. Buddy Allocator Algorithm: This algorithm uses an the TLSF algorithm has been made with strict
array of link lists of unallocated block. Each list for constrain like immediate merging, splitting threshold,
allowable block size. For example list of 2N block size good-fit strategy, no reallocation, same strategy for all
like 200 kb, 400 kb, 800 kb so on. The buddy allocator block sizes, memory is not cleaned up [3][7].
finds a smallest block which is large enough to hold Immediate merging means as soon as the memory
the request from list of unallocated blocks. If the block is freed, it would merge with its neighbor free
unallocated block list is empty then it will search a block to make a larger block. So it will be used in such
block from another list which is larger than request, application where different size of memory block is
then select and split the block [6][10]. A block must required. This algorithm implement splitting threshold
be split in to a same size blocks i.e. 400 kb block will by limiting the minimum size of memory block to 16
split in to two 200 kb blocks. In the same way block bytes. So that it can store the information to manage
may be merged with its adjacent block of same size, the memory block as well as include the pointer to link
and this is possible if the adjacent block has not been list of unallocated block. TLSF implements good-
split into smaller block. strategy fit policy by maintaining large set of
unallocated link lists and each list is non-orderd link
3. Indexed Fit: This algorithm uses structured index to list of unallocated blocks whose size is between the
implement desired fit [3]. According to allocation size class and next size class. So it implements
policy, it uses data structure likes tree or hash table for segregated list.
searching unallocated blocks. The ordinary segregated fit methodology uses
an array of unallocated block link lists, with each array
4. Bitmapped Fit: This algorithm uses a bitmap which holding unallocated blocks within a size class. To
represent weather heap is used or not. This map is a reduce the time of accessing unallocated blocks and to
simple vector of one bit flag with one bit manage a large set of segregated lists the array of lists
corresponding to each word of heap area [6][10]. Each has been organized as a two-level array. The first-level
bit in this map having value either 1 or 0. If the part of array divides unallocated blocks in classes which are
bitmap is in use than its value is 1 else its 0. The a power of two like 20, 21, 22, 23, 24 … 2n while the
benefit of this algorithm is memory overhead is small second-level sub-divides each first-level class
due to search time which is depend on bitmap size. linearly, where the number of divisions is suggested
by user. Each array of lists has an associated bitmap
used to mark which link lists are empty and which
III. UNCONVENTIONAL ALGORITHMS contain unallocated blocks. Information regarding
“Unconventional” itself suggest that it is not usual or each block is stored inside the block itself [7].
traditional. Here unconventional means to overcome the issues TLSF provides explicit allocation and
of conventional algorithms, certain researchers have been find deallocation of memory blocks with a temporal cost
Ө(1) [7]. According to M. Masmano, I. Ripoll, A.

237 https://sites.google.com/site/ijcsis/
ISSN 1947-5500
International Journal of Computer Science and Information Security (IJCSIS),
Vol. 14, No. 5, May 2016

Crespo, and J. Real, this algorithm has shown As shown in Figure 2, TLSF-I uses the two
excellent experimental results with respect to both level indexes for the unallocated block linked-list
response time and fragmentation. same as TLSF. The difference is that in TLSF-I when
it requires unallocated block, it will first search in its
own list and check if the first element is available. For
example, when it wants to allocate a block that is
between 2048 and 4096 bytes, it will first check its
own list (marked as X), if the first block is larger than
or equal to request, it will use this block and split
that(if required). If the first element is smaller than
request or does not exist, it will continue to search for
the next available block and extract the block from its
tail (marked as Y).

Figure 1. TLSF Architecture [7]

2. Improved TLSF: Improved TLSF is nothing but


improvement in two level segregated fit algorithm
which has been proposed by XiaoHui Sun, JinLin
Wang and Xiao Chen in 2007 [8]. This algorithm is
known as TLSF-I. This algorithm is proposed to
improve the performance and efficiency in allocating
small blocks and reduce fragmentation, it uses
different strategies to allocate blocks for different Figure 2. TLSF-I Architecture [8]
sizes. If the block size is small, it uses the exact fit, While deallocating a memory block,
which is indexed by a double occupancy map. And if previous block is checked to see whether it is
the block size is larger blocks uses a compound FIFO unallocated or not. If the block is unallocated then the
and LIFO strategy. block is removed from the segregated list and merged
In this algorithm double occupancy bitmap is with the current block. The same operation is carried
used to maintain an exact fit table. The first level out with the next physical block. Once the block has
bitmap is an index of the second bitmap. A two level been merged with its free neighbor blocks, the new big
bitmap can totally index up to 8k bytes. When it block is inserted in the tail of the segregated list
requires to allocate memory which is small, it first gets marked as Z (First in First out); otherwise, this block
the map index of required size to see if the block list is inserted into the head of the list (Last in Fist out)
is unallocated. If it gets success to find an available [8].
block in the unallocated list, it simply extract that. If
not, then it will search the bitmap tree to find the 3. Smart Memory Allocator Algorithm: This algorithm
available block. If it gets failure to find suitable block has been proposed by Ramakrishna M, Jisung Kim,
in the small block area, it continue to search the large Woohyong Lee and Youngki Chung in 2008 [9]. This
block area till it finds extractable blocks [8]. is a custom type of dynamic memory algorithm having
This algorithm combine the FIFO and LIFO best response time and less memory fragmentation.
operations in unallocated memory blocks This algorithm divides memory blocks into two
management. categories. One is short-lived and another is long-lived

238 https://sites.google.com/site/ijcsis/
ISSN 1947-5500
International Journal of Computer Science and Information Security (IJCSIS),
Vol. 14, No. 5, May 2016

memory blocks. The short-lived memory blocks are 2. Memory Usage: Maximum memory usage has been
allocated in the direction of lowest level to highest done by Sequential Fit, Buddy Allocator and
level from heap while long-lived memory blocks are Bitmapped Fit, while minimum memory usage done
allocated from highest level to lowest level [9][10]. by TLSF, TLSF-I and Smart memory Allocator.
The used space of heap grows from highest level to 3. Response Time: Sequential Fit having very slow
lowest level as well as lowest level to highest level. response time, while Buddy Allocator, Indexed Fit
Initially entire heap memory is unallocated and there and Bitmapped Fit having Fast response time. With
is only one unallocated memory block for each short compare to all previous algorithms TLSF having faster
as well as long-lived memory. The heap space is response time but TLSF-I and smart memory allocator
divided equally into two blocks. When the heap grows having excellent compare to all.
from both sides, the virtual border between these two
can easily modified according to dynamic memory V. CONCLUSION
request. Memory management is the one of most important
As this algorithm predicting memory object aspect of Real time operating system. So in this paper, we have
life scope, it can easily allocate memory block from analyzed and surveyed various memory allocation algorithms.
either short-lived or long-lived memory pool [9]. So it Also compared them on the basis of three different parameters
can have best response time with lower fragmentation. like fragmentation, memory usage and response time.
It is implemented with lookup table and hierarchical
VI. REFERENCES
bitmaps which are improved version of multilevel
[1] Robart L. Budzinski, Edward S. Davidson, “A Comparison of
segregated mechanism.
Dynamic and Static Virtual Memory Allocation Algorithms” IEEE
Transactions on software Engineering, Vol. SE-7, NO. 1, January
1981.
[2] David R. Hanson, “Fast allocation and deallocation of memory
based on object life times,” Software-Practice and Experience, Vol.
20(1), Jan 1990 pp. 5-12.
[3] P. R. Wilson, M. S. Johnstone, M. Neely, and D. Boles, “Dynamic
Memory Allocation: A Survey and Critical Review,” In Proceedings
of the Memory Management International Workshop IWMM95,
Sep 1995
[4] Takeshi Ogasawara, “An Algorithm with Constant Execution Time
for Dynamic Memory Allocation”, in proceedings of Second
International Workshop on Real-Time Computing Systems and
Applications, 25-27 Oct 1995, Pg No. 21 – 25.
[5] Puaut, "Real-Time Performance of Dynamic Memory Allocation
Algorithms," in Proceedings of the 14th Euromicro Conference on
Real-Time Systems (ECRTS'02), June 2002
[6] Mohamed A. Shalan, “Dynamic Memory Management for
Embedded Real-Time Multiprocessor System On a Chip”, A Thesis
in Partial Fulfillment of the Requirements for the Degree of Doctor
of Philosophy from School of Electrical and Computer Engineering
Figure 3. Structure of unallocated blocks [9][10] ,Georgia Institute of Technology, November 2003.
[7] M. Masmano, I. Ripoll and A. Crespo, “TLSF: A new dynamic
IV. COMAPRISION BETWEEN ALGORITHMS memory allocator for real-time systems,” in proceedings of 16th
Euromicro Conference on Real-Time Systems, Catania, Italy, July
In this section we have done the comparison between 2004, pages 79-88.
different dynamic memory allocation algorithm with respect to [8] XiaoHui Sun, JinLin Wang, xiao chan, “An Improvement of TLSF
parameters of memory usage, response time and fragmentation Algorithm”.
[9] Ramakrishna M, Jisung Kim, Woohyong Lee and Youngki Chung,
[10]. “Smart Dynamic Memory Allocator for embedded systems”, in
1. Fragmentation: Sequential Fit, Buddy Allocator, proceedings of 23rd International Symposium on Computer and
Indexed Fit and Bitmapped Fit cause large amount of Information Sciences, ISCIS '08, 27-29 Oct. 2008
fragmentation. While TLSF causes small amount of [10] Dipti Diwase, Shraddha Shah, Tushar Diwase and Priya Rathod,
"Survey Report on Memory Allocation Strategies for Real Time
fragmentation, where TLSF-I and Smart memory Operating System in Context with Embedded Devices", published
allocator cause lesser fragmentation than TLSF. in International Journal of Engineering Research and Applications,
Vol. 2, Issue 3, May-Jun 2012, pp.1151-1156.

239 https://sites.google.com/site/ijcsis/
ISSN 1947-5500
International Journal of Computer Science and Information Security (IJCSIS),
Vol. 14, No. 5, May 2016

[11] Jane W. S. Liu, “Real-time System”, (published by Person


Education, Page no. 20-40).

240 https://sites.google.com/site/ijcsis/
ISSN 1947-5500

Vous aimerez peut-être aussi