Fragmentation in Operating System

Operating System | Fragmentation: In this tutorial, we will learn what is fragmentation, cause of fragmentation, types of fragmentation, etc. By Monika Jha Last updated : May 05, 2023

Overview

In a computer storage system, as processes are loaded and removed from memory, the free memory space is broken into small pieces. In this way memory space used inefficiently, so the capacity or performance of the system may degrade.

The conditions of the fragmentation depend on the system of memory allocation. In most of the cases, memory space is wasted.

Sometimes it happens that memory blocks cannot be allocated to processes due to their small size and memory blocks remain unused. This problem is known as Fragmentation.

Cause of Fragmentation

User processes are loaded and removed from the main memory, processes are stored in the blocks of main memory. At the time of process loading and swapping there are many spaces left which are not capable to load any other process due to their size.

Due to the dynamical allocation of main memory processes, main memory is available but its space is not sufficient to load any other process.

Types of Fragmentation

The following are the types of fragmentation:

  1. External fragmentation
  2. Internal fragmentation
  3. Data fragmentation

1. External Fragmentation

External fragmentation exists when adequate total memory space exists to satisfy a request, but it is not contiguous; storage is fragmented into a large number of holes.

External fragmentation in OS

2. Internal Fragmentation

An approach is to allocate very small holes as part of the larger request. Thus the allocated memory may be larger than the requested memory.

The difference between these two numbers is internal fragmentation - the memory that is internal to any partition but is not being used.

Internal fragmentation in OS

There is a hole of 500k. Suppose that next process request 450k. If we allocate the requested block, so there is a hole left which is 50k. This type of condition raises internal fragmentation.

3. Data Fragmentation

This type of fragmentation occurs when a group of data in memory is broken up into many pieces that are not contiguous that is not close together.

If we are attempting to insert a large object into memory that has already suffered then external fragmentation occurs.

Example:

In a file system files are arranged in units called clustersblocks. There is a free space to store files in these blocks in a contiguous manner.

In this way, we can do a rapid sequential file reads and writes. As files are added, deleted, and modified or changed in size, there are external fragmentation occurs, and there are only small holes in which we can place new data.

when a current file is enlarged, the operating system places the new data a in new non-contiguous data blocks to fit into the available holes. New data blocks don't need to be contiguous. This process slowing access cause of seek time and rotational latency of the read/write head and incurring additional overhead to organize additional locations. This is file system fragmentation.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.