TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Process in Operating System – Concept & Process Control Block

    1. Process kya hota hai?

    👉 Process ek running program hota hai. Jab koi program execute hone lagta hai, to wo ek process ban jata hai.

    Example:

    🔹 Jab aap MS Word open karte ho, to wo ek process ban jata hai jo system pe run ho raha hota hai.
    🔹 Agar aap do alag-alag Word documents open karte ho, to dono alag processes hongi, chahe program same ho.

    Process ke Components:

    1️⃣ Program Code – Jisme actual instructions hoti hain.
    2️⃣ Data – Input aur output values jo process use karega.
    3️⃣ Process Stack – Temporary data jaise function calls aur local variables store karta hai.
    4️⃣ Heap – Dynamically allocated memory rakhta hai.
    5️⃣ Registers – CPU ke registers jo process ki information rakhte hain.
    6️⃣ Program Counter (PC) – Next instruction ka address store karta hai jo execute hone wala hai.


    2. Process States in OS (Process ki Different States)

    Ek process apni execution ke dauraan alag-alag states se guzar sakta hai.

    🔹 Process Life Cycle (Diagram)

          +-----+
    ----> | New | (Naya process bana)
          +-----+
             |
             V
          +-------+
    ----> | Ready | (CPU milne ka wait kar raha hai)
          +-------+
             |
             V
          +---------+
    ----> | Running | (CPU pe execute ho raha hai)
          +---------+
               |
            /     \
           V       V
    +-----------+ +----------+
    | Blocked   | |Terminated|
    | (Wait kar | | (Process |
    | raha hai) | | Khatam)  |
    +-----------+ +----------+

    🔹 Process ki States ka Explanation:

    ✅ New – Jab ek process create hota hai, par abhi execute nahi hua hai.
    ✅ Ready – Process memory me load ho chuka hai aur CPU milne ka wait kar raha hai.
    ✅ Running – Process CPU pe execute ho raha hai.
    ✅ Blocked – Process kisi I/O operation (jaise user input ya printing) ke liye wait kar raha hai.
    ✅ Terminated – Process apna kaam complete kar chuka hai aur system se remove ho raha hai.


    3. Process Control Block (PCB) kya hota hai?

    🔹 PCB ek data structure hai jo har process ki information store karta hai.
    🔹 Jab bhi ek process create hota hai, OS uske liye ek PCB allocate karta hai.

    🔹 PCB me kya-kya hota hai?

    PCB Field Description
    Process ID Process ka unique number
    Process State Process kis state me hai (Ready, Running, Blocked, etc.)
    Program Counter Next instruction ka address
    CPU Registers CPU ke registers jo process ki information rakhte hain
    Memory Management Info Process ke memory allocation ki details
    Accounting Information CPU usage, execution time, etc.
    I/O Status Information Kaunse I/O devices use ho rahe hain

    🔹 PCB ka Example (Process Table Entry):

    Process ID State PC CPU Registers Memory Address I/O Info
    101 Ready 205 0xA1F4 Keyboard
    102 Running 412 0xB2D5 Printer
    103 Blocked 310 0xC3E6 Hard Disk

    🔹 PCB kaha store hota hai?
    PCB OS ke kernel space me store hota hai, aur OS ise process management ke liye use karta hai.


    4. Context Switching kya hota hai?

    👉 Context Switching tab hota hai jab CPU ek process se dusre process pe switch karta hai.

    🔹 Example:

    1️⃣ Process A execute ho raha tha, par ek interrupt aagaya.
    2️⃣ OS Process A ka PCB save karta hai.
    3️⃣ OS Process B ka PCB load karta hai aur usko CPU control de deta hai.
    4️⃣ Jab Process A wapas execute hoga, to OS uska PCB wapas load karega.

    ✅ Multitasking ko support karne ke liye Context Switching zaroori hota hai!


    5. Summary (Short Notes)

    ✔ Process ek running program hota hai.
    ✔ Process ki states – New, Ready, Running, Blocked, Terminated.
    ✔ PCB ek table hai jo har process ki details rakhta hai.
    ✔ Context Switching se CPU ek process se dusre process pe switch karta hai.

    Scroll to Top