cpu scheduling 6th sem 2010 ppt

25
Project Guide: Project Members: Ms. Priyanka Paul Abhishek Bajpai Devanshu Gupta Harshit Srivastava Kushagra Chawla

Upload: harshit-srivastava

Post on 05-Apr-2015

1.843 views

Category:

Documents


1 download

DESCRIPTION

Project Guide: Ms. Priyanka PaulProject Members: Abhishek Bajpai Devanshu Gupta Harshit Srivastava Kushagra ChawlaCPU SchedulingBasis of multiprogramming operating systems which organizes jobs so that CPU always has one to execute Refers to the way processes are assigned to run on the available CPUs By switching CPU among processes, OS can make computer more productive

TRANSCRIPT

Page 1: Cpu Scheduling 6th Sem 2010 PPT

Project Guide: Project Members:

Ms. Priyanka Paul Abhishek Bajpai

Devanshu GuptaHarshit SrivastavaKushagra Chawla

Page 2: Cpu Scheduling 6th Sem 2010 PPT

CPU Scheduling› Basis of multiprogramming operating systems

which organizes jobs so that CPU always has one to execute

› Refers to the way processes are assigned to run on the available CPUs

› By switching CPU among processes, OS can make computer more productive

Page 3: Cpu Scheduling 6th Sem 2010 PPT

Basic Concepts› Maximum CPU utilization obtained with

multiprogramming• Objective is to have some processes running at all

times• Every time one process has to wait, another process

takes over the use of CPU

› CPU–I/O Burst Cycle• Process execution consists of a cycle of CPU

execution and I/O wait

› CPU burst distribution

Page 4: Cpu Scheduling 6th Sem 2010 PPT

CPU-I/O Burst Cycle

Alternating sequence of CPU and I/O bursts

Page 5: Cpu Scheduling 6th Sem 2010 PPT

Histogram of CPU-burst Durations› Curve is exponential or hyper exponential, with

large number of short CPU bursts and small number of large CPU bursts

Page 6: Cpu Scheduling 6th Sem 2010 PPT

CPU Scheduler› Selects a process from the processes in the ready

queue or memory that are ready to execute and allocates the CPU to that process

› also known as; short-term scheduler

Page 7: Cpu Scheduling 6th Sem 2010 PPT

Preemptive Scheduling› CPU scheduling decisions may take place under

following circumstances:• When a process switches from running state to waiting

state• When a process switches from running state to ready state• When a process switches from waiting state to ready state• When a process terminates

› When scheduling take place only under conditions 1 & 4, the scheduling scheme is nonpreemptive; otherwise it is preemptive

› Preemptive scheduling provides the choice for selecting a new process for execution

Page 8: Cpu Scheduling 6th Sem 2010 PPT

Scheduling Criteria› CPU utilization : keep the CPU as busy as

possible

› Throughput: no. of processes completed per time unit

› Turnaround time : time taken to execute a process from submission to completion

› Waiting time : time that a process spends waiting in ready queue

› Response time : time from submission of a request until first

response is produced

Page 9: Cpu Scheduling 6th Sem 2010 PPT

Optimization Criteria› Max CPU utilization

› Max Throughput

› Min Turnaround time

› Min Waiting time

› Min Response time

Page 10: Cpu Scheduling 6th Sem 2010 PPT

Scheduling Algorithms› First-Come, First-Served Scheduling (FCFS)

› Shortest-Job-First Scheduling (SJF)

› Priority Scheduling

› Round-Robin Scheduling

Page 11: Cpu Scheduling 6th Sem 2010 PPT

First-Come, First-Served Scheduling› Runs jobs in the order they arrive

› Assume that processes arrive in the order: P1, P2, P3

› The Gantt Chart for the schedule is:

› Waiting time for P1= 0; P2= 24; P3 = 27

› Average waiting time: (0 + 24 + 27) / 3 = 17

P1 P2 P3

24 27 300

Process Burst Time

P1 24

P2 3

P3 3

Page 12: Cpu Scheduling 6th Sem 2010 PPT

› Assume that processes arrive in the order: P2, P3, P1

› The Gantt chart for the schedule is:

› Waiting time for P1 = 6; P2 = 0; P3 = 3

› Average waiting time: (6 + 0 + 3) / 3 = 3

› Much better than previous case

P1P3P2

63 300

Page 13: Cpu Scheduling 6th Sem 2010 PPT

Shortest-Job-First Scheduling› Associates with each process the length of its

next CPU burst

› Process having smallest next CPU burst is assigned to the available CPU

› Two schemes: • Nonpreemptive- once CPU is given to the process, it

can’t be preempted until completes its CPU burst• Preemptive- if a new process arrives with CPU burst

length less than remaining time of current executing process then preempt

› SJF is optimal• gives minimum average waiting time

Page 14: Cpu Scheduling 6th Sem 2010 PPT

Example of Nonpreemptive SJF

› The Gantt Chart for the schedule is:

› Average waiting time = (0 + 6 + 3 + 7) / 4 = 4

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

P1 P3 P2

73 160

P4

8 12

Page 15: Cpu Scheduling 6th Sem 2010 PPT

Example of Preemptive SJF (SRTF)

› The Gantt Chart for the schedule is:

› Average waiting time = (9 + 1 + 0 +2) / 4 = 3

Process Arrival Time Burst Time

P1 0 7

P2 2 4

P3 4 1

P4 5 4

P1 P3P2

42 110

P4

5 7

P2 P1

16

Page 16: Cpu Scheduling 6th Sem 2010 PPT

Priority Scheduling› A priority is associated with each process

› CPU is allocated to the process having highest priority

› Equal priority processes are scheduled in FCFS order

› SJF algorithm is a priority algorithm where priority is the inverse of the next CPU burst

› Problem• Starvation - low priority processes may never execute

› Solution• Aging - as time progresses, increase the priority of the

process

Page 17: Cpu Scheduling 6th Sem 2010 PPT

Example of Priority Scheduling

› The Gantt Chart for the schedule is:

› Average waiting time = (6 + 0 + 16 + 18 + 1) / 5 = 8.2

Process Burst Time Priority

P1 10 3

P2 1 1

P3 2 4

P4 1 5

P5 5 2

P2

P5 P1 P3 P40 6 16 19181

Page 18: Cpu Scheduling 6th Sem 2010 PPT

Round-Robin Scheduling› Designed for time sharing systems

› Similar to FCFS scheduling with added preemption

› A small unit of time called time quantum/time slice is defined (10-100 ms)

› After time quantum has elapsed, the process is preempted and added to the tail of the ready queue

› New processes are added to the tail of the ready queue

Page 19: Cpu Scheduling 6th Sem 2010 PPT

Example of Round-Robin Scheduling

› Time Quantum = 20 › The Gantt Chart for the schedule is:

› Higher avg. turnaround time than SJF, but better response

Process Burst Time

P1 53

P2 17

P3 68

P4 24

P1 P2 P3 P4 P1 P3 P4 P1 P3 P3

0 20 37 57 77 97 117 121 134 154 162

Page 20: Cpu Scheduling 6th Sem 2010 PPT

Design Constraints

› Implemented in JAVA Language

› Operating System : Windows XP

› No Database Connectivity

Page 21: Cpu Scheduling 6th Sem 2010 PPT

SDLC Model› Iterative waterfall model

Page 22: Cpu Scheduling 6th Sem 2010 PPT

Level 0 DFD

Page 23: Cpu Scheduling 6th Sem 2010 PPT

Level 1 DFD

Page 24: Cpu Scheduling 6th Sem 2010 PPT

Coding Progress

› FCFS.java

› Round-Robin.java

Page 25: Cpu Scheduling 6th Sem 2010 PPT

Any Queries ?