1. Start From the Core Idea

Before understanding allocation techniques, think about how a file might be stored on a disk.

Suppose a file contains data that occupies five disk blocks. The simplest approach is to place all five blocks next to each other on the disk.

Block 10 | Block 11 | Block 12 | Block 13 | Block 14

The file occupies one continuous region of storage.

This is the fundamental idea behind Contiguous Allocation.

Why This Seems Attractive

If all blocks are stored together:

  • Reading becomes straightforward

  • Disk head movement is minimized

  • Access calculations become simple

  • Performance is very high

Because of these advantages, contiguous allocation was one of the earliest file allocation methods used in operating systems.

Key Insight

The entire file is stored in one continuous sequence of disk blocks.


2. What is Contiguous Allocation?

Contiguous Allocation is a file allocation method in which all blocks of a file are stored in adjacent (continuous) locations on the disk.

Definition

A file occupies a set of consecutive disk blocks, and the operating system stores only:

  • Starting Block Number

  • Length of File (in blocks)

Key Idea

File = Starting Block + Length

Instead of storing pointers to every block, the OS simply remembers where the file begins and how many blocks it occupies.

Example

Suppose:

File A
Start Block = 10
Length = 5 Blocks

Disk Layout:

10 | 11 | 12 | 13 | 14

The operating system knows:

Start = 10
Length = 5

That is enough information to access the entire file.

Key Insight

The operating system does not need block-by-block tracking because every block location can be calculated mathematically.


3. Visualization of Contiguous Allocation

Disk Before Allocation

0  1  2  3  4  5  6  7  8  9
F  F  F  F  F  F  F  F  F  F

(F = Free)

Allocating a File of 5 Blocks

0  1  2  3  4  5  6  7  8  9
F  F  A  A  A  A  A  F  F  F

Where:

A = File A

Directory Entry

File Name : A
Start     : 2
Length    : 5

Another Example

Disk

|----A----|--B--|----C----|

10 11 12 13 14

File A:

Start = 10
Length = 5

File B:

Start = 15
Length = 2

File C:

Start = 17
Length = 4

Key Insight

Files occupy continuous stretches of disk space without gaps.


4. How It Works (Step-by-Step)

Step 1: File Creation

When a new file is created:

create("report.txt")

the operating system searches the free space list for a sufficiently large continuous region.

Example:

Free Blocks:
20–29

A file requiring 5 blocks can be allocated there.


Step 2: Allocation

OS reserves:

20
21
22
23
24

for the file.

Result:

report.txt → Blocks 20–24

Step 3: Store Metadata

Directory entry stores:

File Name = report.txt

Start Block = 20

Length = 5

Only two values are needed.


Step 4: File Access

Suppose we need:

Block 0

of the file.

OS calculates:

20 + 0 = 20

Need:

Block 3

OS calculates:

20 + 3 = 23

Need:

Block 4

OS calculates:

20 + 4 = 24

Formula

Physical Block = Start Block + Offset

Key Insight

No pointers, linked lists, or index structures are required.


5. Access Performance (Very Important)

One of the biggest reasons contiguous allocation was widely used is its excellent performance.

Sequential Access

Sequential reading means:

Block 10
↓
Block 11
↓
Block 12
↓
Block 13

Because blocks are physically adjacent:

  • Very little disk head movement

  • Fast transfer rate

  • Excellent throughput

Example

Streaming a movie:

Frame 1
Frame 2
Frame 3
Frame 4

Stored continuously.

Reading becomes extremely efficient.


Direct Access

Suppose we need:

Block 4

OS computes:

Start + 4

and directly accesses it.

No traversal required.

Access Time

O(1)

for locating a block.


Why It Is Fast

Because:

  • Blocks are adjacent

  • Minimal seek operations

  • Simple address calculations

  • No pointer following

Key Insight

Contiguous allocation provides the fastest access performance among traditional file allocation methods.


6. Advantages of Contiguous Allocation

6.1 Very Fast Access

Both sequential and direct access are extremely efficient.

Sequential Access

Excellent

because blocks are consecutive.

Direct Access

Excellent

because addresses are calculated directly.

Benefit

High performance.


6.2 Simple Implementation

Directory entry contains only:

Start Block
Length

No complicated structures are needed.

Benefit

Easy to implement and manage.


6.3 Low Metadata Overhead

Example:

Start = 100

Length = 20

Only two values are stored.

Benefit

Minimal storage overhead.


6.4 Efficient for Sequential Data

Ideal for:

  • Audio files

  • Video files

  • Read-only media

  • Backup archives

Benefit

Continuous reading becomes very efficient.


6.5 Predictable Performance

Since data is stored together:

  • Disk access patterns are predictable

  • Throughput remains high

Benefit

Reliable performance.


7. Major Problems (Most Important Section)

Although contiguous allocation is fast, it suffers from serious practical limitations.

These limitations are the main reason modern file systems rarely rely on pure contiguous allocation.


7.1 External Fragmentation

This is the biggest problem.

Scenario

Disk contains:

Free:
5–6

Free:
10–12

Free:
20–21

Total free blocks:

2 + 3 + 2 = 7

Suppose a new file requires:

4 blocks

Problem

No continuous region of 4 blocks exists.

Even though:

Total Free Space = 7

allocation fails.

Visualization

[XX][XX][F][F][XX][XX][F][F][F][XX][F][F]

Need:

[F][F][F][F]

but none exists.

Result

Allocation Failure.

Key Insight

Enough space exists, but it is scattered across the disk.

This is called External Fragmentation.


7.2 File Growth Problem

Files often grow dynamically.

Initial Situation

File A

10 11 12

Length:

3 Blocks

Now file expands.

Need:

Block 13

But:

Block 13

is already occupied.

Problem

File cannot continue growing.


Solution 1: Move Entire File

Move:

10 11 12

to another larger region.

Issue

Very expensive.

Large files may require copying gigabytes of data.


Solution 2: Preallocate Extra Space

Allocate:

10 11 12 13 14 15

even if file currently needs only:

10 11 12

Issue

Wasted disk space.


Key Insight

Contiguous allocation works poorly when file sizes are unpredictable.


7.3 Compaction Problem

To remove fragmentation:

OS may move files around.

Example

Before:

A A F F B B F C C F

After Compaction:

A A B B C C F F F F

All free space becomes one large block.

Benefit

Large allocations become possible.

Problem

Compaction requires:

  • Reading files

  • Moving files

  • Updating metadata

Result

High overhead.

Key Insight

Compaction is expensive and time-consuming.


7.4 Poor Utilization Over Time

As files are:

  • Created

  • Deleted

  • Expanded

disk becomes fragmented.

Performance gradually degrades.

Result

More allocation failures.


7.5 Not Suitable for Dynamic Systems

Modern operating systems handle:

  • Constant file creation

  • Frequent file growth

  • Variable workloads

Contiguous allocation struggles under such conditions.

Key Insight

The method works best when file sizes are fixed and known in advance.


8. Real-World Applications

Although pure contiguous allocation is uncommon today, it is still useful in specific situations.

CD-ROM Systems

Files are written once.

Never modified.

Benefit

No fragmentation issues.


DVD and Blu-ray Storage

Media files are stored sequentially.

Benefit

High-speed streaming.


Multimedia Systems

Video playback:

Frame 1
Frame 2
Frame 3
Frame 4

benefits from continuous storage.

Benefit

Smooth playback.


Embedded Systems

Some embedded devices use fixed-size files.

Benefit

Simple implementation.


Read-Only File Systems

Since files never grow:

File Size = Fixed

contiguous allocation becomes practical.

Benefit

Maximum performance.


9. Contiguous Allocation at a Glance

FeatureContiguous Allocation
Storage MethodConsecutive Blocks
Metadata RequiredStart Block + Length
Sequential AccessExcellent
Direct AccessExcellent
External FragmentationYes
Internal FragmentationNo
File Growth SupportPoor
Compaction NeededOften
ComplexityLow
PerformanceVery High
Modern UsageLimited

Final Insight

Contiguous Allocation stores a file in one continuous sequence of disk blocks, making both sequential and direct access extremely fast. The operating system only needs the starting block and file length to access any part of the file. While simple and highly efficient, it suffers from serious drawbacks such as external fragmentation and file growth difficulties. These limitations make it unsuitable for modern dynamic file systems, but it remains useful in read-only and multimedia-oriented storage environments where performance is more important than flexibility.