Page 1 Chapter 3.5: Multimedia Operating Systems
Chapter 2: Basics
Chapter 3: Multimedia Systems – Communication Aspects and Services
• Multimedia Applications and Communication
• “Multimedia” Transfer and Control Protocols
• Quality of Service and Resource Management
• Synchronization
• Multimedia Operating Systems
Chapter 4: Multimedia Systems – Storage Aspects Chapter 5: Multimedia Usage
3.5: Multimedia Operating Systems
• Resource Management
• Process Management
• Scheduling Strategies
• Prototype System
Page 2 Chapter 3.5: Multimedia Operating Systems
Operating System Aspects
For multimedia applications not only transferring data has to be considered – also, the processing of the data on sender and receiver host has to be fast.
Operating System Aspects for Multimedia Processing
Most conventional operating systems offer only little or no support for in-time processing of continuous media. This concerns all functions of an operating system like process, memory, file or device management
1. Resource Management
How to achieve a coordinated processing of all operating system functions in order to achieve an end-to-end Quality of Service (delay, capacity, loss rate, jitter, ...)?
An abstract continuous resource model
A common resource management procedure 2. Process Management
How to schedule processes permitting each to terminate according to its deadline?
Rate Monotonic Scheduling
Earliest Deadline First
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 3 Chapter 3.5: Multimedia Operating Systems
Resource Management Tasks
1. Admission control
If a new data stream wants to start:
is there enough remaining capacity to handle the additional stream?
2. QoS calculation
Which characteristics (e.g. in terms of throughput and delay) are available for the new stream?
3. Resource reservation
Reserves the resources which are required to meet the deadlines 4. QoS enforcement
Quality of service can be (possibly) obtained by appropriate scheduling, e.g. by re- ordering tasks (serving a tasks with urgent deadlines earlier than a task with less strict bounds)
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 4 Chapter 3.5: Multimedia Operating Systems
Real-Time Systems
What means real-time?
A real-time task is a process which delivers its result in a given time or according to a given deadline. A deadline is given e.g. in the order of msec for interactive voice and video data or in the order of days for text documents.
What means the term deadline?
A deadline represents the latest acceptable timefor finishing the processing of a task.
• Deadlines are called hardif failures are mission-critical or threatening human beings.
• Deadlines are called softif they cannot exactly be determined or a violation is less critical.
Fields of application
Control systems for manufacturing processes, military systems, telecommunication systems, aircrafts, automobiles, nuclear power plants or interactive multimedia systems.
Page 5 Chapter 3.5: Multimedia Operating Systems
Classification of Real-Time Systems
real-time systems
soft real-time systems hard real-time systems high availability high integrity fail safe fail operational
telephone switching
on-line banking
railway signaling
flight control
High availability
• Down-time is minimal High integrity
• Consistency of data must survive any system failure and malicious attempt to alter the data
Fail safe
• Probability to detect any failure is close to 1
• System can be stopped in case of violation Fail operational
• Minimal service even in case of failure
• System cannot be stopped
Page 6 Chapter 3.5: Multimedia Operating Systems
Real-Time Systems
Processing Requirements
• Predictable fast response to time-critical events
• Accurate timing information
• High degree of schedulability, i.e. resource capacity is not wasted (nearly optimal scheduling; finding optimal schedules is often a NP-complete task)
• Stability under transient overload, i.e. use of buffering to cope with bursty systems Aspects specific to Multimedia Systems
• In-time processing, transmission and presentation of audio and video data Requirements are described as QoS parameters
• Throughput, local delay, global (i.e. end-to-end) delay, jitter, and reliability
• Specified by average values, worst case values, peak rates, distribution functions, and/or moments of the distribution functions
→Resource Management and Process Management for dealing with deadlines
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 7 Chapter 3.5: Multimedia Operating Systems
Resource Management
• Even sophisticated compression techniques cannot compensate resource bottlenecks
• In current (interactive) multimedia systems, capacity is necessary for audio and video transmission as well as processing power
Hardware resources in Year x Resource
Requirements
1980 1990 2000
Network File Access
“Killer Application“
Interactive Video
High-Quality Audio
insufficient scarce
abundant
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 8 Chapter 3.5: Multimedia Operating Systems
Classification of Resources
Active vs. passive resources (depending on their autonomous processing capabilities)
• Active resources: CPU, network interface card, etc
• Passive resources: file system, main memory, etc Shared vs. exclusive resource usage
• Active resource are usually allocated exclusively whereas passive ones can be shared by multiple tasks
Single vs. multiple resource occurrences
• A “normal” wortkstation for a human user usually contains only a single CPU, whereas many servers contain two or more CPUs
Page 9 Chapter 3.5: Multimedia Operating Systems
Resource Management Procedure
2. Schedulability 3. QoS Calculation Resource Manager
1. Request by a new task CPU
Resources
. .
I/O
6. Add Task
Queue
5. Calculate Schedule
7. Schedule Task 4. Reservation
4.
Dispatcher 8. Assign Resources
Steps 1 to 5: preparation of task processing Steps 6 to 8: task processing
Page 10 Chapter 3.5: Multimedia Operating Systems
Reservation Strategies
Principle
Timelines of processing no guarantee Resource utilization
overbooking possible potentially high Base for schedulability test average test
detect and resolve conflicts
Optimistic Pessimistic
avoid conflicts
maximum for peak rate load no overbooking
“guarantee”
Airline example: Northwest Airlines
Risky, lots of overbooking, solve conflicts by finding customers who leave the aircraft (by paying something in cash or – better - in terms of a voucher)
Lufthansa
very cautious airline (no overbooking, no-shows), low actual load, high prices
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 11 Chapter 3.5: Multimedia Operating Systems
Abstract Continuous Media Modeling: Workload
• Data streams consist of periodically arriving Logical Data Units (called Messages) and are described by the “Linear Bounded Arrival Process (LBAP) Model”
• A data stream is a triple (M, R, B), where
M is the maximal message size
R is the maximal message rate (i.e. the number of message per time unit)
B is the maximal burstiness or allowed workahead
• The model is named linear bound arrival process because it assumes that the number of message arrivals N in a given time interval ∆is bound by
N (∆) = R ·∆+ B (R ·∆ message arrivals in ∆time units) Interfaces
Resource
Messages Messages
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 12 Chapter 3.5: Multimedia Operating Systems
Abstract Continuous Media Modeling: Workahead
• The workahead w(t) of a LBAP at time t describes how many messages have arrived that are not yet processed. It is defined by w(t) = max {0, N( [t0, t] ) - R ⋅|t - t0|}.
• The logical arrive time l(mi) of message miis the time at which a message is effectively being scheduled. The scheduling is done by FIFO (First In, First Out). The logical arrival time then is defined by
l(mi) = ai+ w(ai) / R (= actual arrival time + delay due to workahead) l(mi+1) = max {ai+1, l(mi) + 1 / R}
where aiis the actual arrival time of message mi
t w(t)
1 2 3 4 5 6 7 8 9 10
1 2 3
a1
l(m1)
a2
l(m2) a3 a4
l(m3) l(m4)
Page 13 Chapter 3.5: Multimedia Operating Systems
Resource
Messages Messages Interfaces
Queue Server
Abstract Continuous Media Modeling: Resources
The logical delay d(m) of messages m between two interfaces I1and I2is defined by d(m) = l2(m) - l1(m)
The buffer requirements of resource for a given data stream are defined by buf = B + R·(D - U) with
B = number of messages which arrive unexpectedly due to burstiness D = maximum logical delay between input and output interfaces U = minimum (unbuffered) actual delay between the same interfaces R·(D - U) = number of messages which may be build up due to the variation
of processing times
Page 14 Chapter 3.5: Multimedia Operating Systems
Process Management
Process Management deals with the assignment of the CPU to processes/tasks. A process may be in one of five basic states:
initial, i.e. it is created, but not in schedule; process is idle
ready, i.e. it is waiting for CPU assignment
running, i.e. it is running on the CPU
waiting, i.e. it is waiting for an external event
finished
A schedulerchooses the next process to become running according to a given schedule.
The schedule determines the order of CPU assignment to processes.
• Goals of traditional scheduling
Optimal throughput, optimal resource utilization, fair queuing
• Goals of real-time scheduling
Execute maximum number of processes in time, i.e. according to their deadlines
Minimize deadline violations
in re ru fi
wa
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 15 Chapter 3.5: Multimedia Operating Systems
Classification of Real-Time Scheduling Strategies
Scheduling strategies can be distinguished by...
• static vs. dynamic schedule calculation
( static = calculation of schedule in advance
dynamic = re-calculation whenever a new task arrives)
• central vs. distributed schedule calculation
• preemptive vs. non-preemptive task processing
(preemptive = a task may be interrupted by any task with higher priority) They schedule...
• tasks with periodic or aperiodic processing requirements
• independent tasks or tasks with precedence constraints They are applied to...
• uniprocessor systems
• multiprocessor systems (neglecting communication delay)
• multicomputer systems (taking communication delay into account)
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 16 Chapter 3.5: Multimedia Operating Systems
Schedulability Tests and Optimal Schedulers
• The test to determine whether a schedule exists for a given task set is called a schedulability test
• There are three kinds of test: sufficient, exact, and necessaryones:
Sufficient test: if the test is positive, the set of tasks is schedulable. A negative result is possible even if the task set is schedulable (“cautious” test).
Necessary test: if the test is negative, the set of tasks is not schedulable. A positive result does not guarantee the schedulability of a task set (“optimistic”
test).
Exact test: if the tasks set is schedulable, it returns a positive result.
• Most exact schedulability tests belong to the class of NP-complete problems
• A scheduler is called optimal if it always finds a schedule for task sets satisfying an exact schedulability test
Page 17 Chapter 3.5: Multimedia Operating Systems
Model for a task timing constraint: (si, ei, di, pi) with
sistarting point, i.e. ready time for first period
eiprocessing time for period pi
dideadline for period pi(relative to its period’s ready time)
If a task set consisting of periodic tasks (T1, ..., Tn) is schedulable [Ti= (si, ei, di, pi)], then the processor utilization is given by
• A task is characterized by its timing constraints and its resource requirements
• Most tasks in multimedia systems are periodic and have no precedence constraints
si
period 1 period 2 period 3 period 4 pi
di ei
Model for Real-Time Tasks
(where ei/pi= relative processor utilization by task Ti)
n i i 1 i
U e
= p
=
∑
Page 18 Chapter 3.5: Multimedia Operating Systems
Preemptive vs. Non-Preemptive Scheduling
There are tasks sets that have valid preemptive schedules but no non-preemptive ones. If the cost for preemption is neglected, preemptive scheduling is always better or equal than non-preemptive scheduling.
a
a b c d e f
1 b 2
1 2
1 1 1 2 2 2
Deadline violation High-Rated Task T1
Low-Rated Task T2
Non-Preemptive Schedule
Preemptive Schedule
da db dc, d1
dd
df, d2 de Deadlines
d e f
a b d e f
p2 p1
c
c
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 19 Chapter 3.5: Multimedia Operating Systems
Rate Monotonic Algorithm
The Rate Monotonic Algorithm (RM) is a static, preemptivealgorithm for periodictasks Assumptions
• All time-critical tasks have periodic computing requirements
• Tasks are mutually independent (i.e. no precedence constraints)
• A task’s deadline equals its period (di= pi)
• A task’s maximum computing time is constant and a-priori known
• Context switches are considered timeless, i.e. preemption is assumed to come without cost (at least without time cost)
Principles
• Shortest period ⇔highest priority (i.e. tasks are ordered by decreasing period)
• Priorities are recalculated if a new task is added to the task set or a task is deleted from the task set (schedule calculation only once for a given task set)
RM is optimalamong static scheduling algorithms, i.e. if a task set is schedulable by any static algorithm then there exists a feasible RM schedule
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 20 Chapter 3.5: Multimedia Operating Systems
Rate Monotonic Algorithm - Example
• Principle of operation: high rated tasks preempt lower rated tasks
• The performance of RM depends on the arrival pattern; in the worst case (“critical instant“), every task with higher priority arrives at the same time than a lower rated task (i.e. maximum disadvantage for lower rated tasks)
Deadlines
High-Rated Task T1
Low-Rated Task T2
RM Schedule a 1 b 1 c 2 d 2
a b c d
1 2
period of T2 period of T1
da db, d1 dc dd, d2
preemption of T2 T2is resumed
Page 21 Chapter 3.5: Multimedia Operating Systems
Earliest Deadline First (EDF)
Earliest Deadline First is a dynamic, preemptivealgorithm for periodictasks Principle of operation:
• Earliest deadline ⇔highest priority
• Priorities are re-calculated each time a task becomes ready (even for an unchanged task set)
• Calculation has worst case complexity of O(n2)
a 1 b c 2 d
a b c d
1 2
da db, d1 dc dd, d2 Deadlines
High-Rated Task T1
Low-Rated Task T2
EDF Schedule
Page 22 Chapter 3.5: Multimedia Operating Systems
Comparison of EDF and RM
RM schedules require more context switches, i.e. more preemptions, than EDF:
a 1 b c 2 d
a b c d
1 2
da db, d1 dc dd, d2 Deadlines
High-Rated Task T1
Low-Rated Task T2
EDF Schedule
a 1 b 1 c 2 d 2
RM Schedule
The higher number of preemptions for RM has to be compared with the additional cost for EDF due to recalculation of schedules
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 23 Chapter 3.5: Multimedia Operating Systems
Comparison of EDF and RM
EDF is better than RM: If RM can schedule a task set then the same is valid for EDF but not vice versa
Rate monotonic vs. EDF: Processor Utilization and Deadline Violations
High-Rated
Low-Rated
EDF
Rate Monotonic Deadlines
Deadline Violations
dAnot met dCnot met
d1 d2 dA d3 d4 d5, dB d6 d7 dC
period period
0 10 20 30 40 50
A
1 2 3 4 5 6
60 70 80
7 8
B C
0 10 20 30 40 50 60 70 80
d8
0 10 20 30 40 50 60 70 80
1 2 3 4 5 6 7 8
10 20 30 40 50 60 70 80
1 A 2 A 3 AB 4 B 5 B 6 C 7 C 8 C
A A B B
C
C C
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 24 Chapter 3.5: Multimedia Operating Systems
Achievable Processor Utilization with RM
Minimum utilization for all sets of tasks (T1, ..., Tn) which are schedulable and which
“fully utilize“ the processor:
• A task set fully utilizes a processor
if the task set can be scheduled
If for a single task which is increased in processing time by ε> 0, the assignment becomes infeasible
• Example:
Given a task set (T1, T2, T3) with period piand processing time eifor each task:
p1= 3, e1= 1; p2= 4, e2= 1; p3= 5, e3= 1
It can be shown that in this case
3 2
3 ,max 3 2 1
2 1
p p
e p e e 5 1 2 1 2 1
p p
⎡ ⎤ ⎡ ⎤
= − ⋅⎢ ⎥− ⋅⎢ ⎥= − ⋅ − ⋅ =
⎢ ⎥ ⎢ ⎥
Page 25 Chapter 3.5: Multimedia Operating Systems
Achievable Processor Utilization with RM: Theorem
• A set of n independent and periodic tasks (T1, ..., Tn) can be scheduled if
• As a consequence: A lower bound for processor utilization is:
ln 2 if RM is applied
But: 1 (lower and upper bound) if EDF is applied (and deadline = end of period) For n→ this expression converges to
ln 2≈0,693
∞
1
1 2 n n
1 2 n
e e e
... n ( 2 1) p +p + +p ≤ ⋅ −
Page 26 Chapter 3.5: Multimedia Operating Systems
Achievable Processor Utilization with EDF
For EDF a much better (i.e. perfect) utilization is possible:
Mixed scheme:
• Suppose we have n periodic tasks
• Priorities given according to RM are T1, T2, ..., Tn(T1shortest period, Tn= longest period), i.e. highest priority for task 1
• Compromise:
Schedule the highest priority tasks T1, T2, ..., Tkwith RM (1 ≤k≤n)
Schedule Tk+1, Tk+2, ..., Tnwith EDF when the processor is not occupied by T1, T2, ..., Tk
1 2 n
1 2 n
e e e
... 1
p +p + +p ≤
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 27 Chapter 3.5: Multimedia Operating Systems
C3’
Mixed strategy
(Task 1 with RM, 2 and 3 with EDF)
Achievable Processor Utilization with RM and EDF
0 60
A1 A2 A3 A4 A9 A14 A20
B1 B2 B3 B4 B5
C1 C2 C3
A1 B1
C1 A2
B2 C2
A3 B3 A4
C3 A5 B4
A6 B5 A7
C4 B6
A8 C5 A9
B7 C6
A10 B8 A11
C7 B9
A12 C8 B10 A13
A14 B11
C9 A15B12
A16 C10 A17
B13 C11
A18 A19
C12 B14 B15
A20
1 1 1 47
occupation , i.e. 13 out of 60 slots remain empty 3+ + =4 5 60
C1’ C2’ C3’
i.e. only 1 out of 60 slots remains empty ,
60 59 5 2 4 1 3 occupation 1+ + =
A1 B1
C1’ A2
C1’ B2
A3 A4 A5 B3 C2’
C3’ B4 Task 1
(p1= 3, e1= 1)
Task 2 (p2 = 4, e2= 1)
Task 3 (p3= 5, e3= 1)
Task 3, new with e3= 2
RM
A6 B5
C4’ A7
C4’ B6
A8 C5’
A9 B7
C6’ A10
C6’ B8
A11 C7’
A12 B9
C8’ A13
B10 C8’
A14 B11
C9’ A15
C9’ B12
A16 C10’
A17 B13
C11’ A18
C11’ B14
A19 C12’
A20 B15
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 28 Chapter 3.5: Multimedia Operating Systems
Deadline Monotonic Algorithm
Shortest deadline firstis a static algorithm which gives higher priority to a task with shorter deadline, i.e. T1 > T2if d1 < d2
• If deadline = period →RM algorithm
• This algorithm is similar but not identical to EDF
Page 29 Chapter 3.5: Multimedia Operating Systems
Shortest (Remaining) Processing Time
In this strategy, highest priority is given to the task with
• shortest process time (if non-preemptive)
• shortest remaining time(if preemptive) Properties:
• This strategy serves the maximum number of customers
• In an overload situation and if all tasks have the same deadline then this strategy minimizes the number of deadline violations
Page 30 Chapter 3.5: Multimedia Operating Systems
Preemptive vs. Non-Preemptive
“Preemptive“ is more complicated than „non-preemptive“ but...
• increases the feasibility of scheduling (in some cases a preemptive schedule exists but no non-preemptive schedule)
• reduces the amount of priority inversion (i.e. situations where lower priority jobs are executed while higher priority jobs are waiting)
A task set with processing times eiand with request periods piis schedulable if:
In general, the resulting schedule is a preemptive one
i i
e ln 2 0.693 (if task priorities are fixed assigned)
p ≤ ≈
∑
i i
e 1 (if priorities may be dynamically adjusted, e.g. by EDF strategy) p ≤
∑
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 31 Chapter 3.5: Multimedia Operating Systems
(***)
Preemptive vs. Non-Preemptive
Schedulability for non-preemptive strategies is more complicated:
• Task Tkcan be scheduled (worst case consideration) if its deadline dksatisfies the following:
x
job of priority k arrives
higher priority jobs arrive and are served
“my service time“ (*) (**)
(***)
• Here, Tnis the highest priority task, T1is the lowest priority task (*) = own execution time
(**) = waiting time due to job found in service at arrival time
(worst case: maximum execution time of all jobs of other priority classes) (***) = execution time of all jobs of higher priority which are present at arrival time
or which arrive during the waiting time
n
j j
k k i j
i k j k 1 j
d e
d e max e e 1
p
≠ = +
⎛⎡ − ⎤ ⎞
≥ + +
∑
⋅⎜⎜⎝⎢⎢⎢ ⎥⎥⎥+ ⎟⎟⎠!
Re quirement : dk≥x
(**)
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 32 Chapter 3.5: Multimedia Operating Systems
Example for Achievable Processor Utilization
• Given a task set (T1, T2, T3) with period pi and processing time eifor each task:
p1= 3, e1= 1 ; p2= 4, e2= 1; p3= 5, e3,max= 2
T1and T2scheduled with RM, T3scheduled with EDF
Conjecture:
• Mixed scheme is nearer to the better side (namely EDF) than to the “poor” side (namely RM)
+ + = ≈
1 1 2
Utilization (mixed scheme): 0.983 98%
3 4 5
+ + = ≈7
1 1 1
Utilization (RM): 0.783 8%
3 4 5
*
3 3
e e
+ + =
1 1 2.083
Utilization (EDF): 1 = 100%, when increasing to = 2.083
3 4 5
Page 33 Chapter 3.5: Multimedia Operating Systems
Achievable Processor Utilization (here RM)
Utilization:
T1 T1
T1 T1
T2 T2 T2
T3 T3
T1 T2 T3 T1 T2 T3 T1 T2 Task T1
RM schedule Task T3 Task T2
t
The actual utilization is slightly better than the theoretical minimum:
3
1 2
actual
1 2 3
e
e e 1 1 1
U 0.783
p p p 3 4 5
= + + = + + =
1 3 theorem
U = ⋅3 ⎛⎜2 −1⎞⎟=0.78
⎝ ⎠
Page 34 Chapter 3.5: Multimedia Operating Systems
Least Laxity First (LLF)
LLF has no advantage over the EDF for uniprocessor systems. If tasks have similar laxity values, context switches can occur frequently (calculation overhead compared to EDF).
LLF might be suitable only in multiprocessor systems, i.e. when several resources are scheduled simultaneously.
s
e
s + (k-1)p t1 t erem(t1)
t2 Lk(t1)
Lk(t2)
s + (k-1) p+d
Deadline in period k
s + k ⋅p
period k
In this strategy, the task with shortest remaining laxityis scheduled first
Definition: The laxity Lk(t) of task T in period k at time tis the remaining time from t to the deadline d of task T in period k that is not necessary for processing task T:
Lk(t) = (s + (k-1) p + d) - (t + erem(t))
= (Deadline in period k) - (actual time + remaining processing time)
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 35 Chapter 3.5: Multimedia Operating Systems
Least Laxity First - Example for Two Tasks
Example with a minimum CPU time granularity of 2 (if no granularity is assumed, then two tasks with equal laxity would preempt each other continuously, i.e. “processor sharing”
would be the result)
T1 T2 T1T2T1T2 T1
t L2(T1) = 20
L2(T2) = 14 T2interrupts T1
L8(T1) = 14 L8(T2) = 14 T1interrupts T2
L10(T1) = 14 L10(T2) = 12 T2interrupts T1
T2finished T1finished ...
LLF Schedule Task T2 Task T1
Laxities do not change during execution time of a task but become smaller when a task is not served. If the laxity of a waiting task becomes smaller than that of the running task, the running task is interrupted.
10 20 30 40
d1 d2
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 36 Chapter 3.5: Multimedia Operating Systems
Scheduling Aperiodic (but Independent) Tasks
Multimedia applications comprise both, periodic and aperiodic tasks
• Periodic tasks are used for transport and processing of continuous media data whereas control or management tasks are aperiodic
• Often it is reasonable to give to periodic tasks priority over aperiodic tasks Problem
• How to schedule a task set which is composed of periodic as well as aperiodic tasks?
Idea
• One special periodic task (called server) is polling aperiodic tasks to be processed New problem
• Aperiodic tasks can only be processed when server task is scheduled, i.e. they miss their deadline if it is earlier than the next time the server is scheduled
Solution: Bandwidth preserving algorithms like
• Priority Exchange
• Deferrable Server
• Sporadic Server
Page 37 Chapter 3.5: Multimedia Operating Systems
Bandwidth Preserving Algorithms
Priority Exchange
• One periodic task Tsserves all aperiodic tasks. The server exchanges priority with a lower priority periodic task Tiif no aperiodic task is ready. The server receives its initial priority for the next period.
T1 Ts T2 ... Ti ... Tn T1´ Ts´ T2´ ... Ti´ ... Tn´
period k period k+1
T1 Ti T2 ... Ts ... Tn T1´ Ti´ T2´ ... Ts´ ... Tn´
period k period k+1
Case 2: Tshas no task to serve, changes priority with Tiand is reactivated at the time Tiwas scheduled
Case 1: Tsserves > 0 aperiodic tasks
Page 38 Chapter 3.5: Multimedia Operating Systems
Bandwidth Preserving Algorithms
Deferrable Server
• One periodic task (called deferrable server) serves all aperiodic tasks. It defers its processing time if no aperiodic task is ready but retains its priority. As soon as an aperiodic task request occurs, it either
(immediately) preempts the running task (that has a lower priority), or
resumes processing after the current task terminates
Ts
T1 T2T3T4 ... Tn
Interrupt T4or wait until T4is finished nothing to serve
aperiodic task arrival
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 39 Chapter 3.5: Multimedia Operating Systems
Bandwidth Preserving Algorithms
Sporadic server
• Tries to combine the advantages of the Priority Exchange and the Deferrable Server algorithm
• A sporadic server exchanges its priority when no aperiodic task is ready. Any spare CPU capacity, i.e. time not used by periodic tasks, is transformed into a ticket, that is given to a sporadic server, which then replenishes its initial priority. This way, the sporadic server is allowed to use any idle time of the CPU.
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 40 Chapter 3.5: Multimedia Operating Systems
Scheduling Tasks with Blocking
• The blocking of a task is caused by mutual exclusion when trying to access a critical section currently occupied by another task
• Priority Inversion Effect:
Assume a high-priority task Thwants to enter a critical section currently occupied by a low-priority task Tl. This blocked until Tlleaves the critical section. Until then, not only Tlbut all medium-priority tasks Tmhaving higher priority than Tland lower priority than Thwill be processed prior to Th. This phenomenon is called priority inversion.
critical section proc.
blocked until wait(s) signal(s)
processing
Task Th Task Tl Task Tm
Page 41 Chapter 3.5: Multimedia Operating Systems
Scheduling Tasks with Critical Sections
Several algorithms have been developed in order to avoid priority inversion, e.g.
• Priority Inheritance, or
• the Ceiling Protocol Priority Inheritance:
• A low-priority task Tlinherits the priority of a high-priority task Thif it causes the blocking of Th. Tlretains its initial priority when leaving the critical section.
Thus:
• Ready jobs between “low“ and “high“ are blocked Disadvantage:
• Lower utilization of server, possible deadline violations Advantage:
• Sequence of schedules is preserved
Page 42 Chapter 3.5: Multimedia Operating Systems
Scheduling Tasks with Critical Sections
More Problems with “standard“ priority inheritance:
• Tasks can be blocked in each critical section
• Deadlocks can occur
• Transitive blocking is possible, i.e. T3is blocked by T2that is blocked by T1 Attempt for solution of the problem (Ceiling protocol):
• Each task has two priorities:
A static one assigned by the scheduler, e.g. according to RM strategy
A dynamic one, i.e. the maximum of the static priority and the highest priority inherited
• Each semaphore has a maximum „ceiling priority“ value of all tasks that actually use it. A semaphore only can be locked by a task with a higher dynamic priority than any currently locked semaphore. (Comparable to “hierarchy of resources“ approach to deadlock avoidance.)
• Benefit: a task is only blocked once, no deadlocks and transitive blocking
• Price: restrictive locking policy (brute force method) →longer blocking delays for other tasks
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 43 Chapter 3.5: Multimedia Operating Systems
Prototype Systems - Real-Time Mach
Real-Time Mach (RT Mach) is an experimental distributed operating system for real- time applications based on ARTS (Advanced Real-Time System), both developed at Carnegie Mellon University at Pittsburgh, PA, USA.
RT Mach…
• supports multi-processor operation
• clusters n≥1 processors into a processor set
• assigns a separate run queue and scheduling strategies to each processor set
• enables an application to select the current scheduling strategy (at run-time)
RT Mach Kernel
processor set processor
scheduler strategy run queue
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 44 Chapter 3.5: Multimedia Operating Systems
Generic Scheduler Thread Dispatching Mgmt.
Processor Set Mgmt.
RM RM/DS RM/DS
FP RR
Task Scheduling in RT Mach
RT Mach offers three classes of tasks (called RT Threads):
Periodic tasks with hard deadlines
Aperiodic (sporadic) tasks with hard deadlines
Tasks with soft deadlines
Tasks are scheduled by one of the following strategies (dynamically changeable):
Rate monotonic with deferrable server (RM/DS) or sporadic server (RM/SS)
Fixed priority (FP)
Round robin (RR)
Thread dispatching management controls idle threads and aperiodic server (DS or SS).
Processor set management performs context switching, thread preemption, or processor assignment.
Page 45 Chapter 3.5: Multimedia Operating Systems
The QoS Ticket Model
• The QoS Ticket Model combines resource reservation and adaptation
• Has been implemented on RT Mach 3.0 supporting so-called Q-Threads
2. Calculation of resource allocation
QoS Manager
1. QoS Request 4. Issue Ticket
Multimedia Session
QoS Ticket
3. Resource reservation RT Mach kernel
5. Consumption Information
• QoS tickets allow users to specify tolerance ranges for period and computation time
• A ticket is issued for each session comprising several threads
• QoS parameters are adapted dynamically based on the current resource consumption
Page 46 Chapter 3.5: Multimedia Operating Systems
Comparison of RT-Threads and Q-Threads
continuous-media processing real-time processing
Purpose
guaranteed, within the available computation time none (possible with CPU
reservation) Guarantee of
execution
dynamic, within range, based on QoS control policy fixed (can be re-specified)
Invocation period
ranges for period and computation time fixed invocation period
Thread attributes
user-defined entry point is called periodically Invocation time
Q-Thread Periodic RT-Thread
Lehrstuhl für Informatik 4
Kommunikation und verteilte Systeme
Page 47 Chapter 3.5: Multimedia Operating Systems
Conclusions
Multimedia Applications need lots of protocols to work:
• Control protocols like H.323 or SIP for session management and coordination
• Transfer protocols like RTP/RTCP for data transfer Transferring multimedia data streams is not trivial:
• Quality of Service and resource management – QoS Negotiation, Admission Control, Traffic Shaping, Scheduling, Error Control
• Synchronization aspects
• Operating system aspects for processing multimedia data