[go: up one dir, main page]

0% found this document useful (0 votes)
12 views27 pages

Jai Project 1

The document is a lab project report on 'Dynamic Memory Allocator' submitted by students of Joginpally B.R. Engineering College for their Bachelor of Technology in Information Technology. It discusses the principles of dynamic memory allocation, including various techniques and their performance implications, while also addressing issues like fragmentation and memory management efficiency. The report includes acknowledgments, declarations, and an abstract summarizing the project's significance and objectives.

Uploaded by

Jagadeesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views27 pages

Jai Project 1

The document is a lab project report on 'Dynamic Memory Allocator' submitted by students of Joginpally B.R. Engineering College for their Bachelor of Technology in Information Technology. It discusses the principles of dynamic memory allocation, including various techniques and their performance implications, while also addressing issues like fragmentation and memory management efficiency. The report includes acknowledgments, declarations, and an abstract summarizing the project's significance and objectives.

Uploaded by

Jagadeesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

JOGINPALLY BR ENGINEERING COLLEGE

A Lab Project Report On

DYNAMIC MEMORY ALLOCATOR


Is Submitted to Joginpally BR Engineering College (UGC Autonomous) , Hyderabad. In
partial fulfillment of the requirements for the award of the degree of

BACHELOR OF TECHNOLOGY
IN

INFORMATION TECHNOLOGY

SUBMITTED

Ch Mani Deekshith (23J21A1211)


J Ananth Kumar (23J21A1216)
P Jaya Prakash (23J21A1237)

Under the guidance of

Dr. SHAIK ALEEM BASHA M.Tech,Ph.D


Associate Professor

DEPARTMENT OF INFORMATION TECHNOLOGY

JOGINPALLY B.R. ENGINEERING COLLEGE


(UGC Autonomous)
Accredited by NAAC with A+ Grade, Recognized under Sec. 2(f) of UGC Act. 1956
Approved by AICTE and Affiliated to Jawaharlal Nehru Technological University,
Hyderabad Bhaskar Nagar, Yenkapally, Moinabad,
RangaReddy, Hyderabad, Telangana- 500075.

2024-2025

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

JOGINPALLY B.R ENGINEERING COLLEGE


(UGC Autonomous)

Accredited by NAAC with A+ Grade, Recognized under Sec. 2(f) of UGC Act. 1956
Approved by AICTE and Affiliated to Jawaharlal Nehru Technological University,
Hyderabad

Bhaskar Nagar, Yenkapally, Moinabad,

RangaReddy, Hyderabad, Telangana- 500075.

CERTIFICATE

This is to certify that the Lab Project entitled “DYNAMIC MEMORY ALLOCATOR” is the
bonafide work carried out by CH.ManiDeekshith (23J21A1211), J.Ananth
Kumar(23J21A1216), P. Jaya Ptrakash (23J21A1237) of II B.Tech IT, under our guidance
and supervision.The Lab Project Report is submitted to Joginpally BR Engineering College
(UGC Autonomous) Hyderabad in partial fulfilment of requirements of the award of the
degree of Bachelor of Technology in Information Technology during theacademic year 2024-
2025.

INTERNAL GUIDE HEAD OF THE


DEPARTMENT
Dr.ALEEM BASHA Dr.T.SHESHAGIRI
Associate Professor Associate Professor

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

Principal

ACKNOWLEDGEMENT
We express our hearted thank you to our principal Dr. B Venkata Ramana Reddy for giving
us spontaneous encourage for completing the Lab project.

We are really thank you to our HOD Dr. T. Sheshagiri for his time to time, much needed
valuable guidance throughout our Lab project.

We would like to express our sincere gratitude to our LAB PROJECT INTERNAL GUIDE
Dr.shaik Aleem Basha who has guided and supported us through every stage in the Lab
Project.

Ch Mani Deekshith (23J21A1211)


J Ananth kumar (23J21A1216)
P Jaya Prakash (23J21A1237)

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

DECLARATION

We hereby declare that our Lab Project entitled “DYNAMIC MEMORY ALLOCATOR”
is the work done during the academic year 2024-2025, II year - I-Sem and our Lab Project
is submitted in partial fulfilment of the requirements for the award of B.Tech degree in
Information Technology from JOGINPALLY B.R. ENGINEERING COLLEGE (UGC
Autonomous),Hyderabad.

Ch Mani Deekshith (23J21A1211)


J Ananth kumar (23J21A1216)
P Jaya Prakash (23J21A1237)

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

ABSTRACT
A Dynamic Memory Allocator is a system component responsible for managing memory
allocation and deallocation during program execution. Unlike static memory allocation,
which assigns fixed memory at compile time, dynamic memory allocation enables efficient
and flexible memory utilization at runtime. This is particularly useful in applications with
unpredictable memory requirements, such as operating systems, embedded systems, and
highperformance computing.
This paper discusses the fundamental principles of dynamic memory allocation, including
heap management, fragmentation, and garbage collection techniques. It explores common
implementations like malloc/free, buddy system, slab allocation, and memory pools,
analyzing their advantages and trade-offs. Performance optimization strategies such as
best-fit, first-fit, and worst-fit algorithms are also examined.
Efficient memory management is crucial for system performance, reducing memory
fragmentation, and improving execution speed. Future advancements in dynamic memory
allocation involve hardware-assisted techniques, intelligent compaction methods, and
machine learning-based predictive allocation.
This study provides insights into the design and implementation of dynamic memory
allocators, highlighting challenges and solutions for optimized memory management in
modern computing systems.

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

CONTENTS
I. Cover Page
Abstract
II. Introduction
II.1Basic concepts on Dynamic Memory Allocator
II.1.1 Fragmentation
II.1.2 Internal Fragmentation
II.1.3 External Fragmentation
II.1.4 Total Fragmentation
II.2Executing Time
3 Memory Allocation Techniques
3.1 Linked list Techniques
3.1.1 First Fit
3.1.2 Next Fit
3.1.3 Best Fit
3.1.4 Worst Fit
3.2 Buddy System
3.2.1 Binary Buddy System
3.2.2 Fibonacci Buddy System
3.2.3 Waited Buddy System
4 Simulation and Performance Analysis
5 Algorithm
6 Code
7 Test case

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

8 Experimental results or Outputs


9 Conclusion
10 References

I. INTRODUCTION

Memory manager performs memory allocation process. It is reported that dynamic


memory management consumes 23%-38% of the time in six allocation-intensive C
programs running on 17-SPECmarks SPARC architecture with 80 MB of memory [1].
Object-oriented programs have a very high object creation rate and, therefore, the speed of
memory allocation is crucial for improving the system performanc

Received Date : 10.12.2004 Accepted Date: 27.03.2005 Until now, improved software
techniques by using various data structures are separated into three different categories:
Bitmap, Linked List techniques, Buddy Systems.

Bitmap implementation use a bitmap, where each bit represents some portions of memory
and indicates whether it is free or occupied.

The most popular method in dynamic memory allocation techniques is Linked Lists. First
Fit, Best Fit, Worst Fit and Next Fit Linked List techniques are well known and frequently
used. Although Memory usage of these algorithms is good, list structure leads to decrease
running speed of these algorithms. Each memory request (malloc function in C
programming language) causes to search all list sequentially. The memory manager scans
among the list until it finds blocks that are big enough. The hole is then broken into two
pieces; one for the process and one for the unused memory.

The most popular method in dynamic memory allocation techniques is Linked Lists. First
Fit, Best Fit, Worst Fit and Next Fit Linked List techniques are well known and frequently
used. Although Memory usage of these algorithms is good, list structure leads to decrease
running speed of these algorithms. Each memory request (malloc function in C
programming language) causes to search all list sequentially. The memory manager scans

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

among the list until it finds blocks that are big enough. The hole is then broken into two
pieces; one for the process and one for the unused memory.

In computer systems, memory management plays a crucial role in ensuring


efficient

and reliable operation. Dynamic memory allocation is a technique that enables programs to
allocate and manage memory at runtime, allowing for flexible and efficient use of system
resources. A dynamic memory allocator is a software component responsible for managing
the allocation and deallocation of memory blocks, ensuring that memory is used efficiently
and minimizing memory-related errors.

Background
Dynamic memory allocation involves allocating memory blocks of varying sizes
from a larger memory pool. The allocator must ensure that memory blocks are allocated
efficiently, minimizing fragmentation and reducing the risk of memory-related errors.
Dynamic memory allocators are used in a wide range of applications, from operating
systems and embedded systems to high-performance computing and cloud computing.

Importance of Dynamic Memory Allocation

Dynamic memory allocation is essential for several reasons:

1. Efficient Memory Use: Dynamic memory allocation enables programs to allocate


memory only when needed, reducing memory waste and improving overall system
efficiency.

2. Flexibility: Dynamic memory allocation allows programs to allocate memory blocks of


varying sizes, enabling flexible and efficient memory management.

3. Reliability: Dynamic memory allocation helps minimize memory-related errors, such


as memory leaks and buffer overflows.

2.1 BASIC CONCEPT OF DYNAMIC MEMORY ALLOCATION


The goal of allocator design is usually to minimize wasted space without undue time cost.
An allocator must keep track of which parts of memory are in use and which parts are free.
A conventional allocator can not control the number or size of live blocks. A conventional
allocator also can not compact memory, moving blocks to make them contiguous. It must

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

respond immediately to a request for space deciding which block of memory to allocate. It
can only deal with memory whether it is free and only choose where in free memory to
allocate the requested block

2.1.1 FRAGMENTATION
Fragmentation is one of the most important problem that an allocator encounters. The
fragmentation problem prevents memory to be used effectively. Fragmentation is classified
as external or internal [6].

2.1.2. Internal Fragmentation


Unless the set of requested block sizes is a subset of the set of provided block sizes, it will
be necessary to allocate more memory space than requested block size. The memory
wasted due to this overallocation is internal fragmentation. Measure of internal
fragmentation is the ratio of number of overallocated blocks to number of allocated
memory.

2.1.3. External fragmentation


External fragmentation happens when available free blocks at memory are too numerous
and small and can not be used to allocate next requests for larger blocks. Measure of
external fragmentation is the proportion of total memory which is available when overflow
occurs .

2.1.4. Total fragmentation


Internal and external fragmentation are an expected result of different properties of the
methods used in memory allocation. But, both decrease the effective size of available
memory due to creation of memory portions that can not be used. We define total
fragmentation to be total amount of memory which is unusable due to either internal or
external fragmentation. Since
our definition of internal fragmentation is the propotion of allocated memory which is
unusable, while external fragmentation is a proportion of total memory, total
fragmentation is not simple sum of internal and external fragmentation, but rather
calculated as,

total =(1− External)*Internal+ External (3) total = Internal+ External−(Internal*External)

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

2.2 EXECUTING TIME


Another performance criteria in memory allocation is execution time (allocation and
deallocatin duration). Splitting and coalescing performed for decreasing fragmentation
increases the running time. In general, running time is inversely proportional to
fragmentation.

3. MEMORY ALLOCATION TECHNIQUES


Very different techniques are developed to combat fragmentation. Although, some of
them decrease external fragmentation, the others solve internal fragmentation. But,
there is not yet any mechanism to solve this problem perfectly. The basic allocation
mechanisms are separated into 3 categories [5]:

Bitmap
Linked List techniques: First Fit, Best Fit, Next Fit, Worst Fit
Buddy Systems: Binary, Fibonacci,
Weighted

3.1. BIT MAP TECHNIQUE


The fundamental of Bitmap technique is that status of each blocks in memory is
represented with a bit in Bit map which is 0 if the block is free and 1 if it is allocated.
Figure 1 shows part of the memory and the corresponding bit map. The smaller the
allocation unit, the larger the bitmap.

In spite of simplicity, the main problem is that when it has been decided to bring a k
unit process into memory, the memory manager must search the bit map to find k
consecutive 0 bits in the bit map. Searching a bit map for a request is a slow operation,
so in practice, bit maps are not often used.

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

Figure 1: (a) A part of memory with five processes and 3 holes. The tick marks show
the memory allocation units. The shaded regions (0 in the bit map) are free. (b) The
corresponding bit map

3.1 LINKED LIST TECHNIQUES


Memory management techniques by using Linked lists is the most used technique. These
techniques allocate by using linked list structure.

Linked list techniques used more frequently are;

First Fit: Allocate the first hole that is big enough.


Next Fit: Allocate the first hole that is big enough starting where it left off.
Best fit: Allocate the smallest hole that is big enough.
Worst Fit: Allocate the largest hole
3.1.1. First Fit
The memory manager starts to scan from beginning of the lists until it finds a hole that is big
enough. The hole is then broken up into two pieces, one for the process and one for the unused
memory. A problem with first fit is that the larger blocks near the beginning of the list tend to
be split first and the remaining fragments result in having a lot of small blocks near the
beginning of the list. These small memory blocks can increase search times. Because many
small free blocks accumulate and the search must go through them each time a larger block is
requested.

3.1.2. Next Fit


The greatest difference of this technique from others is that search starts always different place
of the list. The pointer records the position where the last search was satisfied and the next

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

search begins from there. By means of this feature, Small and awkward memory hole can not
accumulate at the beginning of the list as first fit technique

3.1.3. Best Fit


A best fit allocator searches the list to find smallest free blocks large enough to satisfy a
request and then allocate this blocks. Best fit is slower than first fit and next fit. Because it
must search the entire list every time it is called.

It is expected from this strategy that unused holes are decreased. But, this is not performed and
first fit algorithm may be more successful from this point of view. Because, after allocation are
performed, the remainder may be quite small and perhaps unusable for next larger request. A
little time later, memory has a lot of small blocks and total unused area is too much than that of

Figure 2:sample representation of linked lists


(a) a part of memory (b) Corresponding linked
list

first fit.

3.1.4. Worst Fit


Working manner of this technique is more similar to best fit. Difference between them is that
while best fit select the smallest hole, worst fit take the largest available hole. This strategy
produces the largest leftover hole, which may be more useful than the smaller leftover from a
best fit approach

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

3.2. BUDDY SYSTEMS


Important property for the buddy systems over first fit or best fit memory management
schemes was its reduction in search time to find and allocate an available block of appropriate
size. By means of using tree structure, finding appropriate hole is performed faster.

Although Buddy system is faster, it has a very important disadvantage. Buddy systems are
inefficient in memory usage. Though the linked list techniques have only external
fragmentation, buddy systems have both internal and external fragmentation. Basis reason of
this problem is that allocated blocks are power of two (for Binary buddy system). Therefore,
first request size round up to smallest number that is power of two (for binary buddy) then
allocation process is performed.

3.2.1. Binary Buddy System

Working mechanism of Binary buddy system is as follows: We start with the entire block of
size 2U. When a request of size S is made: If 2U-1 < S<= 2U then allocate the entire block of
size 2U. Else, split this block into two buddies, each of size 2U-1. If U-2< S<= 2U-1 then
allocate one of the two buddies. Otherwise one of the two buddies is split in half again. This
process is repeated until the smallest block greater or equal to S is generated [7].

Figure 3 shows the settlement of binary buddy system at binary tree. Striped circle, white
circle and gray circle represent respectively split blocks for allocation, leave nodes that show
free blocks, nodes that shows used memory chunks.

3.2.2. Fibonacci Buddy System


In this system, blocks are split in respect of Fibonacci numbers. Working mechanism of it is
similar to binary buddy system. Fibonacci series are defined as follows.

F0 =0,F1 =1,Fn+2 =Fn+1 +Fn(n≥0)

According to this definition, the elements of Fibonacci series: 0, 1, 2, 3, 5, 8, 13, 21, 34, 55,
89, 144, 233, 377, 610, 987...
Figure 4 shows sample tree structure of Fibonacci Buddy systems.

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

Figure 4: Tree structure of Fibonacci Buddy system

3.2.3. Weighted Buddy System


At the Weighted Buddy system, block sizes are as 2k or 3* 2k.
When blocks are split, applied rules are showed in figure 5 and 6.

As showed in figure 5a, If split block size is 2 k+2, this block are split to 3*2k+2 and 2k block
size. If block size is 3*2k+2(Figure 6b), it separated into 2k+1 and 2k block sizes [3*2k -> (2k+1,
2k)].

Figure 5: (a) Splitting of 2k+2 block size

(b) Splitting of 3*2k+2 block size

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

4. SIMULATION AND PERFORMANCE ANALYSIS


Some of the examined software techniques are simulated for performance analysis by using
C++ programming language. For this purpose, First Fit, Best fit, Worst Fit, Bit map, Binary
Buddy and Weighted Buddy software techniques are simulated. Simulation results are
obtained for selected performance criteria that are fragmentation, allocation and deallocation
duration in respect of memory size and maximum allocatable object size. (Figure 8-10) In
practice, nodes which have a few fields for holding allocation information are defined using
“struct NODE” structure. This structure consist of field which hold father, left child, right
child in tree structure and next address in list. Another field indicates status of blocks. If the
value is ‘1’, blocks are allocated, otherwise they are free. Allocation and deallocation
processes are executed by using tree or list which is formed based on this defined structure.
Defined specially by Mymalloc and
Myfree functions at the program are called randomly with 66%- 33% probabilities
respectively. Generated and allocated values are saved in an array. When Myfree function is
called, a value is selected randomly and then these blocks are deallocated. This array hold
allocated address values. The aim of using this array is that it is not possible to deallocate the
address which has not been allocated.

Allocation processes are performed by using generated random numbers in program. Internal
and external fragmentation is calculated after each allocation process. In this practice, total
fragmentation is calculated by using average internal and external values for 100 steps.

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

Allocation and deallocation process can not be calculated sensitively by using classic time
function in C++. Because, running time implements in very short time. In order to solve this
problem, Windows API

“QueryPerformanceFrequency” is used. By this API, each allocation and deallocation duration


and their average are calculated in the micro second type. Program is run 100 times for
obtaining more realistic results.

Buddy systems suffer from both internal and external fragmentation. The others have only
external fragmentation. Internal and external fragmentation values of binary and weighted
buddy systems are showed graphically in figure 7.

As shown in figure, it can be observed that Weighted buddy system suffers from internal
fragmentation less than Binary buddy. In contrast, in respect of external fragmentation binary
buddy is more successful. Another result obtained from this figure is that maximum
allocatable block number is directly proportional to external fragmentation.

In this study, although results of all techniques are obtained in respect of performance criteria,
Graphics are drawn only for the best method in each category. In this way, the performance of
categorically classified methods is evaluated.

Figure 7: Internal and External fragmentation of Buddy Systems

In figure 8, In respect of fragmentation criteria, First fit is the best and Binary buddy is the
worst technique. Allocation of bit map method gives close similarity to first fit. Because,
searching bits is performed as first fit.

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

Figure 9 shows that, according to allocation process, the best performance technique is binary
buddy, the worst is bitmap. Search process in tree structure can be done in shorter time than in
list structure. So, Buddy systems have the best performance in respect of allocation process
duration. In contrast, in bit map techniques, allocation is faster at small memory sizes due to
searching at bits and not splitting. The bigger memory size, the slower allocation time in the
bit map.

In figure 10, in respect of deallocation duration performance criteria, the most successful

technique is observed as bit map. As coalescing process is used in bitmap technique,

deallocation process is performed in short time by updating the bitmap by inverting (from 1 to

0) all bits corresponding deallocated blocks.

Figur 8: Total fragmentation values of techniques

Firt Fit Bit Map Binary Buddy

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

Figure 9: Allocation duration of techniques (micro second)

Figure 10: Deallocation duration of techniques

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

5. ALGORITHM
For a dynamic memory allocator project, you can implement algorithms like First-Fit, Best-Fit,
or Worst-Fit, which manage memory allocation and deallocation by searching for suitable free
blocks and splitting/merging them as needed.
Here's a breakdown of the key concepts and algorithms:
1. Understanding Dynamic Memory Allocation:
Heap:
Dynamic memory allocation deals with the heap, a region of memory where you can request
and release memory during program execution.
Allocation:
The allocator finds free blocks of memory large enough to satisfy the request and returns a
pointer to the beginning of that block.
Deallocation:
When memory is no longer needed, the allocator marks the block as free, potentially merging it
with adjacent free blocks.

2. Common Algorithms:
First-Fit:
Searches for the first free block that's large enough.
Simple to implement but can lead to fragmentation.
Best-Fit:
Searches for the smallest free block that's large enough.
Can reduce external fragmentation but might increase internal fragmentation.
Worst-Fit:
Searches for the largest free block.
Can lead to large free blocks being used for smaller requests, potentially wasting space.
Next-Fit:
Similar to first-fit, but starts searching from the point where the last allocation was made.
Can lead to better memory utilization than first-fit, but still suffers from fragmentation.

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

6.CODE
#include <stdio.h>
#include <stdlib.h>
typedef struct { int
process_id; int
arrival_time; int
burst_time; int
completion_time; int
turn_around_time; int
waiting_time;
} Process;
// Function to calculate and display waiting and turn-around times
void calculateTimes(Process *processes, int n) { int
total_waiting_time = 0; int total_turn_around_time = 0;
// Calculate completion time, turn around time, and waiting time for each process
processes[0].completion_time = processes[0].arrival_time + processes[0].burst_time;
processes[0].turn_around_time = processes[0].completion_time - processes[0].arrival_time;
processes[0].waiting_time = processes[0].turn_around_time - processes[0].burst_time;
total_waiting_time = processes[0].waiting_time;
total_turn_around_time = processes[0].turn_around_time;
for (int i = 1; i < n; i++) {
processes[i].completion_time = processes[i-1].completion_time +
processes[i].burst_time;
processes[i].turn_around_time = processes[i].completion_time -
processes[i].arrival_time; processes[i].waiting_time = processes[i].turn_around_time -
processes[i].burst_time;
total_waiting_time += processes[i].waiting_time;
total_turn_around_time += processes[i].turn_around_time;
}
// Display results

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

printf("\nProcess ID\tArrival Time\tBurst Time\tCompletion Time\tTurnaround


Time\tWaiting Time\n");
for (int i = 0; i < n; i++) {
printf("%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\n", processes[i].process_id,
processes[i].arrival_time, processes[i].burst_time, processes[i].completion_time,
processes[i].turn_around_time, processes[i].waiting_time);
}
printf("\nAverage Waiting Time: %.2f\n", (float)total_waiting_time / n);
printf("Average Turnaround Time: %.2f\n", (float)total_turn_around_time / n); }
int main() {
int n;
// Input the number of processes
printf("Enter the number of processes: ");
scanf("%d", &n);
// Dynamically allocate memory for processes
Process *processes = (Process *)malloc(n * sizeof(Process));
if (processes == NULL) {
printf("Memory allocation failed!\n");
return 1; // Exit if memory allocation fails
}
// Input process details (ID, Arrival time, Burst time)
for (int i = 0; i < n; i++) { processes[i].process_id
= i + 1;
printf("\nEnter details for Process %d\n", processes[i].process_id);
printf("Arrival Time: ");
scanf("%d", &processes[i].arrival_time);
printf("Burst Time: ");
scanf("%d", &processes[i].burst_time);
}

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

// Call the function to calculate and display times


calculateTimes(processes, n);

// Free the dynamically allocated memory


free(processes);
return 0;
}

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

7.TEST CASES

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

8.EXPERIMENTAL RESULTS/OUTPUTS

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

9.CONCLUSION

In this paper, Performance analysis of examined memory allocation techniques is performed


comparatively in respect of performance criteria.
The performance analysis of examined memory allocation techniques, a Simulator is written
in C++ programming language. In this study, although results of all techniques are obtained, in
respect of performance criteria, Graphics are drawn only for the best method in each category.
In this way, the performance of methods classified categorically is evaluated. Despite First Fit
listing technique shows better performance according to fragmentation, it can not show the
same success in respect of allocation and deallocation time. Binary buddy is very fast but it

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

has the worst at fragmentation rate. According to these results, it is seen that there are not yet
the best performance techniques point from all performance criteria.
Consequently, it can not be said that the basic memory allocation techniques are successful. To
minimize the fragmentation problem and to allocate faster, new memory allocation techniques
can be implemented by using hardware structure.
It is suggested that by using new and different data structures, faster and more efficient
memory allocators can be achieved.

10.REFERENCES

 Zorn B., July 1993, The measured cost of conservative garbage collection,
SoftwarePractıce And Experıence, Vol. 23, No. 7, 733-756
 Shen. K.K. and Peterson, J.L., Oct. 1974, A weighted buddy method for dynamic
storage allocation. Communications Of The ACM 17, 10, 558-562
 Barkle, R.E. ve Lee T.P., Dec 1989, A Lazy Buddy System Bounded by Two
Coalescing Delays per Class, Proc. 12th Symp. OpertatınSystem
Prıncples,vol:23,no:5, 167-176
 Hırschberg, D.S., Oct. 1973, A class of dynamic memory allocation algorithms.
 Communications Of The ACM 16, 10, 615-618
 Tanenbaum A.S. ve Woodhull A. S., 1997, Operating Systems Design and
Implementation,
 Prentice Hall, Portland, 0-13-638677-6
 Wilson P. R., Johnstone M. S., Neely M. ve Boles D., September 1995, Dynamic
Storage

DYNAMIC MEMORY ALLOCATOR


JOGINPALLY BR ENGINEERING COLLEGE

 Allocation: A Survey and Critical Review, International Workshop on Memory


 Management, Kinross, Scotland, UK
 Peterson J.L. ve Norman T.A., June 1977, Buddy systems, Communications Of The
ACM, Vol. 20, 421-431

DYNAMIC MEMORY ALLOCATOR

You might also like