File Allocation Techniques in Operating System: Contiguous, Linked and Indexed

Explain Different File Allocation Techniques

(7 Marks Answer – Operating System)

Sabse pehle Hindi mein samjho 😊

File Allocation Techniques ka matlab hai hard disk mein files ko store karne ke liye disk blocks ko allocate karne ka tarika.

Operating System mein 3 main File Allocation Techniques hoti hain:

  1. Contiguous Allocation
  2. Linked Allocation
  3. Indexed Allocation

1. Contiguous Allocation

Definition: In this technique, ek file ke sabhi blocks disk mein continuously (ek ke baad ek) store hote hain.

Example:

Disk Blocks:

+----+----+----+----+----+----+
| 1  | 2  | 3  | 4  | 5  | 6  |
+----+----+----+----+----+----+
       File A
       [ 2 ][ 3 ][ 4 ]

Yahan File A ke blocks 2, 3 aur 4 continuously store hain.

Advantages:

  • File access fast hota hai.
  • Sequential aur direct access dono possible hain.
  • Implementation simple hai.

Disadvantages:

  • External fragmentation ho sakti hai.
  • File ka size badhana difficult hota hai.

2. Linked Allocation

Definition: In this technique, file ke blocks disk mein alag-alag locations par store hote hain aur har block mein next block ka pointer hota hai.

Example:

+--------+     +--------+     +--------+
| Block 2| --> | Block 5| --> | Block 8|
+--------+     +--------+     +--------+
                                    |
                                    v
                                  NULL

Yahan File ke blocks 2, 5 aur 8 linked hain.

Advantages:

  • External fragmentation nahi hoti.
  • File ka size easily increase kar sakte hain.
  • Free disk blocks ka use kar sakte hain.

Disadvantages:

  • Direct access difficult hota hai.
  • Pointer store karne ke liye extra space chahiye.
  • Pointer kharab hone par file ke remaining blocks tak pahunchna difficult ho sakta hai.

3. Indexed Allocation

Definition: In this technique, har file ke liye ek separate index block hota hai, jisme file ke sabhi data blocks ke addresses store hote hain.

Example:

Index Block
+-----------+
| Block 2   |
| Block 5   |
| Block 8   |
+-----------+
   |    |    |
   v    v    v
+---+ +---+ +---+
| 2 | | 5 | | 8 |
+---+ +---+ +---+
 Data Blocks

Yahan index block file ke data blocks ke addresses store karta hai.

Advantages:

  • Direct aur sequential access possible hai.
  • External fragmentation nahi hoti.
  • File ka size badhana relatively easy hota hai.

Disadvantages:

  • Index block ke liye extra memory space chahiye.
  • Chhoti files ke liye index block ki space waste ho sakti hai.
  • Bahut badi files ke liye multiple-level indexing ki zarurat ho sakti hai.

Difference Between Three Allocation Techniques

FeatureContiguousLinkedIndexed
StorageContinuous blocksScattered blocks linked togetherScattered blocks with an index
AccessFast direct accessDirect access difficultDirect access possible
External FragmentationYesNoNo
Extra SpaceNo pointer overheadPointers requiredIndex block required
File GrowthDifficultEasyRelatively easy

Conclusion

Operating System mein file allocation ki teen main techniques hain: Contiguous, Linked aur Indexed Allocation. Contiguous allocation fast hoti hai, Linked allocation file growth ko easy banati hai, aur Indexed allocation direct access provide karti hai.

Exam Trick:

  • Contiguous = Blocks ek saath
  • Linked = Blocks pointers se connected
  • Indexed = Addresses index block mein