Os Report
Os Report
TECHNIQUES
A MINI-PROJECT REPORT
Submitted By
Adithya.V [RA2311027020118]
Jatin.D [RA12311027020104]
Manav [RA2311027020078]
SIGNATURE
Dr. Usha Ruby
Assistant Professor,
DECLARATION
We hereby declare that the entire work contained in this mini project report titled
“MEMORY FRAGMENTATION AND DEFRAGMENTATION
TECHNIQUES ” has been carried out by ADITHYA.V (RA2311027020118),
JATIN.D (RA2311027020104), MANAV (RA23110270120078) at SRM Institute
of Science and Technology, Ramapuram Campus, Chennai - 600089,
Place: Chennai
Date:
ABSTRACT
implementations. The scope covers both software and hardware requirements for
TECHNIQUES
INTRODUCTION
1.1Overview
utilization of memory, as the system might fail to allocate memory even when
Internal Fragmentation: Happens when allocated memory blocks are larger than
lead to crashes, or cause the system to slow down due to frequent memory
address it, and implementing a solution that efficiently manages memory to reduce
or eliminate fragmentation.
resource.
PyCharm
PROJECT DESCRIPTION
3.1 Introduction
The project aims to demonstrate how memory fragmentation occurs and how
memory.
3.3 Algorithm Used
In this project, we use a Best Fit Algorithm to allocate memory and a Compaction
Best Fit Algorithm: It finds the smallest free block that is large enough to
Compaction Algorithm:
larger allocations.
Detailed logs showing how memory blocks were allocated and deallocated.
Performance metrics before and after applying the defragmentation algorithm,
defragmentation process.
APPENDIX
Source Code
The source code for the project includes modules for memory management,
core logic:
CODE
#include <stdio.h>
#include <stdlib.h>
#define MAX_BLOCKS 10
Typedef struct {
Int size;
Int allocated;
} Block;
Block memory[MAX_BLOCKS];
Memory[i].size = sizes[i];
Memory[i].allocated = 0;
Best_index = i;
Best_fit_size = memory[i].size;
If (best_index != -1) {
Memory[best_index].allocated = 1;
} else {
Void defragment() {
Memory[last_allocated].size += memory[i].size;
Memory[i].size = 0;
If (memory[i].allocated) {
Last_allocated = i;
Printf(“Memory defragmented\n”);
}
Int main() {
Int sizes[MAX_BLOCKS] = {100, 200, 300, 400, 500, 600, 700, 800, 900,
1000};
Init_memory(sizes);
Best_fit(350);
Best_fit(450);
Defragment();
return 0;
}
Output:
Memory defragmented
The project successfully demonstrates how memory fragmentation occurs and the
employing the Best Fit and Compaction algorithms, the system achieves better