Process Scheduling

Introduction

मान लो system में 10 processes ready हैं।
लेकिन CPU एक समय में सिर्फ 1 process ही चला सकता है।

अब सवाल:
कौन सा process पहले चलेगा?
कौन wait करेगा?
किसे कितना time मिलेगा?

इसी decision-making process को कहते हैं:
Process Scheduling

Process Scheduling क्या होता है

Process Scheduling वह mechanism है जिसमें Operating System यह decide करता है कि कौन सा process CPU use करेगा और कब करेगा।

Real Life Analogy

मान लो bank में line लगी है:

  • सभी लोग = processes
  • Counter = CPU
  • Manager = OS scheduler

Manager decide करता है कि किसे पहले बुलाना है

Basic Flow (System में क्या होता है)

  • Processes Ready Queue में होते हैं
  • Scheduler उनमें से एक process select करता है
  • Dispatcher CPU allocate करता है
  • Process execution शुरू होता है

Schedulers क्या होता है :

OS में different types के schedulers होते हैं:

1. Long-Term Scheduler (Job Scheduler)

  • Decide करता है कौन से process system में आएंगे
  • New → Ready state

Control करता है system load

2. Short-Term Scheduler (CPU Scheduler)

  • Ready queue से process select करता है
  • Ready → Running

यह सबसे fast scheduler होता है

3. Medium-Term Scheduler

  • Process को temporarily remove (suspend) करता है
  • Memory management में help करता है

Dispatcher क्या करता है

Dispatcher वह component है जो:

  • Selected process को CPU देता है
  • Context switching करता है
  • User mode ↔ Kernel mode switch करता है

Context Switching (Core Concept)

जब CPU एक process से दूसरे process पर जाता है:

  • Current process का data save
  • Next process का data load

Time लगता है → overhead

Scheduling Queues

System में अलग-अलग queues होती हैं:

  • Job Queue → सभी processes
  • Ready Queue → CPU wait करने वाले
  • Device Queue → I/O wait

Types of Scheduling

1. Preemptive Scheduling

  • Process को बीच में रोका जा सकता है
  • CPU दूसरे process को दे दिया जाता है

Example: Round Robin

2. Non-Preemptive Scheduling

  • Process complete होने तक CPU रखता है

Example: FCFS

Example

मान लो:

  • P1, P2, P3 ready queue में हैं

Process flow:

  • Scheduler P1 को select करता है
  • P1 running
  • P1 I/O wait में चला गया
  • Scheduler P2 को CPU देता है

यही scheduling है

Why Process Scheduling Important

  • CPU idle नहीं रहता
  • System performance improve होता है
  • Fairness maintain होती है
  • Multi-tasking possible होता है

Key Points

  • Scheduler types जरूर याद करो
  • Dispatcher + Context Switching important
  • Preemptive vs Non-preemptive पूछता है

Conclusion

Process Scheduling Operating System का heart है, जो system के सभी processes को efficiently manage करता है और CPU utilization को maximize करता है।

यह तय करता है कि system smooth और fast चले।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top