What is fragmentation? Example?
Fragmentation:
Fragmentation refers to the phenomenon where files or data are divided and scattered into smaller pieces or fragments across a storage device. It occurs when the available free space on a storage medium is divided into smaller chunks due to the allocation and deallocation of files. Fragmentation can happen in both physical and logical storage systems.
Types of Fragmentation:
There are two types of fragmentation:
1. External Fragmentation: External fragmentation occurs when free space is scattered throughout the storage medium, making it difficult to allocate contiguous blocks of memory for new files or data. It happens over time as files are created, modified, and deleted, leaving fragmented gaps between allocated blocks. This type of fragmentation typically affects traditional mechanical hard drives.
2. Internal Fragmentation: Internal fragmentation occurs when the allocated space for a file or data is larger than what is actually needed. It happens when files are stored in fixed-sized blocks or sectors, and the remaining space within each block is wasted. This type of fragmentation is more common in file systems that use fixed block sizes, such as FAT32 or NTFS.
Example:
Let's consider an example to understand fragmentation better:
Imagine a hard drive with a total capacity of 100 GB. Initially, the drive is empty, and there is a single large block of free space available. Now, suppose you want to save three files: File A (10 GB), File B (20 GB), and File C (30 GB).
1. Contiguous Allocation: If the files are stored using contiguous allocation, they would be saved in consecutive blocks of 10 GB, 20 GB, and 30 GB, respectively. However, if File B is deleted later, it would create a gap of 20 GB between File A and File C, resulting in external fragmentation.
2. Linked Allocation: If the files are stored using linked allocation, each file would be divided into smaller blocks or fragments, and the file allocation table would keep track of the links between these fragments. In this case, fragmentation would not be an issue, as files can be scattered across the storage medium.
3. Indexed Allocation: If the files are stored using indexed allocation, each file would have an index block that contains pointers to the locations of its data blocks. Again, fragmentation would not be a concern as files can be stored in non-contiguous blocks.
Conclusion:
Fragmentation can lead to decreased performance and inefficiency in storage systems. It can cause slower read/write operations, increased seek time, and wasted storage space. Defragmentation is a process used to reduce fragmentation by rearranging files and data to make them contiguous and improve system performance.
To make sure you are not studying endlessly, EduRev has designed Class 7 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 7.