advertisement

Cpu Scheduling Galvin

60 %
40 %
advertisement
Information about Cpu Scheduling Galvin
Education

Published on January 12, 2009

Author: sonalichauhan

Source: slideshare.net

advertisement

CPU SCHEDULING SONALI CHAUHAN SYBSc IT 2008-09 UDIT

BASIC CONCEPTS Main objective of multiprogramming is to keep on running processes all the time for maximum CPU utilization. In uniprocess system only one process run at a time, others process have to wait for cpu time. Scheduling is fundamental function of OS.

Main objective of multiprogramming is to keep on running processes all the time for maximum CPU utilization.

In uniprocess system only one process run at a time, others process have to wait for cpu time.

Scheduling is fundamental function of OS.

CPU-I/O BURST CYCLE CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait.

CPU–I/O Burst Cycle – Process execution

consists of a cycle of CPU execution and I/O

wait.

CONT…

CPU SCHEDULER Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates Scheduling under 1 and 4 is nonpreemptive All other scheduling is preemptive

Selects from among the processes in memory that

are ready to execute, and allocates the CPU to one of them

CPU scheduling decisions may take place when a

process:

1. Switches from running to waiting state

2. Switches from running to ready state

3. Switches from waiting to ready

4. Terminates

Scheduling under 1 and 4 is nonpreemptive

All other scheduling is preemptive

Selects one process from ready queue to run on CPU Scheduling can be Nonpreemptive Preemptive CONT…

Selects one process from ready queue to run on CPU

Scheduling can be

Nonpreemptive

Preemptive

Nonpreemptive Once a process is allocated the CPU, it does not leave unless: it has to wait, e.g., for I/O request  or for a child to terminate it terminates   Preemptive OS can force (preempt) a process from CPU at anytime Say, to allocate CPU to another higher-priority process  CONT…

Nonpreemptive

Once a process is allocated the CPU, it does not leave unless:

it has to wait, e.g., for I/O request  or for a child to terminate

it terminates  

Preemptive

OS can force (preempt) a process from CPU at anytime

Say, to allocate CPU to another higher-priority process 

DISPATCHER Scheduler : selects one process to run on CPU Dispatcher : allocates CPU to the selected process, which involves: switching context switching to user mode jumping to the proper location (in the selected process) and restarting it Dispatcher should be fast enough. Dispatch latency – time it takes for the dispatcher to stop one process and start another running.

Scheduler : selects one process to run on CPU

Dispatcher : allocates CPU to the selected process, which involves:

switching context

switching to user mode

jumping to the proper location (in the selected process) and restarting it

Dispatcher should be fast enough.

Dispatch latency – time it takes for the dispatcher to stop one process and start another running.

How does scheduler select a process to run?

How does scheduler select a process to run?

SCHEDULING CRITERIA CPU utilization – keep the CPU as busy as possible Maximize Throughput – No of processes that complete their execution per time unit Maximize Turnaround time – amount of time to execute a particular process (time from submission to termination) i.e (waiting in memory + waiting time in ready queue + executing time in CPU + doing IO) Minimize

CPU utilization – keep the CPU as busy as possible

Maximize

Throughput – No of processes that complete their execution per time unit

Maximize

Turnaround time – amount of time to execute a particular process (time from submission to termination) i.e (waiting in memory + waiting time in ready queue + executing time in CPU + doing IO)

Minimize

Waiting time – amount of time a process has been waiting in the ready queue (sum of time waiting in ready queue) Minimize Response time – amount of time it takes from when a request was submitted until the first response is produced, not output  (for time-sharing environment) Minimize CONT…

Waiting time – amount of time a process has been waiting in the ready queue (sum of time waiting in ready queue)

Minimize

Response time – amount of time it takes from when a request was submitted until the first response is produced, not output  (for time-sharing environment)

Minimize

SCHEDULING ALGORITHM First Come, First Served Shortest Job First Priority Round Robin

First Come, First Served

Shortest Job First

Priority

Round Robin

FIRST COME FIRST SERVED SCHEDULING

Process Burst Time P1 24 P2 3 P3 3 Suppose that the 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 CONT… First come, First served… P 1 P 2 P 3 24 27 30 0

Process Burst Time

P1 24

P2 3

P3 3

Suppose that the 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

Suppose that the processes arrive in the order : P 2 , P 3 , P 1 ( P1: 24, P2: 3, P3: 3) The Gantt chart for the schedule is: Waiting time for P 1 = 6 ; P 2 = 0 ; P 3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3 Much better than previous case Convoy effect short process behind long process CONT… First come, First served… P 1 P 3 P 2 6 3 30 0

Suppose that the processes arrive in the order : P 2 , P 3 , P 1 ( P1: 24, P2: 3, P3: 3)

The Gantt chart for the schedule is:

Waiting time for P 1 = 6 ; P 2 = 0 ; P 3 = 3

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

Much better than previous case

Convoy effect short process behind long process

CONT… SHORTEST-JOB-FIRST SCHEDULING

Associate with each process the length of its next CPU burst. Use these lengths to schedule the process with the shortest time Two schemes: nonpreemptive – once CPU given to the process it cannot 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, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF) SJF is optimal – gives minimum average waiting time for a given set of processes CONT… SHORTEST-JOB-FIRST

Associate with each process the length of its next CPU burst.

Use these lengths to schedule the process with the shortest time

Two schemes:

nonpreemptive – once CPU given to the process it cannot 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, preempt. This scheme is know as the Shortest-Remaining-Time-First (SRTF)

SJF is optimal – gives minimum average waiting time for a given set of processes

CONT… SHORTEST-JOB-FIRST… Process Arrival Time Burst Time P 1 0.0 7 P 2 2.0 4 P 3 4.0 1 P 4 5.0 4 SJF (non-preemptive) Average waiting time = (0 + 6 + 3 + 7)/4 - 4 Example of Non-Preemptive SJF P 1 P 3 P 2 7 3 16 0 P 4 8 12

Process Arrival Time Burst Time

P 1 0.0 7

P 2 2.0 4

P 3 4.0 1

P 4 5.0 4

SJF (non-preemptive)

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

Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4 SJF (preemptive) Average waiting time = (9 + 1 + 0 +2)/4 - 3 CONT… SHORTEST-JOB-FIRST… Example of Preemptive SJF P 1 P 3 P 2 4 2 11 0 P 4 5 7 P 2 P 1 16

Process Arrival Time Burst Time

P1 0.0 7

P2 2.0 4

P3 4.0 1

P4 5.0 4

SJF (preemptive)

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

PRIORITY SCHEDULING

A priority number (integer) is associated with each process Lager the CPU burst lower the priority The CPU is allocated to the process with the highest priority (smallest integer  highest priority) Preemptive nonpreemptive Problem  Starvation (Infinity blocking) – low priority processes may never execute Solution  Aging – as time progresses increase the priority of the process CONT… PRIORITY…

A priority number (integer) is associated with each process

Lager the CPU burst lower the priority

The CPU is allocated to the process with the highest priority (smallest integer  highest priority)

Preemptive

nonpreemptive

Problem  Starvation (Infinity blocking) – low priority processes may never execute

Solution  Aging – as time progresses increase the priority of the process

ROUND-ROBIN SCHEDULING

Each process gets a small unit of CPU time ( time quantum ), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue. If there are n processes in the ready queue and the time quantum is q , then each process gets 1/ n of the CPU time in chunks of at most q time units at once. No process waits more than ( n -1) q time units. Performance q large  FIFO q small  q must be large with respect to context switch, otherwise overhead is too high CONT… ROUND-ROBIN…

Each process gets a small unit of CPU time ( time quantum ), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.

If there are n processes in the ready queue and the time quantum is q , then each process gets 1/ n of the CPU time in chunks of at most q time units at once. No process waits more than ( n -1) q time units.

Performance

q large  FIFO

q small  q must be large with respect to context switch, otherwise overhead is too high

Process Burst Time P1 24 P2 3 P3 3 Quantum time 4millisec The Gantt chart is: Typically, higher average turnaround than SJF, but better response CONT… ROUND-ROBIN… P 1 P 2 P 3 P 1 P 1 P 1 P 1 P 1 0 4 7 10 14 18 22 26 30

Process Burst Time

P1 24

P2 3

P3 3

Quantum time 4millisec

The Gantt chart is:

Typically, higher average turnaround than SJF, but better response

Add a comment

Related presentations

Related pages

Operating Systems: CPU Scheduling - Computer Science

CPU Scheduling References: Abraham Silberschatz, Greg Gagne, and Peter Baer Galvin, "Operating System Concepts, Eighth Edition ", Chapter 5 5.1 Basic Concepts
Read more

Chapter 6: CPU Scheduling - wiley.com

Operating System Concepts 6.1 Silberschatz, Galvin and Gagne 2002 Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms
Read more

Chapter 6: CPU Scheduling - George Mason University

1 Operating System Concepts with Java 6.1 Silberschatz, Galvin and Gagne ©2003 Chapter 6: CPU Scheduling nBasic Concepts nScheduling Criteria nScheduling ...
Read more

Operating System Concepts - CPU Scheduling Flashcards ...

8th Edition Operating system concepts Silberschatz, Galvin, Gagne [Chapter 5 Multiple-Processor Scheduling]
Read more

Operating Systems: CPU Scheduling - University of Illinois ...

CPU Scheduling References: Abraham Silberschatz, Greg Gagne, and Peter Baer Galvin, "Operating System Concepts, Ninth Edition ", Chapter 6 6.1 Basic Concepts
Read more

Chapter 5: CPU Scheduling - EazyNotes

Operating System Concepts – 8th Edition 5.2 Silberschatz, Galvin and Gagne ©2009 Chapter 5: CPU Scheduling Basic Concepts Scheduling Criteria
Read more

Chapter 5 CPU Scheduling (Algorithms)

Chapter 5 CPU Scheduling (Algorithms) Deterministic Modeling: Using round robin scheduling Process Burst Time P1 10 P2 29 P3 3 P4 7 P5 12 (Time quantum ...
Read more

Cpu Scheduling - scribd.com

Chapter 5: CPU Scheduling. Operating System Concepts ± 8th Edition, Silberschatz, Galvin and Gagne ©2009 Outline Basic Concepts Scheduling Criteria ...
Read more

Module 6: CPU Scheduling - Wiley: Home

Operating System Concepts with Java 6.1 Silberschatz, Galvin and Gagne ©2003 Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling ...
Read more