22
Uniprocessor Scheduling I Chapter 9

Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

  • View
    231

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Uniprocessor Scheduling I

Chapter 9

Page 2: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Goals of Scheduling

Quick response timeFast throughputProcessor efficiency

Page 3: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Type of Scheduling (1)

Long-term performed when new process is created The decision to add to the pool of processes

to be executed (chapter 3, process control)Medium-term

swapping The decision to add to the number of

processes that are partially or fully in main memory (chapter 7 and 8, control structure)

Page 4: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Types of Scheduling

Short-term which ready process to execute next decision as to which ready process will be

executed by the processor (chatter 9 and 10)

I/O decision as to which process’s pending

I/O request shall be handled by available I/O device (chapter 11)

Page 5: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Scheduling and Process State Transition

ExitRunningReady

BlockedBlocked,suspend

Ready,suspend

New

Long-termscheduling

Medium-termscheduling

Medium-termscheduling

Long-termscheduling

Short-termscheduling

Page 6: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

A Seven-State Model - States

Ready: The process is in main memory and available for execution.

Blocked: The process is in main memory and awaiting an event.

Blocked, suspend: The process is in secondary memory and awaiting an event.

Ready, suspend: The process is in secondary memory but is available for execution as soon as it is loaded into main memory.

Page 7: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Queuing Diagram for Scheduling

Processor

Medium-termscheduling

Medium-termscheduling

Batchjobs

Long-termscheduling

Time-out

Interactiveusers

Ready Queue

Ready, Suspend Queue

Blocked, Suspend Queue

Blocked QueueEvent

Occurs

Event Wait

ReleaseShort-termscheduling

Page 8: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Long-Term Scheduling

Determines which programs are admitted to the system for processing

Controls the degree of multiprogramming

More processes, smaller percentage of time each process is executed

Page 9: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Medium-Term Scheduling

SwappingBased on the need to manage

multiprogramming

Page 10: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Short-Term Scheduling

Known as the dispatcherInvoked when an event occurs

clock interrupts I/O interrupts operating system calls signals

Page 11: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Short-Tem Scheduling Criteria

User-oriented Related to the behavior of the system as

perceived by the individual user or process. Response Time: Elapsed time between the

submission of a request until there is output.

System-oriented The focus if on effective and efficient

utilization of the processor

Page 12: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Short-Term Scheduling CriteriaPerformance-related

Performance-related criteria are quantitative and generally can be readily measured.

measurable such as response time and throughput

Not performance related predictability: a given job should run in

about the same amount of time and at about the same cost regardless of the load on the system

Page 13: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Priorities

Scheduler will always choose a process of higher priority over one of lower priority

Have multiple ready queues to represent each level of priority

Lower-priority may suffer starvation allow a process to change its priority

based on its age or execution history

Page 14: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Priority Queuing

Processor

Eventoccurs Blocked Queue

Event Wait

Preemption

Admit

RQn

RQ1

RQ0Dispatch

Release

.

.

.

Priority

[RQi] >[RQj]

for i<j

A set of queues to instead of a single ready queue

Page 15: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Decision Mode

Nonpreemptive Once a process is in the running state, it will

continue until it terminates or blocks itself for I/OPreemptive

Currently running process may be interrupted and moved to the Ready state by the operating system

Allows for better service since any one process cannot monopolize the processor for very long

Page 16: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

An Example for Scheduling Policies

Process Arrival Time Service Time

1

2

3

4

5

0

2

46

8

3

6

4

5

2

Page 17: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Each process joins the Ready queueWhen the current process ceases to execute,

the oldest process in the Ready queue is selected

0 5 10 15 20

1

2

3

4

5

First-Come-First-Served (FCFS)

Page 18: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Turnaround Time and Service Time

Turnaround Time Tq - the total time that the item

spends in the system (waiting time plus service time,

or finish time mines arrival time).

Service Time Ts - Finish Time minus Start Time.

Normalized Turnaround Time - the ratio of turnaround

time to service time

Tq / Ts

Page 19: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

FCFS -Normalized Turnaround Time

Process Arrival Serve Start Finish Turnaround Tq/Ts

Time Time Ts Time Time Time Tq

A 0 1 0 1 1 1

B 1 100 1 101 100 1

C 2 1 101 102 100 100

D 3 100 102 202 199 1.99

Mean 100 26

Page 20: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Difficulties with First-Come-First-Served

A short process may have to wait a very long time before it can execute

Favors CPU-bound processes CPU-bound processes: the processes

mostly use processor. I/O processes have to wait until CPU-

bound process completes

Page 21: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Uses preemption based on a clockAn amount of time is determined that

allows each process to use the processor for that length of time

Next ready job is selected.

Round-Robin q=1

0 5 10 15 20

1

2

3

4

5

02

23

45

66

7

88

910

1112

1314

16

Ready Time

Page 22: Uniprocessor Scheduling I Chapter 9. Goals of Scheduling zQuick response time zFast throughput zProcessor efficiency

Round-Robin q=4

0 5 10 15 20

1

2

3

4

5

24

6

P2 rest part ready time is 7

P4 rest part ready time is 15

P5 ready time is 8

P4 rest part ready time is 15

P5 ready time is 8

07

158

Ready Time

Ready Time