SlideShare a Scribd company logo
1 of 19
Memory Allocation for Real Time
Operating System
Eng. Asma’a Lafi
1
Memory allocation
• Reserving memory moment to moment, as
needed, without having to reserve a fixed
amount ahead of time. Modern operating
systems perform dynamic memory allocation
for their own use. They may also perform the
same operation for their applications, or they
may include programming interface functions
(APIs such as malloc) that allow the
applications to allocate and de-allocate
memory as needed.
2
Memory allocation in RTOS
• Real time operating system uses different
memory allocation strategies and algorithm that
are used in order to improve the performance of
the intended system.
• Basically two types of memory allocation are
provided in RTOS stack and heap. The stack
allocation is used during context switching for
Task Control Blocks while heap allocation deals
with memory other than memory used for
program code and it is used for dynamic
allocation of data space for tasks. Allocation of
this memory is called heap allocation.
3
Memory allocation in RTOS (cont’d)
• Real time operating system
supports static and dynamic
memory allocation
Static memory
allocation
Dynamic memory
allocation
Memory is
allocated at
compile or design
time
Memory is
allocated at run
time
Memory allocation
is a deterministic
process that
means memory
allocation already
known
Requires memory
manager to keep
track which
memory are used
and which are not
No memory
allocation or
deallocation
actions are
performed during
execution
Memory allocation
is established and
destroyed during
the execution
4
Classification of Memory Allocation
Techniques.
5
Manual memory Allocation
• In manual memory allocation, the programmer has
direct control on process of memory is allocated
and recycling. Usually this is either by explicit
calls to heap allocation functions or by language
constructs that affect the stack.
• Advantage:
Manual memory allocation is easier for
programmers to understand and use.
• Disadvantage:
Memory allocation bugs are common when manual
memory allocation is used.
6
Automatic Memory Allocation
• Automatic memory allocation, usually do their job by
recycling blocks that are unreachable from program
variables.
• Advantage:
Automatic memory allocation eliminates most memory
allocation bugs.
• Disadvantage:
Sometimes automatic memory managers fail to deallocate
unused memory locations causing memory leaks.
Automatic memory mangers usually consume a great
amount of the CPU time and usually have nondeterministic
behavior.
7
DYNAMIC MEMORY ALLOCATION ALGORITHMS
Sequential Fit
Sequential fit is the most basic algorithm which uses a single linear list
of all free memory blocks called a free list. Free blocks are allocated
from this list in one of four ways :
 First fit: the list is searched from the beginning, returning the first
block large enough to satisfy the request
 Next fit: the list is searched from the place where the last search left
off, returning the next block large enough to satisfy the request
 Best fit: the list is searched exhaustively, returning the smallest block
large enough to satisfy the request.
 Worst fit : the list is searched; returning largest available free block .
8
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
• Sequential Fit
Advantage:
Simple to understand and easy to apply.
Disadvantage:
As memory available for allocation becomes large, the search
time becomes large and in the worst case can be proportional to
the memory size.
As the free list becomes large, the memory used to store the
free list becomes large; hence the memory overhead becomes
large
Sequential Fit is not a good strategy for RTSs because it is
based on a sequential search, whose cost depends on the number
of existing free blocks.
9
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
• Buddy allocator
A buddy allocator uses an array of free lists, one for each
allowable block size.
The buddy allocator rounds up the requested size to an
allowable size and allocates from the corresponding free
list. If the free list is empty, a larger block from another
free list is selected and split.
A block may only be split into a pair of buddies (of the
same size in case of binary buddy system).
A block may be coalesced only with its buddy, and this is
possible only if the buddy has not been split into smaller
blocks.
10
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
• Buddy allocator
Advantage:
The advantage of a buddy system is that the
buddy of a block being freed can be quickly found
by a simple address computation.
Disadvantage:
The disadvantage of a buddy system is that the
restricted set of block sizes leads to high
internal fragmentation, as does the limited ability
to coalesce.
11
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
Indexed Fit
Indexed fits are a class of allocation
mechanisms that use an indexing data
structure, such as a tree or hash table, to
identify suitable free blocks, according to the
allocation policy.
Advantage
This strategy is based on the use of advanced
structures to index the free memory blocks
thus provide better performance.
12
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
Bitmapped Fit
Bitmapped Fits are a class of allocation
mechanisms that use a bitmap to represent
the usage of the heap. Each bit in the map
corresponds to a part of the heap, typically a
word, and is set if that part is in use.
Advantage:
In Bitmapped Fit mechanism, the search time
is proportional to the bitmap size which result
in a small memory overhead.
13
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
Two Level Segregated Fit (TLSF)
 Two level segregated fit solves the problem of the worst case
bound maintaining the efficiency of the allocation and
deallocation operations allows the reasonable use of dynamic
memory allocation in real-time applications.
 provides explicit allocation and deallocation of memory. There
exists an increasing number of emerging applications using high
amounts of memory, such as multimedia systems, video
streaming.
 In order to meet these constraints and requirements, two level
segregated fit has been designed with guidelines like immediate
merging, splitting threshold for optimizes the memory usage
which tends to produce the lowest fragmentation on real
workloads.
14
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
• Two Level Segregated Fit (TLSF)
 To implement a good-fit strategy two level segregated fit
algorithm uses a segregated fit mechanism. The basic
segregated fit mechanism uses an array of free lists, with each
array holding free blocks within a size class.
 In order to speed up the access to the free blocks and also to
manage a large set of segregated lists (to reduce
fragmentation) the array of lists has been organized as a two-
level array.
 The first-level array divides free blocks in classes that are a
power of two apart and the second-level sub-divides each first-
level class linearly, where the number of divisions can be
determined by the user. Each array of lists has an associated
bitmap used to mark which lists are empty and which ones
contain free blocks.
15
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
Smart Memory Allocator
Smart Dynamic Memory Allocator is a new allocation
style which allows designing a custom dynamic
memory allocation mechanism with reduced memory
fragmentation and response time.
In this algorithm memory blocks is divided into to
types: Long lived block and Short lived block.
Directions of growing of heap is different for both
types of memory blocks. The short lived allocated
from bottom to top while the long lived block
allocated from top to bottom.
16
DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d)
Smart Memory Allocator
 A new smart dynamic memory allocator particularly for embedded
systems have limited memory and processing power.
 The smart allocator predict the short-lived objects and allocates those
objects on one side of the heap memory and remaining objects on other
side of the heap memory for effective use of memory footprint.
 The allocator reduces the memory fragmentation by using directional
adaptive allocation based on the predicted object lifetimes the lifetime
can be predicted using a mixture of block size and the number of
allocation events.
 The allocator is implemented with improved multilevel segregated
mechanism by means of lookup tables and hierarchical bitmaps that
guarantee very good response time and dependable timing performance.
17
Comparison between Different
Memory Allocation Algorithms
parameters
fragmentation Memory
footprint usage
Response time
Sequential fit Large Maximum Slow
Buddy System large Maximum Fast
Indexed fit large Maximum Fast
Bitmapped fit Large maximum Fast
TLSF Small Minimum Faster
Smart Memory
Allocator
reduce Minimum The fastest
18
CONCLUSION
• Dynamic memory allocation is used in many
real-time systems. In such systems there are
a lot of objects, which are referenced by
different threads.
• There are different memory allocation
algorithms are available.
• The major challenges of memory allocator are
minimizing fragmentation, providing a good
response time, and maintaining a good locality
among the memory blocks.
19

More Related Content

What's hot

Multi core-architecture
Multi core-architectureMulti core-architecture
Multi core-architecture
Piyush Mittal
 
Real Time Kernels
Real Time KernelsReal Time Kernels
Real Time Kernels
Arnav Soni
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 

What's hot (20)

Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
Vx works RTOS
Vx works RTOSVx works RTOS
Vx works RTOS
 
Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
 
Superscalar Processor
Superscalar ProcessorSuperscalar Processor
Superscalar Processor
 
INTERRUPT ROUTINES IN RTOS EN VIRONMENT HANDELING OF INTERRUPT SOURCE CALLS
INTERRUPT ROUTINES IN RTOS EN VIRONMENT HANDELING OF INTERRUPT SOURCE CALLSINTERRUPT ROUTINES IN RTOS EN VIRONMENT HANDELING OF INTERRUPT SOURCE CALLS
INTERRUPT ROUTINES IN RTOS EN VIRONMENT HANDELING OF INTERRUPT SOURCE CALLS
 
Pipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture pptPipeline hazards in computer Architecture ppt
Pipeline hazards in computer Architecture ppt
 
Cache memory
Cache memoryCache memory
Cache memory
 
Multi core-architecture
Multi core-architectureMulti core-architecture
Multi core-architecture
 
Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
Rtos concepts
Rtos conceptsRtos concepts
Rtos concepts
 
Real Time Kernels
Real Time KernelsReal Time Kernels
Real Time Kernels
 
Multiprocessor architecture
Multiprocessor architectureMultiprocessor architecture
Multiprocessor architecture
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Task assignment and scheduling
Task assignment and schedulingTask assignment and scheduling
Task assignment and scheduling
 
Mac protocols for ad hoc wireless networks
Mac protocols for ad hoc wireless networks Mac protocols for ad hoc wireless networks
Mac protocols for ad hoc wireless networks
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Memory Organisation in embedded systems
Memory Organisation in embedded systemsMemory Organisation in embedded systems
Memory Organisation in embedded systems
 
System on chip architectures
System on chip architecturesSystem on chip architectures
System on chip architectures
 
MEMORY MANAGEMENT
MEMORY MANAGEMENTMEMORY MANAGEMENT
MEMORY MANAGEMENT
 

Similar to Memory allocation for real time operating system

Memory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage CollectorMemory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage Collector
Wednesday Solutions
 
Memory Managementgggffffffffffgggggggggg
Memory ManagementgggffffffffffggggggggggMemory Managementgggffffffffffgggggggggg
Memory Managementgggffffffffffgggggggggg
BHUPESHRAHANGDALE200
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
C.U
 

Similar to Memory allocation for real time operating system (20)

MM RTOS.pptx
MM RTOS.pptxMM RTOS.pptx
MM RTOS.pptx
 
Cache Memory.pptx
Cache Memory.pptxCache Memory.pptx
Cache Memory.pptx
 
Memory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage CollectorMemory Management in Go: Stack, Heap & Garbage Collector
Memory Management in Go: Stack, Heap & Garbage Collector
 
Memory Managementgggffffffffffgggggggggg
Memory ManagementgggffffffffffggggggggggMemory Managementgggffffffffffgggggggggg
Memory Managementgggffffffffffgggggggggg
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management CSI-503 - 6. Memory Management
CSI-503 - 6. Memory Management
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
contiguous memory allocation.pptx
contiguous memory allocation.pptxcontiguous memory allocation.pptx
contiguous memory allocation.pptx
 
A kind of Algorithm that Extend MLC SSD Life Expectancy by 3 Folds
A kind of Algorithm that Extend MLC SSD Life Expectancy by 3 FoldsA kind of Algorithm that Extend MLC SSD Life Expectancy by 3 Folds
A kind of Algorithm that Extend MLC SSD Life Expectancy by 3 Folds
 
Dos unit3
Dos unit3Dos unit3
Dos unit3
 
Os unit 3
Os unit 3Os unit 3
Os unit 3
 
Cache simulator
Cache simulatorCache simulator
Cache simulator
 
Linux Memory Management with CMA (Contiguous Memory Allocator)
Linux Memory Management with CMA (Contiguous Memory Allocator)Linux Memory Management with CMA (Contiguous Memory Allocator)
Linux Memory Management with CMA (Contiguous Memory Allocator)
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt
 
Operating system 34 contiguous allocation
Operating system 34 contiguous allocationOperating system 34 contiguous allocation
Operating system 34 contiguous allocation
 
Memory Management in real time operating system
Memory Management in real time operating systemMemory Management in real time operating system
Memory Management in real time operating system
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Chapter 9 OS
Chapter 9 OSChapter 9 OS
Chapter 9 OS
 
unit5_os (1).pptx
unit5_os (1).pptxunit5_os (1).pptx
unit5_os (1).pptx
 
Memory Hierarchy
Memory HierarchyMemory Hierarchy
Memory Hierarchy
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

Memory allocation for real time operating system

  • 1. Memory Allocation for Real Time Operating System Eng. Asma’a Lafi 1
  • 2. Memory allocation • Reserving memory moment to moment, as needed, without having to reserve a fixed amount ahead of time. Modern operating systems perform dynamic memory allocation for their own use. They may also perform the same operation for their applications, or they may include programming interface functions (APIs such as malloc) that allow the applications to allocate and de-allocate memory as needed. 2
  • 3. Memory allocation in RTOS • Real time operating system uses different memory allocation strategies and algorithm that are used in order to improve the performance of the intended system. • Basically two types of memory allocation are provided in RTOS stack and heap. The stack allocation is used during context switching for Task Control Blocks while heap allocation deals with memory other than memory used for program code and it is used for dynamic allocation of data space for tasks. Allocation of this memory is called heap allocation. 3
  • 4. Memory allocation in RTOS (cont’d) • Real time operating system supports static and dynamic memory allocation Static memory allocation Dynamic memory allocation Memory is allocated at compile or design time Memory is allocated at run time Memory allocation is a deterministic process that means memory allocation already known Requires memory manager to keep track which memory are used and which are not No memory allocation or deallocation actions are performed during execution Memory allocation is established and destroyed during the execution 4
  • 5. Classification of Memory Allocation Techniques. 5
  • 6. Manual memory Allocation • In manual memory allocation, the programmer has direct control on process of memory is allocated and recycling. Usually this is either by explicit calls to heap allocation functions or by language constructs that affect the stack. • Advantage: Manual memory allocation is easier for programmers to understand and use. • Disadvantage: Memory allocation bugs are common when manual memory allocation is used. 6
  • 7. Automatic Memory Allocation • Automatic memory allocation, usually do their job by recycling blocks that are unreachable from program variables. • Advantage: Automatic memory allocation eliminates most memory allocation bugs. • Disadvantage: Sometimes automatic memory managers fail to deallocate unused memory locations causing memory leaks. Automatic memory mangers usually consume a great amount of the CPU time and usually have nondeterministic behavior. 7
  • 8. DYNAMIC MEMORY ALLOCATION ALGORITHMS Sequential Fit Sequential fit is the most basic algorithm which uses a single linear list of all free memory blocks called a free list. Free blocks are allocated from this list in one of four ways :  First fit: the list is searched from the beginning, returning the first block large enough to satisfy the request  Next fit: the list is searched from the place where the last search left off, returning the next block large enough to satisfy the request  Best fit: the list is searched exhaustively, returning the smallest block large enough to satisfy the request.  Worst fit : the list is searched; returning largest available free block . 8
  • 9. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) • Sequential Fit Advantage: Simple to understand and easy to apply. Disadvantage: As memory available for allocation becomes large, the search time becomes large and in the worst case can be proportional to the memory size. As the free list becomes large, the memory used to store the free list becomes large; hence the memory overhead becomes large Sequential Fit is not a good strategy for RTSs because it is based on a sequential search, whose cost depends on the number of existing free blocks. 9
  • 10. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) • Buddy allocator A buddy allocator uses an array of free lists, one for each allowable block size. The buddy allocator rounds up the requested size to an allowable size and allocates from the corresponding free list. If the free list is empty, a larger block from another free list is selected and split. A block may only be split into a pair of buddies (of the same size in case of binary buddy system). A block may be coalesced only with its buddy, and this is possible only if the buddy has not been split into smaller blocks. 10
  • 11. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) • Buddy allocator Advantage: The advantage of a buddy system is that the buddy of a block being freed can be quickly found by a simple address computation. Disadvantage: The disadvantage of a buddy system is that the restricted set of block sizes leads to high internal fragmentation, as does the limited ability to coalesce. 11
  • 12. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) Indexed Fit Indexed fits are a class of allocation mechanisms that use an indexing data structure, such as a tree or hash table, to identify suitable free blocks, according to the allocation policy. Advantage This strategy is based on the use of advanced structures to index the free memory blocks thus provide better performance. 12
  • 13. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) Bitmapped Fit Bitmapped Fits are a class of allocation mechanisms that use a bitmap to represent the usage of the heap. Each bit in the map corresponds to a part of the heap, typically a word, and is set if that part is in use. Advantage: In Bitmapped Fit mechanism, the search time is proportional to the bitmap size which result in a small memory overhead. 13
  • 14. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) Two Level Segregated Fit (TLSF)  Two level segregated fit solves the problem of the worst case bound maintaining the efficiency of the allocation and deallocation operations allows the reasonable use of dynamic memory allocation in real-time applications.  provides explicit allocation and deallocation of memory. There exists an increasing number of emerging applications using high amounts of memory, such as multimedia systems, video streaming.  In order to meet these constraints and requirements, two level segregated fit has been designed with guidelines like immediate merging, splitting threshold for optimizes the memory usage which tends to produce the lowest fragmentation on real workloads. 14
  • 15. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) • Two Level Segregated Fit (TLSF)  To implement a good-fit strategy two level segregated fit algorithm uses a segregated fit mechanism. The basic segregated fit mechanism uses an array of free lists, with each array holding free blocks within a size class.  In order to speed up the access to the free blocks and also to manage a large set of segregated lists (to reduce fragmentation) the array of lists has been organized as a two- level array.  The first-level array divides free blocks in classes that are a power of two apart and the second-level sub-divides each first- level class linearly, where the number of divisions can be determined by the user. Each array of lists has an associated bitmap used to mark which lists are empty and which ones contain free blocks. 15
  • 16. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) Smart Memory Allocator Smart Dynamic Memory Allocator is a new allocation style which allows designing a custom dynamic memory allocation mechanism with reduced memory fragmentation and response time. In this algorithm memory blocks is divided into to types: Long lived block and Short lived block. Directions of growing of heap is different for both types of memory blocks. The short lived allocated from bottom to top while the long lived block allocated from top to bottom. 16
  • 17. DYNAMIC MEMORY ALLOCATION ALGORITHMS (cont’d) Smart Memory Allocator  A new smart dynamic memory allocator particularly for embedded systems have limited memory and processing power.  The smart allocator predict the short-lived objects and allocates those objects on one side of the heap memory and remaining objects on other side of the heap memory for effective use of memory footprint.  The allocator reduces the memory fragmentation by using directional adaptive allocation based on the predicted object lifetimes the lifetime can be predicted using a mixture of block size and the number of allocation events.  The allocator is implemented with improved multilevel segregated mechanism by means of lookup tables and hierarchical bitmaps that guarantee very good response time and dependable timing performance. 17
  • 18. Comparison between Different Memory Allocation Algorithms parameters fragmentation Memory footprint usage Response time Sequential fit Large Maximum Slow Buddy System large Maximum Fast Indexed fit large Maximum Fast Bitmapped fit Large maximum Fast TLSF Small Minimum Faster Smart Memory Allocator reduce Minimum The fastest 18
  • 19. CONCLUSION • Dynamic memory allocation is used in many real-time systems. In such systems there are a lot of objects, which are referenced by different threads. • There are different memory allocation algorithms are available. • The major challenges of memory allocator are minimizing fragmentation, providing a good response time, and maintaining a good locality among the memory blocks. 19