Sunteți pe pagina 1din 19

BITS Pilani

Real Time Systems


BITS Pilani G S Sesha Chalapathi
gssc@pilani.bits-pilani.ac.in
Pilani Campus
BITS Pilani
Pilani Campus

Lecture-6
Introduction to Scheduling
BITS G553 Real Time Systems
Last Class

• Periodic Task Model


• Precedence Graph and Task Graph

BITS Pilani, Pilani Campus


Today’s Class

• Effective release time and deadlines


• Overview of scheduling Algorithms

BITS Pilani, Pilani Campus


Overview of real-time scheduling algorithms

• Clock-driven
• Round-robin
• Priority-driven
 Dynamic vs. static
 Deadline scheduling: EDF and LST
 Off-line and On-line Scheduling
 Validation

5
BITS Pilani, Pilani Campus
Broad Division

• Clock-driven
 Scheduling points are defined by interrupts from a
timer
• Event-driven
 Scheduling points are defined by task completion and
generation events

6
BITS Pilani, Pilani Campus
Clock-Driven Scheduling

• Decisions about what jobs execute when are made at specific


time instants
–  These instants are chosen before the system begins execution
–  Usually regularly spaced, implemented using a periodic timer
interrupt
 Scheduler awakes after each interrupt, schedules the job to
execute for the next period, then blocks itself until the next
interrupt
• Typically in clock-driven systems:
–  All parameters of the real-time jobs are fixed and known
–  A schedule of the jobs is computed off-line and is stored for use
at run-time; as a result, scheduling overhead at run-time can be
minimized
–  Simple and straight-forward, not flexible
7
BITS Pilani, Pilani Campus
Round Robin

• A small unit of time called time quantum or time slice is


allocated to each process
• If the burst is less than time slice then process leaves
the CPU and next process is scheduled
• If the burst is greater than time slice then timer will cause
a interrupt to the OS .A context switch will be executed
and the process will be put at the tail of the ready queue.
• When there are n ready jobs each jobs gets one time
slice every one time slice every n time slices

BITS Pilani, Pilani Campus


Weighted Round-Robin
Scheduling
• In weighted round robin each job Ji is assigned a weight wi; the job
will receive wi consecutive time slices each round, and the duration
of a round is
–  Equivalent to regular round robin if all weights equal 1
–  Simple to implement, since it doesn’t require a sorted
priority queue

• Partitions capacity between jobs according to some ratio


Offers throughput guarantees
Each job makes a certain amount of progress each round

• By giving each job a fixed fraction of the processor time, a round-


robin scheduler may delay the completion of every job

9
BITS Pilani, Pilani Campus
Priority-Driven Scheduling
• Assign priorities to jobs, based on some algorithm
• Make scheduling decisions based on the priorities, when events such as
releases and job completions occur
–  Priority scheduling algorithms are event-driven
–  Jobs are placed in one or more queues; at each event, the ready job
with the highest priority is executed
–  The assignment of jobs to priority queues, along with rules such a
whether preemption is allowed, completely defines a priority
scheduling algorithm
• Priority-driven algorithms make locally optimal decisions about which job to
run
–  Locally optimal scheduling decisions are often not globally optimal
–  Priority-driven algorithms never intentionally leave any resource idle
-- Leaving a resource idle is not locally optimal

BITS Pilani, Pilani Campus


Priority-Driven Scheduling
• Most scheduling algorithms used in non real-time systems are
priority-driven

• Priority according to release time


1. First-In-First-Out (FIFO)
2. Last-In-First-Out (LIFO)

• Priority according to job execution time


1. Shortest-Execution-Time-First (SETF)
2. Longest-Execution-Time-First (LETF)

• Real-time priority scheduling assigns priorities based on deadline or


some other timing constraint:
1. Earliest deadline first (EDF)
2. Least slack time first (LST)

BITS Pilani, Pilani Campus


Earliest deadline first (EDF)

–  Assign priority to jobs based on deadline


–  Earlier the deadline, higher the priority
–  Simple, just requires knowledge of deadlines

BITS Pilani, Pilani Campus


Least Slack Time first (LST)

–  A job Ji has deadline di, execution time ei, and was


released at time ri
–  At time t < di:
• Remaining execution time trem = ei – (time for
which job has executed)
• Slack time or laxity time tslack = di - t – trem
 e.g. T1(2,8] : at t=0 slack=8-0-{2-(0-0)}=6
 Slack is updated whenever a event occurs
–  Assign priority to jobs based on slack time, tslack
–  The smaller the slack time, the higher the priority
–  More complex, requires knowledge of execution times
and deadlines

BITS Pilani, Pilani Campus


LST2

• Knowing the actual execution time is often difficult a


priori, since it depends on the data, need to use worst
case estimates (⇒ poor performance)

Eg: J1 (0,6] execution time is 3


Slack or laxity at t=0 is 6-0-3=3
Executes till t=2 so slack=6-2-1=3
If another job runs from t=2 to t=4 then
At t=4 slack= 6-4-1=1

BITS Pilani, Pilani Campus


Optimality of EDF and LST

These algorithms are optimal


• i.e. they will always produce a feasible schedule if
one exists
• Constraints: on a single processor, as long as
preemption is allowed and jobs do not contend for
resources

BITS Pilani, Pilani Campus


Offline v/s Online Scheduling

Offline Scheduling Online Scheduling


• Plan is fully ready before • Prior plan is not ready so new
execution tasks can be accommodated
• Different situations must be • New task accommodated in
known priori the existing schedule
• Decide and validate the design • Tests are conducted if the new
• Must for hard RTS task can be handled
• Unpredictable situations if
exists offline scheduling fails

BITS Pilani, Pilani Campus


Dynamic vs. Static Systems
Dynamic system
• If jobs are scheduled on multiple processors, and a job can be
dispatched from the priority run queue to any of the processors, the
system is dynamic
• A job migrates if it starts execution on one processor and is resumed
on a different processor

Static system
• If jobs are partitioned into subsystems, and each subsystem is bound
statically to a processor, we have a static system.
• Static system can be offline or online
• Expect static systems to have inferior performance (in terms of overall
response time of the jobs) relative to dynamic systems
–  But it is possible to validate static systems, whereas this is not always
true for dynamic systems
–  For this reason, most hard real time systems are static

BITS Pilani, Pilani Campus


Effective Release Times and
Deadlines
• Sometimes the release time of a job may be later than that of its
successors, or its deadline may be earlier than that specified for its
predecessors
• This makes no sense: derive an effective release time or effective
deadline consistent with all precedence constraints, and schedule
using that
–  Effective release time
•  If a job has no predecessors, its effective release time is its
release time
•  If it has predecessors, its effective release time is the
maximum of its release time and the effective release times of its
predecessors
–  Effective deadline
•  If a job has no successors, its effective deadline is its deadline
•  It if has successors, its effective deadline is the minimum of its
deadline and the effective deadline of its successors

BITS Pilani, Pilani Campus


Example
J1(2,10) J3(1,12) J4(4,9) J6(0,20)

J2(0,7) J5(1,8) J7(6,21)

Correct answer :
J1(2,8); J3(2,8) ; J4(4,9) ; J6(4,20)
J2(0,7) ; J5(2,8) ; J7(6,21)
What is the maximum value of execution time of each job?
Draw the EDF schedule
9/7/2016 Real Time Systems 19
BITS Pilani, Pilani Campus

S-ar putea să vă placă și