Operating Systems
Operating Systems
SYSTEM
Disk Fragmentation, Storage Allocations,
File Systems
22/06/2024
EXTERNAL AND INTERNAL DISK
FRAGMENTATION
External Fragmentation
• What it is:
• Cause:
• Analogy:
Imagine a collection of boxes in a storage room. As you take boxes out,
empty spaces appear, but they might be scattered around the room and
too small to fit new boxes of a certain size. External Fragmentation:
Internal Fragmentation:
• What it is:
Internal fragmentation refers to wasted space within a single allocated
memory block. This happens when the allocated block is larger than the
actual size of the data it needs to hold. The leftover space within the
block is unusable for other purposes.
• Cause:
Internal fragmentation is a consequence of using fixed-size memory
allocation. When a program or file needs memory, it's assigned the
smallest available block that can fit it entirely. This often results in some
unused space at the end of the block.
• Analogy:
Imagine a drawer where you store socks. You might have a large drawer
allocated for socks, but if you only have 5 pairs, there's wasted space in
the drawer that can't be used for other things.
2
3
Indexed Allocation
efficient storage utilization, fast random access, and scalability for large
files. However, for scenarios dealing primarily with very small files or
requiring the absolute fastest write performance, other allocation
methods like contiguous allocation might be preferable.
Advantages
• Reduced Fragmentation:
4
Unlike contiguous allocation, indexed allocation eliminates external
fragmentation. Since file data is stored in non-contiguous blocks on the
disk, gaps between files don't hinder future storage allocation. This
leads to more efficient utilization of disk space. No wasted space (like
leaving empty folders in the cabinet)
Indexed allocation excels at random access. Each file has an index block
that stores pointers to all the data blocks belonging to that file. This
allows the operating system to quickly locate any specific portion of the
file by simply referencing the index and the corresponding data block
address. Easy to jump to any part of a file (like quickly finding a specific
document)
Indexed allocation is well-suited for storing large files. The index block
can accommodate pointers to a vast number of data blocks, enabling
efficient management of large datasets. Can hold really big files (like
storing a whole bunch of papers)
5
require updating the index block with new data block pointers, adding
an extra step compared to contiguous allocation. Might be slightly
slower for tiny files (like a single sheet of paper)
• Complexity: Managing the index data adds some complexity to the file
system compared to simpler allocation methods. A bit trickier to update
files (like adding or removing papers requires changing the index card)
Contiguous allocation
Imagine a bookshelf where each book needs its own whole shelf. That's
contiguous allocation.
Advantages:
• Simple Implementation:
6
• Fast Access:
Since data is stored in contiguous blocks, accessing any part of the file or
program involves minimal head movement for the disk drive's
read/write head, leading to faster data retrieval. This is beneficial for
applications that require frequent random access to data. Easy to find
your book (fast access)
• No External Fragmentation:
Disadvantages:
• Internal Fragmentation:
• Limited Scalability:
7
Contiguous allocation can be challenging for large files or dynamic
memory allocation scenarios where process sizes can vary significantly.
Finding a single contiguous block large enough for a growing file can
become difficult as the disk fills up with other files. Hard to fit in new
books if shelves are full (limited scalability)
However, for systems with dynamic memory allocation needs, large file
sizes, or a significant number of processes competing for memory,
contiguous allocation might not be the most efficient approach. Other
allocation methods like indexed allocation or paging might be better
suited for such scenarios.
Linked allocation
8
Linked allocation is a valuable approach for file systems that prioritize
efficient space utilization, scalability for growing files, and a relatively
simple implementation. However, for scenarios where random access
performance is critical or dealing with primarily very small files, other
allocation methods like indexed allocation might be more suitable.
Linked allocation is well-suited for storing files that might grow in size
over time. New data blocks can be easily appended to the existing file
chain, accommodating the expanding file size without needing to
relocate the entire file.
9
• Simplicity of Implementation:
The integrity of the linked chain is crucial for accessing file data. it a
pointer becomes corrupted or accidentally overwritten, it can break the
chain and render the file inaccessible. Recovery might require additional
effort using file system utilities.
The FAT file system is a common format for data storage, known for:
10
• Simplicity & Compatibility: Easy to implement and works across
various devices and OSes.
• Small File Efficiency: Handles many small files well with minimal
overhead.
• Scalability:
Not ideal for very large drives due to growing FAT table size.
• Security:
Use FAT for removable media, legacy systems, or situations with mainly
small files. For larger files, advanced security, or bigger storage volumes,
consider NTFS, ext4, or exFAT.
• Legacy Systems:
11
FAT is still supported by many older systems and devices, ensuring data
accessibility across different platforms.
When dealing with primarily small files and limited storage volumes,
FAT can be a sufficient and efficient option.
• Journaling:
NTFS keeps track of file system changes in a journal, allowing for faster
recovery from errors or unexpected shutdowns. It's like having a backup
log of what you did in your filing cabinet, making it easier to undo
mistakes or restore lost files.
• Error Correction:
12
NTFS excels at handling large files efficiently. Unlike FAT, which has
limitations on file size, NTFS can accommodate massive files commonly
used for multimedia content, databases. NTFS can handle much larger
files compared to FAT, making it suitable for storing big videos,
databases, or other voluminous data. Your filing cabinet can now
accommodate even giant folders.
• Disk Optimization:
Additional Features:
• Long Filenames:
13
• Disk Quotas:
• Large partitions:
• Multi-user environments:
Overall, NTFS is a secure, reliable, and efficient file system for modern
computing needs.
14