Defects of the POSIX Sporadic Server and How to Correct Them

45
1 Defects of the POSIX Sporadic Server and How to Correct Them Mark Stanovich Theodore Baker An-I Wang Florida State University, USA Michael González Harbour Universidad de Cantabria, Spain

Transcript of Defects of the POSIX Sporadic Server and How to Correct Them

Page 1: Defects of the POSIX Sporadic Server and How to Correct Them

1

Defects of the POSIX Sporadic Server and How to Correct Them

Mark StanovichTheodore Baker

An-I WangFlorida State University, USA

Michael González

HarbourUniversidad de Cantabria, Spain

Page 2: Defects of the POSIX Sporadic Server and How to Correct Them

2

Overview

POSIX specification broken–

Budget amplification (accounting error)•

Interference can grow over time

Premature replenishment•

Invalidates sliding window budget constraint

Incomplete temporal isolation•

No way to limit low priority execution

Page 3: Defects of the POSIX Sporadic Server and How to Correct Them

3

Motivation•

Sporadic server (SS) is well known1

Many uses–

Bounds interference for other tasks

Service device drivers–

Composable

systems

Only POSIX policy that limits CPU time•

Alternatives (CBS, TBS, …)–

Not for fixed-priority systems

1

Sprunt, Sha, and Lehoczky. Aperiodic

task scheduling for hard real-time systems.

Page 4: Defects of the POSIX Sporadic Server and How to Correct Them

4

Sporadic Server

Used to service aperiodic

jobs in fixed-priority task scheduling

Interference like a periodic task–

Period = replenishment period

Execution time = initial budget•

Average response time < polling server

Interference < deferrable server

Page 5: Defects of the POSIX Sporadic Server and How to Correct Them

5

Replenishment Policy

replenishment period

replenishment

initial budget

time

activation time(work available for server)

Page 6: Defects of the POSIX Sporadic Server and How to Correct Them

6

Bandwidth Preservation

replenishment periodreplenishment

initial budget

time

activation time(work available for server)

Page 7: Defects of the POSIX Sporadic Server and How to Correct Them

7

SCHED_SPORADIC

POSIX variant–

Conceptually similar to Sprunt

SS

Differences–

Allows overruns

Max execution ≤

available budget + clock resolution–

Maximum number of pending replenishments

Background priority

Page 8: Defects of the POSIX Sporadic Server and How to Correct Them

8

Differences Break Model

Budget amplification•

Premature replenishment

Incomplete temporal isolation

Page 9: Defects of the POSIX Sporadic Server and How to Correct Them

9

Budget Amplification

Accounting error–

Overruns not alwayscharged to the server

Max execution ≤

server budget + clock res.•

“if the available execution capacity would become negative...it shall be set to zero”

Page 10: Defects of the POSIX Sporadic Server and How to Correct Them

10

Budget Amplification

Page 11: Defects of the POSIX Sporadic Server and How to Correct Them

Is this a problem in real systems?

Page 12: Defects of the POSIX Sporadic Server and How to Correct Them

12

Budget Amplification Experiment

Linux sporadic server implementation–

Replenishment period = 10 msec

Budget = 1 msec•

Budget breaks into 2-8 chunks

Page 13: Defects of the POSIX Sporadic Server and How to Correct Them

13

Page 14: Defects of the POSIX Sporadic Server and How to Correct Them

14

How likely is this?

Simulate large number of cases•

Exponential workload distribution–

Mean job execution time = 10

Various mean interarrival

times•

Server–

Replenishment period = 120

Budget = 40•

Job overruns = 1 time unit

Maximum utilization = 34%120

140

Page 15: Defects of the POSIX Sporadic Server and How to Correct Them

15

Page 16: Defects of the POSIX Sporadic Server and How to Correct Them

16

Solutions

Just allow negative available capacity?–

But overruns can still occur every period

Our solution–

Think of overrun as time received early

Charge against future replenishments

Page 17: Defects of the POSIX Sporadic Server and How to Correct Them

17

Page 18: Defects of the POSIX Sporadic Server and How to Correct Them

18

Premature Replenishment

Illegal merging of chunks–

Violates minimum offset

Exceeds sliding window budget constraint

Single activation timeis oversimplification

Page 19: Defects of the POSIX Sporadic Server and How to Correct Them

19

Premature Replenishment

Page 20: Defects of the POSIX Sporadic Server and How to Correct Them

20

Premature Replenishment Simulation Experiment

Two tasks–

Sporadic server

Replenishment period = 100•

Budget = 42

Higher priority periodic task•

Period = 141

Execution time specified by x-axis

Intuition–

Longer preemption period can trigger illegal merging of time chunks

Page 21: Defects of the POSIX Sporadic Server and How to Correct Them

21

Page 22: Defects of the POSIX Sporadic Server and How to Correct Them

22

Is this likely?

Difficult to demonstrate on random arrivals and execution times

Effect does not occur often enough to be measured on a macroscopic scale

This anomaly would probably be only a concern in a hard real-time environment

Page 23: Defects of the POSIX Sporadic Server and How to Correct Them

23

Solutions

Maintain all replenishments separately?–

Unbounded fragmentation

Merging chunks essential–

Limits fragmentation

Must not merge illegally–

Preserve additional activation times

Page 24: Defects of the POSIX Sporadic Server and How to Correct Them

24

Premature Replenishment

Page 25: Defects of the POSIX Sporadic Server and How to Correct Them

25

Page 26: Defects of the POSIX Sporadic Server and How to Correct Them

26

Lessons Learned

Transforming a theoretical algorithm into an implementation is not trivial

Practical considerations–

Overruns

Maximum number of replenishments–

Page 27: Defects of the POSIX Sporadic Server and How to Correct Them

27

Lessons Learned

Implementation deviation from theoretical model invalidates schedulabilty

analysis

Analysis must be extended to match implementable reality

Implementation must be analyzable

Page 28: Defects of the POSIX Sporadic Server and How to Correct Them

28

Conclusion

POSIX formulation of SS broken•

Provided possible corrections

Need a standard scheduling policy that enforces time budgets

API for SCHED_SPORADIC with correct semantics can serve the purpose

Page 29: Defects of the POSIX Sporadic Server and How to Correct Them

Thank You!

Questions?

Page 30: Defects of the POSIX Sporadic Server and How to Correct Them

30

Defect #3: Incomplete Temporal Isolation

With temporal isolation a failure in one task does not prevent others from meeting their timing constraints

Problem: Execution at low priority–

Still preempts non-”real-time”

work

Page 31: Defects of the POSIX Sporadic Server and How to Correct Them

31

Unreliable Temporal Isolation

SCHED_FIFOSCHED_RR

SCHED_SPORADIC

SCHED_OTHER

Highest Priority

Lowest Priority

Page 32: Defects of the POSIX Sporadic Server and How to Correct Them

32

Unreliable Temporal Isolation

No upper bound on execution time consumed by SCHED_SPORADIC task

Even though SCHED_OTHER tasks are not RT, should allow a mechanism to isolate from overruns of SCHED_SPORADIC threads

Page 33: Defects of the POSIX Sporadic Server and How to Correct Them

33

Unreliable Temporal Isolation

Some remedies–

Background execution of SCHED_SPORADIC

Only use idle time–

Interleave with non-real-time priorities

Never execute at background priority•

Utilize numeric priority to specify functionality

Page 34: Defects of the POSIX Sporadic Server and How to Correct Them

34

SolutionHighest Priority

Lowest Priority

Idle

No execute

SCHED_OTHER

SC

HE

D_S

PO

RA

DIC

(background priority)SCHED_FIFOSCHED_RR

SCHED_SPORADIC (high priority)

Page 35: Defects of the POSIX Sporadic Server and How to Correct Them

Sprunt

Defect

Page 36: Defects of the POSIX Sporadic Server and How to Correct Them

36

Overview

Aperiodic

Tasks–

Arrivals and executions are generally considered random

No bound on the CPU runtime–

Typically scheduled with a server thread to bound CPU consumption and ease analysis

Page 37: Defects of the POSIX Sporadic Server and How to Correct Them

37

Aperiodic

Server•

Given a budget which it consumes while executing aperiodic

jobs

Budget is replenished according to the server's rules

Typically the server's impact is analyzed by some equivalent periodic task

Examples of fixed-priority servers–

Polling Server

Deferrable Server–

Sporadic Server

Page 38: Defects of the POSIX Sporadic Server and How to Correct Them

38

Polling Server

server budget

Ts

time

replenishment

job arrival

Server activations every period (Ts

)

ti+1

– ti

= Ts

Page 39: Defects of the POSIX Sporadic Server and How to Correct Them

39

Primitive Sporadic Server

server budget

Ts

time

replenishment

job arrival

Server activations lower bounded by the period (Ts

)

ti+1

– ti

Ts

Page 40: Defects of the POSIX Sporadic Server and How to Correct Them

40

Sporadic Server

Parameters–

Execution budget (Cs

)–

Replenishment period (Ts

)–

Server priority

Replenishments performed in chunks–

Used execution time is replenished Ts

in the future from the server activation

Page 41: Defects of the POSIX Sporadic Server and How to Correct Them

41

POSIX•

Portable Operating System Interface [for uniX]

Standard that defines a set of services that an operating system provides to an application

Eases portability of applications from one platform to another

Widely implemented–

Linux–

Mac OS X–

OpenBSD–

FreeBSD–

…•

Some interfaces are optional (e.g. SCHED_SPORADIC)

Page 42: Defects of the POSIX Sporadic Server and How to Correct Them

42

Budget Amplification•

Occurs during overload when all budget is continuously consumed

With small enough fragments, a server can achieve an execution capacity arbitrarily close to 100%

POSIX only limits the available execution capacity to the initial budget

Overruns can happen–

Control of execution on the processor cannot be assumed to be perfect

If overruns do occur, then some fairness mechanism should be used

Page 43: Defects of the POSIX Sporadic Server and How to Correct Them

43

SCHED_SPORADIC

sched_ss_repl_period

time

replenishments

activationtime

replenishments pending limited to sched_ss_repl_max

Current budget limited to sched_ss_init_budget

sched_ss_init_budget

Page 44: Defects of the POSIX Sporadic Server and How to Correct Them

44

Evaluation

Linux implementation•

Also, simulator–

Allows reduction of “noise”

from

implementation•

Demonstrate effects and effectiveness of proposed solutions–

Budget amplification

Premature replenishment

Page 45: Defects of the POSIX Sporadic Server and How to Correct Them

45

Effects of Budget Amplification

Experiment does not reach 100% CPU utilization due to replenishments overlapping and therefore merged

Merging two chunks that exceed the initial budget must be rounded down to the initial budget

While there is a bound it still exceeds the load of an equivalent periodic task