Beruflich Dokumente
Kultur Dokumente
Presented by:
CPU Scheduling ?
In the CPU scheduling the Operating System decide that which process should be executed first on the basis of different algorithms.
The objective of multiprogramming is to have some process running at all times to maximize CPU utilization.
Almost all computer resources are scheduled before used.
an I/O burst, followed by another CPU burst and so on. The last CPU burst will end will a system request to terminate the execution.
The
CPU burst durations vary from process to process and computer to computer.
An I/O bound program has many very short CPU
bursts. A CPU bound program might have a few very long CPU bursts.
CPU Scheduler
Whenever, the CPU becomes idle, the OS must select one of the processes in the ready-queue to be executed. The selection process is carried out the CPU scheduler. The CPU scheduler select a process from the ready queue and allocates the CPU to that process.
Types of Scheduling
There are four types of scheduling that an OS has to perform:
The long term scheduling determines which programs are admitted to the system for processing. It controls the level of multiprogramming. Long term scheduling is performed when a new process is created. The criteria used for long-term scheduling may include first-come-first serve, priority, expected execution time, and I/O requirements.
Medium-Term Scheduling
The medium-term scheduling is a part of swapping function. This is a decision to add a process to those that are at least partially in main memory and therefore available for execution. The swapping- In decision is made on the need to manage the degree of multiprogramming and the memory requirements of the swapped-out process.
Short-Term Scheduling
A decision of which ready process to execute
I/O Scheduling
The decision as to which processs pending I/O requests shall be handled by the available I/O device is made in I/O scheduling.
Scheduling Criteria
CPU utilization : keep the CPU as busy as possible (from 0% to 100%) Throughput : # of processes that complete their execution per time unit Turnaround time : Amount of time to execute a particular Process Waiting time : Amount of time a process has been waiting in the ready queue Response time: Amount of time it takes from when a request was submitted until the first response is produced
Optimization Criteria
Max CPU utilization Max throughput Min turnaround time Min waiting time Min Response time
Scheduling Algorithms
CPU scheduling deals with the problem of deciding which of the processes in the ready queue is to be allocated the CPU. There are many different CPU scheduling algorithms, which we will discuss now.
Scheduling Algorithms
First-Come First-Served (FCFS) Scheduling Shortest-Job First Scheduling (SJF) Priority Scheduling Round-Robin Scheduling
Long average and worst-case waiting times Poor dynamic behavior (convoy effect short process behind long process)
Example:
Process P1 Burst Time 24
P2
P3
3
3
Suppose that the processes arrive in the order P1, P2,P3.The Gantt Chart for the schedule is:
P1 24 P2 27 P3 30
Cont
Suppose that the processes arrive in the order P2, P3, P1. The Gantt chart for the schedule is:
P2 0 3 P3 6 P1 30
Cont
If a new process arrives with CPU burst length less than remaining time of current executing process, preempt the currently executing process and allocate the CPU to the new process.
Cont
Advantages:
Minimizes
Problems:
Priority Scheduling
In priority scheduling, a priority (an integer) is associated with each process. Priorities can be assigned either externally or internally. The CPU is allocated to the process with the highest priority (smallest integer means highest priority).
Problem Starvation or indefinite blocking low priority processes may never execute. Solution
Aging as time progresses increase the
Round-Robin Scheduling
Each process gets a small unit of CPU time (called time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.
CPU scheduler goes around the ready queue, allocating the CPU to each process for a time interval of 1 time quantum.