TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • File Concepts aur Access Methods in Operating System

    1. File Concepts

    File Kya Hota Hai?

    Ek file data ka collection hota hai jo kisi storage device (HDD, SSD, USB, etc.) par store kiya jata hai. Yeh data ko store karne aur retrieve karne ka basic unit hai jo Operating System ke dwara manage hota hai.

    Types of Files

    1. 1. Text Files – Jo human-readable text contain karti hain (e.g., .txt, .html).

    2. 2. Binary Files – Jo machine-readable binary format me store hoti hain (e.g., .exe, .jpg, .mp3).

    3. 3. System Files – OS ke boot aur operations ke liye zaroori (e.g., .dll, .sys).

    4. 4. Database Files – Structured data store karti hain (e.g., .db, .mdb).

    File Attributes

    Har file ke kuch properties (metadata) hoti hain:

    • Name – Unique name jo file identify karta hai.

    • Type – File ka format (.txt, .png, .pdf).

    • Size – File kitni space occupy karti hai.

    • Location – File system me kaha stored hai.

    • Protection – Read, write, execute permissions.

    • Creation Time – Kab file create hui thi.

    • Last Access Time – Last kab file open ya modify hui thi.

    File Structure

    Files ke andar ka data structure alag-alag ho sakta hai:

    1. Byte Sequence – Simple byte storage, jaise Unix systems me hota hai.

    2. Record Sequence – Fixed-size records hote hain, jaise databases me.

    3. Tree Structure – Hierarchical file system jisme folders aur subfolders hote hain.


    2. File Access Methods

    File access methods define karte hain ki data file se kaise read/write hoga.

    1. Sequential Access

    • Sabse common method hai.

    • File ke records ek sequence me read hote hain, backward movement mushkil hota hai.

    • Agar modification karna ho toh poori file dobara likhni pad sakti hai.

    Example:

    • Text file line by line read karna.

    • Video ya audio file sequentially play karna.

    Diagram:

    | Record 1 || Record 2 || Record 3 || Record 4 |
    • Data sequence me access hota hai, Record 1 ke baad Record 2 read hoga.

    Advantages:

    ✅ Simple aur easy to implement.
    ✅ Large data read karne ke liye best hai (e.g., logs).

    Disadvantages:

    ❌ Direct access possible nahi hota.
    ❌ Agar ek specific record chahiye toh pura file scan karna padega.


    2. Direct (Random) Access

    • File records me divided hoti hai, aur koi bhi record directly access kiya ja sakta hai.

    • Best for databases jisme specific record jaldi retrieve karna hota hai.

    Example:

    • Student ki record database me search karna.

    • PDF ya eBook me kisi bhi page par directly jump karna.

    Diagram:

    |Record 1| |Record 2| |Record 3| |Record 4|
       ↑             ↑        ↑
    Kisi bhi position se direct access
     

    Advantages:

    ✅ Fast access, kisi bhi record ko directly fetch kar sakte hain.
    ✅ Unnecessary data process nahi hota.

    Disadvantages:

    ❌ Complex implementation hoti hai.
    ❌ Indexing ke liye extra memory chahiye hoti hai.


    3. Indexed Sequential Access

    • Sequential aur Direct Access ka combination hai.

    • Index Table maintain ki jati hai jo file ke specific blocks ko point karti hai.

    • Jab large files hoti hain aur fast searching chahiye tab yeh best hota hai.

    Example:

    • Phonebook search – Pehle index ke through page find karo, phir sequentially names check karo.

    • Database search with indexed fields – Jaldi data retrieve karna.

    Diagram:

    Index Table → Points to → File Blocks
    -------------------------------------
    | Index 1 | → | Block A |
    | Index 2 | → | Block B |
    | Index 3 | → | Block C |
    -------------------------------------

    Advantages:

    ✅ Pure sequential access se fast searching hoti hai.
    ✅ Direct access jitni memory use nahi hoti.

    Disadvantages:

    ❌ Index table maintain karna mushkil hota hai.
    ❌ Direct access jitna fast nahi hota.


    Comparison Table

    Access MethodKaise Kaam Karta HaiExample Use CaseSpeedBest For
    Sequential AccessData order me read hota haiAudio/Video StreamingSlowLarge Continuous Files
    Direct AccessKisi bhi part me jump kar sakte hainDatabasesFastRandom File Searching
    Indexed Sequential AccessIndex ke through fast lookup hota haiPhonebook searchMediumLarge structured data

    Conclusion

    File concepts aur access methods ko samajhna important hai kyunki ye efficient data storage aur retrieval ke liye zaroori hote hain. Har access method ki apni advantages aur disadvantages hoti hain, aur use case ke hisaab se best method select kiya jata hai.

    Scroll to Top