Outline of the Lecture 3 - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Outline of the Lecture 3

Description:

tB : P R is the next CPU burst time of a process (more precisely, it is an OS ... With each process, associate the length of its next CPU burst. ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 28
Provided by: devin4
Category:
Tags: burst | lecture | outline

less

Transcript and Presenter's Notes

Title: Outline of the Lecture 3


1
Outline of the Lecture 3
  • Scheduling Levels
  • Scheduling Algorithm Criteria
  • 3. Scheduling Algorithms and their Performance
  • First-Come-First Served
  • Shortest-Job-First and Its Optimality
  • Need for the CPU Burst Prediction
  • Preemptive Shortest-Job-First

2
Scheduler Place
Long-Term
Short-Term
End
CPU
Ready Queue
I/O Waiting Queues
I/O
3
Ready and Device Queues
head
ready queue
registers
registers
tail
PCB7
PCB2
queue header
head
tape unit 0
tail
disk unit 0
head
tail
PCB5
4
Process Scheduling
Ready Queue
CPU
I/O
I/O queue
I/O request
time slice expired
child executes
child terminates
fork a child
wait for an interrupt
interrupt occurs
5
Medium-term Scheduling
swap in
Partially executed swapped-out processes
swap out
Ready Queue
CPU
End
I/O Waiting Queue
I/O
6
When to Switch CPU?
  • Process voluntarily waits
  • System calls
  • Interrupt happens
  • - Higher priority event needs attention
  • - Higher priority process needs running
  • - Timer needs to execute

7
CPU Burst Distribution
8
CPU Burst Frequencies
  • I/O Bound Processes -- Many short CPU bursts
  • CPU Bound Processes -- Few very long CPU bursts

9
Programs and Processes
  • In an operating system there are a variety of
    programs that are executed.
  • Background Processes -- Jobs
  • User Process
  • Operating System Processes -- Tasks
  • We will refer to all of these as a
  • Process -- A program in execution

10
Process Control Block
  • Each process has a state information associated
    with it called a Process Control Block (PCB)

11
Lightweight Processes (Threads)
Screen Manager
  • cost of switching

P1
P2
1
2
Users
P3
3
Symmetric to each other Share PCB info with
heavyweight parent Scheduling? - gang
scheduling - hierarchical scheduling
12
Threads
  • A Thread is
  • A light-weight process
  • A single execution sequence
  • A component of a process
  • Most OSs support
  • multi-threading
  • Several threads in a process
  • They share part of the program code and the
    resources of the process

13
Thread State Diagram
Dead
New
Blocked
Running
Ready
14
Scheduling Levels
competition for OS attention
Processes Waiting for entry
Process entry
High-Level Scheduling competition for memory
Processes waiting for initiation
Process initiation
Suspended processes waiting for activation
Wake-up
Intermediate-Level Scheduling
Suspend
Active Processes
Dispatch
Low-Level Scheduling competition for CPU
Block/ Unblock Or Preempt
Running Processes
Complete
Completion
15
Scheduling Algorithm Criteria
  • 1) CPU Utilization -- Keep the CPU as busy as
    possible
  • 2) Throughput -- Number of processes that


    complete their execution per time
    unit
  • 3) Turnaround Time -- Amount of time to execute
    a particular process. A user wants his
    turnaround time to be short. In general use
    average turnaround time over a set of
    processes
  • 4) Waiting Time -- Amount of time a process has
    been waiting in the ready queue

16
Scheduling Algorithm Criteria continued
  • 5) Response Time -- Amount of time it takes from
    the time a request was submitted until the first
    response is produced (not output) (for
    interactive processes)
  • 6) Fairness -- FIFO, Linear Delay, Bounded Delay,
    non-starvation
  • 7) Meeting Deadlines --The scheduling discipline
    should subordinate other goals to that of
    maximizing the percentage of deadlines met
  • 8) Predictability -- A process should run in
    about the same amount of time and at the same
    cost regardless of the load on the system.
  • 9) Balancing Resources -- the scheduling policy
    should keep the resources of the system busy


17
User-Oriented Criteria
  • Response Time
  • Turnaround Time
  • Meeting Deadlines
  • Predictability

18
System-Oriented Criteria
  • Throughput
  • Processor Utilization
  • Fairness
  • Enforcing Priorities
  • Balancing Resources

19
Performance External Goals
  • Goals that can be measured without looking at the
    internals of a system
  • Examples
  • Maximize work performed (Throughput)
  • Minimize response time
  • Fairness in scheduling processes
  • Goals often conflict

20
Performance Internal Goals
  • Performance goals for sub-systems that are
    internal to the computer(s)
  • Examples
  • Maximize CPU Utilization
  • time CPU is busy
  • Maximize Disk Utilization
  • time a disk is busy
  • Minimize Disk Access Time
  • Time it takes to perform a disk request

21
Notation
P pi 1 i n is a set of processes in
the ready queue prit P Z is a
priority at time t, tB? P R is the next
CPU burst time of a process (more precisely, it
is an OS guess about the next CPU burst time)
22
Waiting time of a process
  • twait(pi) waiting time of process pi
  • twait(pi) S tB (pk) ok
  • where
  • 0 if prit (pk) lt prit (pi)
  • ok or (prit (pk) prit
    (pi)) (iltk1)
  • 1 otherwise
  • Simply, processes of higher priority would
    execute first

23
Turnaround Time
  • tturn turnaround time. Time elapsed between
    entry to ready state and exit from running state
  • tturn (pi) twait (pi) tB (pi)
  • We will denote by small t a specific time and by
    T an average of t.

24
First-Come-First-Serve Algorithm
  • A) First-Come-First-Serve (FCFS)
  • Easy to implement
  • Poor Performance
  • Example CPU Burst Duration
  • Process 1 24
  • Process 2 3
  • Process 3 3
  • Processes arrive in order 1, 2, 3

Proc2
Proc3
Proc1
0
24
27
30
25
FCFS Continued
Processes arrive in order 3, 2 ,1
Proc2
Proc3
Proc1
6
30
3
0
Gantt Chart
  • Turnaround Time for arrival order Proc1 24 Proc3
    3
  • Proc2 27 Proc2 6
  • Proc3 30 Proc1 30
  • Average turnaround times

(24 27 30) / 3 27
(3 6 30) / 3 13
26
Shortest Job First Algorithm
  • B) Shortest Job First (SJF)
  • With each process, associate the length of its
    next CPU burst. Use these lengths to dispatch
    the Process with the shortest time.
  • Optimal-- gives minimum average waiting time for
    a given set of processes.

27
SJF Optimality
Loss of long
Proof that the SJF algorithm is optimal
Gain of short gt Loss of long
Write a Comment
User Comments (0)
About PowerShow.com