TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  •  Free Space Management & File Allocation Methods in Operating System

    1. Free Space Management

    Jab files delete hoti hain ya naye files store kiye jaane hote hain, toh Operating System ko ye track karna hota hai ki kaunsa disk space free hai. Isi process ko Free Space Management kaha jata hai.

    Free Space Management Kyu Zaroori Hai?

    • Storage space ko efficiently use karne ke liye.

    • File allocation ko fast banane ke liye.

    • File deletion ke baad space reuse karne ke liye.

    Free Space Management Ke Methods

    1. Bit Vector (Bitmap)

    • Ek array of bits (0s & 1s) use kiya jata hai free aur occupied blocks ko track karne ke liye.

    • 0 → Block free hai.

    • 1 → Block occupied hai.

    Example:

    | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 1 |

    Yahan block 3, 4, 6, aur 7 free hain.

    Advantages:

    ✅ Simple aur memory-efficient.

    Disadvantages:

    ❌ Free block find karna slow ho sakta hai.


    2. Linked List

    • Free blocks ko ek linked list ke form me store kiya jata hai.

    • Har free block me next free block ka address hota hai.

    Example:

    [Free Block 1] → [Free Block 2] → [Free Block 3] → NULL

    Advantages:

    ✅ No memory wastage.

    Disadvantages:

    ❌ Searching time-consuming hota hai.


    3. Grouping

    • Ek free block ka address pehle block me store hota hai, jo naye free blocks ko point karta hai.

    Example:

    [Block 1] → (Blocks 2, 3, 4 ke addresses store hain)

    [Block 2] → (Blocks 5, 6, 7 ke addresses store hain)

    Advantages:

    ✅ Linked list se faster hai.

    Disadvantages:

    ❌ Extra memory chahiye addresses store karne ke liye.


    4. Counting

    • Ek saath free blocks ko ek entry ke form me store kiya jata hai (start block, count).

    Example:

    (100, 5) → Blocks 100 se 104 tak free hain.
    (200, 3) → Blocks 200 se 202 tak free hain.

    Advantages:

    ✅ Storage space bachta hai.

    Disadvantages:

    ❌ Sirf contiguous (ek saath wale) blocks ke liye best hai.


    2. File Allocation Methods

    File allocation ka matlab hai disk space ka allocation kis tarike se kiya jaye taaki files efficiently store ho sakein.

    1. Contiguous Allocation

    • File continuous disk blocks me store hoti hai.

    Example:

    File A: | Block 10 | Block 11 | Block 12 | Block 13 |
    File B: | Block 20 | Block 21 | Block 22 |

    Advantages:

    ✅ Fast access kyunki data ek saath hota hai.

    Disadvantages:

    ❌ External fragmentation ho sakti hai.
    ❌ File size increase karna mushkil hota hai.


    2. Linked Allocation

    • File scattered disk blocks me store hoti hai, aur har block me next block ka pointer hota hai.

    Example:

    File A: Block 5Block 19Block 25Block 40NULL

    Advantages:

    ✅ Flexible size, file badh sakti hai.

    Disadvantages:

    ❌ Slow access, kyunki har block pe jump karna padta hai.


    3. Indexed Allocation

    • Ek index block maintain kiya jata hai jo file ke blocks ke addresses store karta hai.

    Example:

    Index Block[Block 5, Block 19, Block 25, Block 40]

    Advantages:

    ✅ Fast access, direct indexing ke wajah se.

    Disadvantages:

    ❌ Extra memory chahiye index block ke liye.


    Comparison of File Allocation Methods

    Method Kaise Kaam Karta Hai Advantages Disadvantages
    Contiguous Allocation Files ek saath blocks me store hoti hain Fast access, Simple External fragmentation
    Linked Allocation Files ko scattered blocks me store karte hain Flexible size Slow access
    Indexed Allocation Separate index block use hota hai Fast access Extra memory required

    Conclusion

    Free Space Management aur File Allocation Methods Operating System ke disk management ka important part hain. Har method ka use case aur efficiency alag hoti hai, jo system requirement aur file storage ke size pe depend karta hai.

    Scroll to Top