70 likes | 98 Views
CPU Scheduling ( Basic Concepts). CPU scheduling Which process will get the CPU when it is available? This is decided by the O.S. and is called CPU scheduling. The part of the O.S. which performs scheduling is called Scheduler.
E N D
CPU Scheduling ( Basic Concepts) CPU scheduling • Which process will get the CPU when it is available? This is decided by the O.S. and is called CPU scheduling. • The part of the O.S. which performs scheduling is called Scheduler. • The scheduler selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. • The objective is to maximize CPU utilization in multiprogramming. CPU–I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait.
Alternating Sequence of CPU And I/O Bursts execute CPU Burst I/O Wait I/O Burst execute CPU Burst I/O Wait I/O Burst
Optimization Criteria • Max CPU utilization • Max throughput • Min turnaround time • Min waiting time • Min response time
Scheduling Algorithms • First-Come, First-Served (FCFS) Scheduling ( non preemptive) • This algorithm favors: • Longer jobs against the shorter jobs ( W/B is less for longer jobs) • CPU bound processes against I/O bound processes
Shortest Job first Scheduling Now the jobs appear as: • Now: • Longer jobs are not favored against the shorter jobs ( W/B is less for longer jobs) • A longer job can face starvation • CPU bound processes are still favored against I/O bound processes
Round-Robin (RR) Scheduling (Preemptive) • A queue of ready processes is maintained • A time quantum q (10-100 msec) is allocated to each process. • I f a process does not finish in the allocated time it goes back to the end of the queue (circular queue) • If there are n processes, each process gets turn at most after (n-1) q units. Gannt Chart for q = 20 msec CPU CPU • Performance • If q is large, this scheme degenerates to FCFS • If q is small, more context switches (each process finishes in more turns)