processes and scheduling section iii processes and scheduling objective of scheduling ...

61
Processes and Processes and Scheduling Scheduling Section III Section III

Upload: rosa-gibson

Post on 13-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

Processes and SchedulingProcesses and Scheduling

Section IIISection III

Page 2: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Objective of schedulingObjective of scheduling

Fairness----Prevent starvation Efficiency Throughput Response time

Page 3: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Types of schedulingTypes of scheduling (调度类型(调度类型 p379p379 ))

Sorted by OS types (按系统类型分类)٭ Batch scheduling (批处理调度)٭ Time-sharing scheduling ( 分时调度)٭ Real-time scheduling (实时调度)٭ Multiprocessor scheduling (多处理机调度)

Sorted by perform frequency and scheduling unitSorted by perform frequency and scheduling unit (按执行频(按执行频率分类)率分类)

Long-term schedulingLong-term scheduling (长程调度)(长程调度)Medium-term scheduling Medium-term scheduling (中程调度)(中程调度)Short-term scheduling Short-term scheduling (短程调度)(短程调度)I/O schedulingI/O scheduling

Page 4: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Scheduling and Process State Transitions (p380)Scheduling and Process State Transitions (p380)

Page 5: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Levels of SchedulingLevels of Scheduling (分级调度图(分级调度图 P381P381 ))

Page 6: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

P382

Page 7: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Long-term scheduling(P380)Long-term scheduling(P380)

Determines( 确定 ) which program are admitted to the system for processing. Controls the degree of multiprogramming (多道程度) . Once admitted (提交) , a job becomes a process and is added to the queue for short-term scheduler or for medium-term scheduler.

In a batch system, the long-term scheduler chooses the jobs held in( 保持在 ) disk queue and creates processes from the queue when it can.

Page 8: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Two problems for long-term schedulingTwo problems for long-term scheduling (( p381p381 ))

Decide the number of processes that OS can take on, which is decided by the degree of multiprogramming.

Which job or jobs to accept and turn into( 转化为 ) processes.

٭ Decided by scheduling algorithm , e.g. FCFS 、 SJF 、HRRN etc…

When to invoke the long-term scheduler? States of Job: admit, execution, finish

Page 9: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Medium-term schedulingMedium-term scheduling (( p383p383 ))

Part of the swapping function( 交换功能 ). Choose processes in disk to swap in for execution.

Page 10: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Short-term schedulingShort-term scheduling (( p383p383 ))

Known as the dispatcher (分派器) , executes most frequently and makes the fine-grained( 细粒度 ) decision of which process to execute next.

The event to invoked (引起) the short-term scheduling

٭ Clock interrupts

٭ I/O interrupts

٭ Operating system calls

٭ Signals (信号)

Page 11: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Scheduling CriteriaScheduling Criteria (准则) (准则) T9.2(p385)T9.2(p385)

User Oriented, Performance Related (面向用户,考虑性能)٭ Response time (响应时间) . From the submission

(提交) of a request until the response begins to be received. Often be used in time-shared time.

٭ Turnaround (周转) time. The interval (间隙) of time between the submission of a process and its completion. Often be used in batch systems.

٭ Deadlines (截止期) . The deadlines be specified for a process, such as starting deadlines and completion deadlines.

Page 12: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Scheduling Criteria Scheduling Criteria (( IIII ))

System Oriented (面向系统)٭ Throughput (吞吐量) . The number of processes comp

leted per unit of time. Often used in batch system.

٭ Processor Utilization (利用率) . Percentage of time that the processor is busy.

٭ Balancing (平衡) Resources. Used in long-term and middle-term scheduling.

٭ Fairness (公平) . No process should suffer starvation(受饥饿) .

Page 13: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Scheduling Criteria Scheduling Criteria (( IIIIII ))

System Oriented٭ Enforcing priorities( 优先权 ). The scheduling policy sho

uld favor higher priority processes.▪ Implement (实现) : Multi-queue F9.4(P386)▪ To avoid starve, consider the waiting time as a factio

n (因素) to calculate priority.

Page 14: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Multi-queueMulti-queue (多队列(多队列 p386p386 ))

Page 15: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Scheduling Algorithms(p388)Scheduling Algorithms(p388)

Selection function:

٭ w: time spent waiting for the processor( 从提交到现在的等待时间 )

٭ e: time spent in execution so far( 到现在的执行时间 )

٭ s: total service time required by the process, include e( 需要被服务的总时间 )

Page 16: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Scheduling Algorithms(p388)Scheduling Algorithms(p388)

Decision mode( 调度模式 )

٭ Nonpreemptive (非抢占) : Once a process is in the running state, it continues to execute until it terminates or blocks itself to wait for I/O or by requesting some OS service. Often used in batch system.

٭ Preemptive (抢占) : The running process may be interrupted to ready state. Often used in time-sharing or real-time system.

٭ Preemptive policies incur( 引入 ) greater overhead than nonpreemptive ones but provide better service.

Page 17: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Examples Examples (( p388p388 ))

Five processes

Page 18: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Analysis(p389~390)Analysis(p389~390)

Using six scheduling algorithms in the example, calculates the average turnaround( 周转 ) time, and ( Tq / Ts ) (Fig 9.5 & Table 9.4).

Page 19: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Page 20: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

First Come First ServedFirst Come First Served (( FCFSFCFS ))

0 5 10 15 20

1

2

3

4

5

Page 21: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

FCFSFCFS (( p389~391)p389~391)

Simple to implement, but :٭ Inefficient for using resource.

٭ Unfairness. Favor( 有 利 于 ) for processor-bound(计算型) processes but not favor for I/O- bound processes.

Page 22: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Unfairness of FCFSUnfairness of FCFS (( p391p391 ))

Page 23: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Application of FCFSApplication of FCFS (p391)(p391)

FCFS is not an attractive alternative (选择) o

n its own for a single-processor system. However, it is often combined with a priority scheme to provide an effective scheduler.

Page 24: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Round RobinRound Robin (( RRRR )) (p391)(p391)

0 5 10 15 20

1

2

3

4

5

Page 25: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

RRRR

Time slice( 时间片 ). If the quantum (数量) is very short, system overhead to finish process switch (进程切换) is high. To large, the user can not tolerate.

Disadvantage (缺点): A I/O-bound process only need little time, but it must wait a RR cycle.

Used in time-sharing system.

Page 26: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Virtual Round Robin (VRRp393) Virtual Round Robin (VRRp393)

VRR : Add an auxiliary( 辅助 ) queue to storage the I/O finished processes. It has higher priority than ready queue but it can get little slice than ready queue. ( P393 , Fig 9.7 )

Analysis: VRR is fair than RR algorithm.

Page 27: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Shortest Process Next (SPN P395)Shortest Process Next (SPN P395)

0 5 10 15 20

1

2

3

4

5

Page 28: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

SPN(P395)SPN(P395)

Advantage

٭ Reduces the average waiting time, improve the system performance and throughtput.

Disadvantage

٭ Difficult to confirm( 确定 ) the execution time of a process.

٭ Unfair to long process.

٭ Do not consider the pressure task and not suitable for time-sharing and transition process system.

Page 29: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Confirm the Execution Time of a Process(p395)Confirm the Execution Time of a Process(p395)

nnn Sn

nTn

S11

1

n

i

in Tn

S1

11

nnn STS )1(1

Page 30: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Shortest Remaining Time (SRT)Shortest Remaining Time (SRT)

0 5 10 15 20

1

2

3

4

5

Page 31: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

SRTSRT (( p397p397 ))

SPN + Preempt.

٭ Difficult to confirm the remain execution time of a process and unfair to long process.

٭ The average turnaround time( 周转时间 ) is short than SPN.

٭ Elapsed( 已流逝的 ) service times must be recorded.

Page 32: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Highest Response Ratio(Highest Response Ratio( 响应比响应比 ) Next (HRRN)) Next (HRRN)

1

2

3

4

5

0 5 10 15 20

Page 33: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

HRRNHRRN (( p397p397 ))

Response ratio RR= ( w + s ) / s=1+w/s If two processes have same waiting time, then the proce

ss who requests short service time has a higher priority( SPN ) ;

If two processes have same service time, then the process who waits for longer time has a higher priority ( FCFS ) ;

For a long process, it’s priority will increase going with the waiting time.

Difficult to confirm the execution time of a process. Need to calculate the response ratio.

Page 34: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Feedback(Feedback( 反馈反馈 FB q=1)FB q=1)

0 5 10 15 20

1

2

3

4

5

Page 35: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

FBFB (( p398p398 ))

Need not to confirm the services time of a process. Multi ready-queue, every queue has a different priority. The higher the priority of a queue, the shorter the time sli

ce for that queue ; A new process first in the highest priority queue, and if it c

an not complete in the first queue , it will be put into the second queue…

Only the first queue is empty, the second queue can be scheduling and so on…

Page 36: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

FB F9.10FB F9.10 ,, P398P398

Page 37: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

FB(p398)FB(p398)

Be favor for interaction job ( often short job) Be favor for short batch job Long process maybe starve if there are many new

short processes come in. The last queue is treated in RR algorithm.

Page 38: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Real-Time Scheduling (p430)Real-Time Scheduling (p430)

Page 39: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Real-Time SystemReal-Time System

Real-time system may be defined as that type of computing in which the correctness of the system depends not only on the logical result of the computation, but also on the time at which the results are produced.( 实时任务运行结果的正确性依赖于时间和运行逻辑 )

Page 40: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Types of real-time taskTypes of real-time task (( p430p430 ))

Periodic and aperiodic task.( 周期和非周期任务 ) Sort by deadline (按截止时间分类)

٭ Hard real-time task is one that must meet its deadline; otherwise it will cause undesirable damage or a fatal error to the system.

٭ Soft real-time task has an associated deadline that is desirable but not mandatory (强制) ; it still makes sense to schedule and complete the task even if it has passed its deadline.

Page 41: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Characteristics of Real-time OSCharacteristics of Real-time OS (( P430P430 ))

Determinism (确定性) :Performs operations at fixed, predetermined times or within predetermined time intervals.

Responsiveness (响应性) : How long, after acknowledgement, it takes an OS to service an interrupt.

User control : Is generally much broader( 多 ) in a real-time OS than in ordinary OS.

Reliability (可靠性): Far more important for real-time OS than non-real-time systems.

Fail-soft operation (抗毁性): The ability of a system to fail in such a way as to preserve as much capability( 能力 ) and data as possible.

Page 42: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Features of real-time OSFeatures of real-time OS (( p432p432 ))

Fast process or thread switch. Small size (with minimal functionality). Ability to respond to external interrupts quickly. Multitasking with interprocess communication( 进程间通信 )

tools such as semaphores, signals, and events. Use of special sequential files that can accumulate data at a f

ast rate. Preemptive scheduling based on priority. Minimization of intervals during which interrupts are disabl

ed.( 最小化禁止中断的时隙 ) Primitives to delay tasks for a fixed amount of time and to pa

use/resume tasks. (具有延迟、暂停、继续任务的原语) Special alarms and timeouts.

Page 43: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Analysis(p432Analysis(p432 ))

Round Robin Preemptive Scheduler

٭ A task must await its next time slice. Unacceptable for real-time applications.

Page 44: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Priority-drivenPriority-driven (优先权) (优先权) Nonpreemptive SchedulerNonpreemptive Scheduler

A real-time task has high priority and would be scheduled as soon as the current process blocks to run to completion. This could lead to delay of several seconds. Not acceptable.

Page 45: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Priority-driven Preemptive SchedulerPriority-driven Preemptive Scheduler

Combine priorities with clock-based interrupts. Preemption points (抢占点) occur at regular intervals( 规则的间隙 ). Such a delay may be on the order of several milliseconds.

Page 46: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Immediate Preemptive SchedulerImmediate Preemptive Scheduler

OS responds to an interrupt almost immediately, unless the system is in a critical-code lockout (停止) section. Scheduling delays for a task can then be reduced to 100μs or less.

Page 47: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

TypesTypes (类型) (类型) of Real-Time Schedulingof Real-Time Scheduling

Static table-driven (静态表) approaches. Static priority-driven (静态优先权) preemptive a

pproaches. Dynamic planning-based( 动态规划 ) approaches. Dynamic best effort( 动态最大努力 ) approaches.

Page 48: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Static Table-Driven ApproachesStatic Table-Driven Approaches (( p434p434 ))

Is suitable to tasks that are periodic (周期) . Input to the analysis consists of the periodic arrival time, execution time, periodic ending deadline, and relative priority of each task. Earliest-deadline-first ( EDF ) are typical of this category.

Page 49: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Static Priority-Driven Preemptive ApproachesStatic Priority-Driven Preemptive Approaches

Priority assignment is related to the time constraints associated with each task. One example of this approach is rate monotonic( 单调速率 ) algorithm, which assigns static priorities to tasks based on their periods.

Page 50: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Dynamic Planning-Based ApproachesDynamic Planning-Based Approaches

After a task arrives, but before its execution begins, an attempt is made to create a schedule that contains the previously scheduled tasks as well as the new arrival. (新任务到达要参与调度)

If the new arrival can be scheduled in such a way that its deadlines are satisfied and that no currently scheduled task misses a deadline, then the schedule is revised to accommodate the new task. (接纳新任务)

Page 51: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Dynamic best effort approachesDynamic best effort approaches

When a task arrives, the system assigns a priority based on the characteristics. Until a deadline arrives or until the completes, we do not know whether a timing constraint will be met.

Easy to implement.

Page 52: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Deadline SchedulingDeadline Scheduling (( p435p435 ))

The following information might be used: Ready time : Time at which task becomes ready for

execution. Starting deadline : Time by which a task must begi

n. Completion deadline: Time by which task must be co

mpleted. Processing time : Time required to execute the task

to completion

Page 53: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Deadline SchedulingDeadline Scheduling (( II)II)

Resource requirements : Set of resources (other than the processor) required by the task while it is executing.

Priority : Hard real-time tasks may have an absolute priority. Soft real-time task may have a relative priority.

Subtask structure : A task may be decomposed into a mandatory (强制) subtask and an optional subtask. Only the mandatory subtask possesses a hard deadline.

Page 54: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Deadline Scheduling(III)Deadline Scheduling(III)

Earliest Deadline Scheduling

٭ For starting deadline task, no preemption method could be used(F10.4b), and for ending deadline task, preemption method should be used. 10.4c,d )

Page 55: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Two Periodic Tasks With Completion Deadline(P436)Two Periodic Tasks With Completion Deadline(P436)

Two task A and B , The deadline for A must be met every 20ms, and B every 50ms. It takes 10ms, including OS overhead, to process each sample of data from A and 25 ms to process each sample of data from B. T10.2(P436) and F10.5(P437)

Page 56: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Two Periodic Tasks With Completion DeadlineTwo Periodic Tasks With Completion Deadline

Page 57: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Page 58: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Five Aperiodic Task With Starting Deadlines(P438)Five Aperiodic Task With Starting Deadlines(P438)

A 、 B 、 C 、 D 、 E (T10.3 , P438). F10.6(P439) Compare three algorithm٭ Earliest Deadline٭ Earliest Deadline with Unforced Idle Times٭ First Come First Served

Page 59: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Page 60: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING

Rate Monotonic Scheduling (RMSRate Monotonic Scheduling (RMS 单调速率单调速率 ))

Often used for periodic tasks. The priority is decided by the period of task. The shorter the period, the higher the priority.

Period: The time between the arriving time of two tasks. Rate: Inverse of period (in Hertz) The execution time must not exceed the period of the tas

k. CPU utility = the execution time / period of task In RMS scheduling algorithm, using the speed as the pa

rameter , the function of priority is a descending function ( F10.8 , P440 )。

Page 61: Processes and Scheduling Section III PROCESSES AND SCHEDULING Objective of scheduling  Fairness----Prevent starvation  Efficiency  Throughput  Response

PROCESSES AND SCHEDULINGPROCESSES AND SCHEDULING