TheHingineer

  • Operating System


  • OS Part-1

  • OS Part-2

  • OS Part-3

  • OS Part-4

  • OS Part-5

  • Operations on Processes in Operating System 

    Ek process ek running program ka instance hota hai. Operating system different operations perform karta hai taaki processes ko efficiently manage kiya ja sake. Main operations hain:
    ✔ Process Creation (Naya process banana)
    ✔ Process Execution (Process ko run karna)
    ✔ Process Suspension (Process ko temporarily rokna)
    ✔ Process Termination (Process ko khatam karna)


    1. Process Creation 

    Jab bhi ek program execute hota hai, ek naya process create hota hai.
    Parent Process ek Child Process create karta hai, jo ek process hierarchy banata hai.

    Steps in Process Creation:

    1. Naye process ke liye memory allocate hoti hai.

    2. Program code ko memory me load kiya jata hai.

    3. Process ko ek unique Process ID (PID) diya jata hai.

    4. Process ka PCB (Process Control Block) initialize hota hai.

    5. Process ko execution ke liye schedule kiya jata hai.

    Example of Process Creation:

    • Jab aap Google Chrome open karte ho, ek naya process create hota hai.

    • Jab aap Chrome me naya tab open karte ho, ek child process create hota hai.

    Diagram: Process Creation

    Parent Process (PID 100)
      |
      |---> Child Process 1 (PID 101)
      |---> Child Process 2 (PID 102)

    👨‍💻 Linux me process create karne ka example (fork system call)

    #include <stdio.h>
    #include <unistd.h>


    int main() {
    int pid = fork(); // Ek naya child process create karega
    if (pid == 0) {
    printf("Ye child process hai\n");
    } else {
    printf("Ye parent process hai\n");
    }
    return 0;
    }


    2. Process Execution 

    Jab ek process create hota hai, toh wo different states se guzarta hai:

    • New: Naya process create hua.

    • Ready: Process execution ke liye wait kar raha hai.

    • Running: Process CPU par execute ho raha hai.

    • Waiting: Process kisi I/O ke wait me hai.

    • Terminated: Process execution complete ho gaya.

    Diagram: Process States

    New → Ready → Running → (Waiting) → Terminated

    Example:

    • Jab aap PUBG game open karte ho, toh wo Ready state me hota hai.

    • Jab aap game khel rahe hote ho, toh process Running state me hota hai.

    • Jab aap internet disconnect kar dete ho, toh process Waiting state me chala jata hai.


    3. Process Suspension 

    Kabhi kabhi ek process ko temporarily suspend kar diya jata hai taaki CPU aur memory efficiently manage ho sake.

    Types of Suspension:

    1. Suspend Ready: Process memory me hai but execute nahi ho raha.

    2. Suspend Waiting: Process kisi event ka wait kar raha hai, isliye memory se disk me move kiya jata hai.

    Example of Suspension:

    • YouTube video pause karna → Process suspend state me chala jata hai.

    • Mobile apps background me chalana → Process suspend ho jata hai taaki battery save ho.


    4. Process Termination 

    Jab ek process apna kaam complete kar leta hai ya kisi error ki wajah se band ho jata hai, toh wo terminate ho jata hai.

    Reasons for Process Termination:

    ✔ Normal Exit: Process successfully execute ho gaya.
    ✔ Error Exit: Process me koi error aa gaya (e.g., divide by zero).
    ✔ Killed by OS: Operating system ne process ko forcibly terminate kar diya.

    Example:

    • Jab aap Microsoft Word band karte ho, toh uska process terminate ho jata hai.

    • Agar ek application hang ho jaye, toh Task Manager se usko “End Task” karke terminate kiya jata hai.

    👨‍💻 Linux Command to Kill a Process:

    kill -9 PID  (Forcefully process ko terminate karega)


    Conclusion

    • Operating System processes ko manage karne ke liye different operations perform karta hai.

    • Process Creation, Execution, Suspension, aur Termination ek process ke lifecycle ka part hain.

    • Process management CPU aur memory utilization ke liye bahut zaroori hai.

    Scroll to Top