Sunteți pe pagina 1din 13

Operating System

U2M3 Lecture 4 Process Management Scheduling Algorithms

Objectives
Explain the purpose of scheduling List scheduling Criteria Discuss types of scheduling algorithms

Scheduling Algorithm
The scheduling algorithm is a part of the operating system that
decides which processes should be running on the CPU (in what order) and for how long. Maximizes CPU utilization keep the CPU as busy as possible

Context Switching
A context switch (a process switch / a task switch) is the switching of the CPU from one process to another

Scheduling Concerns / Criteria


Throughput Number 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.

Non-pre-emptive and pre-emptive Scheduling algorithms


A non-pre-emptive (Atomic) algorithm runs a process to completion once it has the CPU. A pre-emptive algorithm gives each process a time slice (Quantum) and then switching the CPU's attention among the processes. (process switching /context switching) Each process is allowed to execute for no longer than one time slice so a job may be require many time slices.

Scheduling Algorithms
First come first served (FCFS) Shortest job first;

Round Robin ;

First Come First Served (FCFS) non-pre-emptive


Processes are dispatched according to their arrival time on the ready queue. Being a nonpre-emptive discipline, once a process has a CPU, it runs to completion. The FCFS scheduling not optimal
long jobs make short jobs wait and unimportant jobs make important jobs wait.

Shortest Job First (SJF) non-pre-emptive


Shortest-Job-First (SJF) is an algorithm in which waiting job (or process) with the smallest estimated run-time-to-completion is run next. The SJF scheduling is especially appropriate for batch jobs for which the run times are known in advance. SJF gives the minimum average time for a given set of processes, it is more optimal than FCFS. The problem with SJF scheme is that it requires precise knowledge of how long a job or process will run,
not usually available. rely on user

Shortest Remaining Time First (SRTF) pre-emptive


Shortest-Remaining Time First (SRTF) algorithm is a pre-emptive version of SJF. In which if a new process arrives with CPU burst length less than the remaining time of current executing process, the current process is pre-empted. The CPU switches to execute the new process.

Round Robin pre-emptive


This scheduling policy gives each process a slice of time (i.e., one quantum) before being pre-empted. As each process becomes ready, it joins the ready queue. A clock interrupt is generated at periodic intervals.

Round Robin pre-emptive


When the interrupt occurs, the currently running process is pre-empted, and the oldest process in the ready queue is selected to run next. The time interval between each interrupt may vary. Click to see animation

Overview
CPU Turnaround Response Scheduling algorithm Throughput time Overhead time First In First Out Shortest Job First Round-robin
Low Medium High Low High Medium High Medium Medium Low Medium High

S-ar putea să vă placă și