OS moves thread from Run State to Ready State:
In preemptive scheduling, the operating system can interrupt a running thread and move it back to the ready state to allow another thread to execute.
Preemption is needed to guarantee fairness:
Preemption ensures that no single thread monopolizes the CPU. By interrupting long-running threads, the OS can allocate CPU time to other threads, maintaining fairness in resource distribution.
Preemption needs interrupts:
Preemption relies on hardware interrupts to signal the OS to stop the current thread and switch to another. These interrupts can be triggered by timers, external events, or system calls.
Preemption helps meet deadlines:
In real-time systems, preemption allows high-priority tasks to interrupt lower-priority ones, ensuring critical tasks meet their deadlines and system requirements.
Throughput:
Measures the number of tasks completed per unit time. Higher throughput indicates better performance.
Turnaround Time:
The total time taken for a task to complete, from submission to completion. Lower turnaround time is desirable.
Response Time:
The time from when a request is made to when the system starts responding. Important for interactive systems.
CPU Utilization:
The percentage of CPU cycles actively used for processing tasks. Higher utilization means better resource usage.
Wait Time:
The time a task spends waiting in the ready queue before execution. Lower wait time improves system responsiveness.
Each algorithm has trade-offs and is suited for specific types of systems (e.g., real-time, batch processing, or interactive systems). check youtube better understanding each algo
The time quantum in Round Robin (RR) scheduling significantly impacts performance. If the quantum is extremely large, RR behaves like First-Come, First-Served (FCFS). If the quantum is extremely small, RR achieves true processor sharing but increases overhead due to frequent context switching. Smaller quanta lead to more time spent on context switching, reducing efficiency. To optimize RR, the time quantum must be much greater than the context-switch time to balance responsiveness and overhead.