Unit 3: CPU Scheduling
1. CPU Scheduling Basics
       CPU Scheduling decides which process gets the CPU when mul ple processes are in the
        ready queue.
       Scheduler selects one of the ready processes to execute.
       Dispatcher gives control of the CPU to the selected process.
2. Types of Schedulers
       Long-term Scheduler – Controls degree of mul programming.
       Short-term Scheduler – Selects a process from the ready queue.
       Medium-term Scheduler – Suspends/resumes processes.
3. Scheduling Criteria
       CPU U liza on: Keep CPU as busy as possible.
       Throughput: No. of processes completed per me unit.
       Turnaround Time: Time from submission to comple on.
       Wai ng Time: Time spent in the ready queue.
       Response Time: Time from request submission to the first response.
       Fairness: Equal opportunity to all processes.
4. Scheduling Algorithms
a) First-Come, First-Served (FCFS)
       Non-preemp ve
       Processes served in order of arrival.
       Simple but can lead to convoy effect.
b) Shortest Job Next (SJN) / Shortest Job First (SJF)
       Non-preemp ve
       Process with the shortest burst me is scheduled first.
       Op mal in terms of average wai ng me.
       Can cause starva on.
c) Shortest Remaining Time First (SRTF)
       Preemp ve version of SJF.
       Always selects process with the shortest remaining me.
d) Round Robin (RR)
       Preemp ve
       Each process gets a fixed me quantum.
       Suitable for me-sharing systems.
e) Priority Scheduling
       Each process has a priority. The CPU is assigned to the highest-priority process.
       Can be preemp ve or non-preemp ve.
       Low priority processes may starve.
       Aging technique avoids starva on.
f) Mul level Queue Scheduling
       Separate queues for different types of processes (e.g., interac ve, batch).
       Each queue has its own scheduling algorithm.
       Fixed priority or round-robin among queues.
g) Mul level Feedback Queue Scheduling
       A process can move between queues.