SIES 2010
                  July 9th, Trento, Italy

  An Exception Based Approach to
   Timing Constraints Violations in
...
Summary

Table of Contents
   Introduction and motivation

   Proposed solution

   Experimental results

   Future wo...
Introduction and motivation




Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy   3/29
Introduction

Traditional (hard) real-time development
   Violations of timing constraints not deemed as acceptable
    ...
Introduction

Soft real-time development
   Timing violations:
       might occur at run-time
        –   WCET based on ...
Problem presentation

How to deal with timing constraints violations ?
   Common paradigms
       Continue computations ...
Sample scenario

Periodic task
Deadline constraint
 On overall task activation
WCET constraint
 On overall task activati...
Sample scenario

Periodic task
Deadline constraint
 On overall task activation
WCET constraint
 On overall task activati...
Sample scenario

Periodic task
Deadline constraint
 On overall task activation
WCET constraint
 On overall task activati...
Proposed solution




Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy   10/29
Our proposal

We propose
 To use the well-known exception-handling paradigm
 For dealing with timing constraints violati...
Problems with
                       Exception Handling
Exception handling
 Common paradigm in dealing with occasional fa...
Our proposal

Use a library for exceptions in C
 Originally written by Alessandro Evangelista
 Embedded within the Open ...
Background on OML

Objectives of OML
   Explore extensive use of C macros for providing generic
    (template-like) reusa...
OML Exceptions Example

Example                                                        Declare a new type of
             ...
Extensions to OML
New exception types                                                exception
                           ...
Implementation details

Mechanism builds on standard POSIX calls
 Timer management
 Signal handling
 setjmp/longjmp
Imp...
Benchmarking mode

Painful question
   How to properly set-up WCET and/or deadlines, at first
    executions of the appli...
Devil is in the details

Troublesome issues
   On Linux
       Absolute-time timers fire with a high precision, thanks t...
Case study
                   mplayer on Linux




Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Ita...
Case study

Proposed technique applied to
   Frame dropping in the popular mplayer for Linux
mplayer original heuristic
...
Modified mplayer-dlex

Reworked exception-based heuristic
 Use a try_within_rel() block around decoder
 Set decoding dea...
Experimental results

Unloaded system: similar A/V delay and InterFrame Times




     Tommaso Cucinotta – ReTiS Lab – Scu...
Experimental results

Loaded system: -30% avg(A/V delay); -10% max(A/V delay);




     Tommaso Cucinotta – ReTiS Lab – Sc...
Conclusions and Future Work




Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy   25/29
Conclusions

We proposed
   An exception-based management of timing constraints
       For embedded real-time applicatio...
Future Work

Mechanism level
   Improving exception handling latency for WCET violation
       Requires to post addition...
Related Work

Asynchronous Transfer of Control (ATC)
 Present in common programming languages, e.g. Ada, Java, C

Deadlin...
Thanks for your attention!




                        Questions ?




Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sa...
Upcoming SlideShare
Loading in …5
×

An Exception Based Approach to Timing Constraints Violations in Real-Time and Multimedia Applications

613 views
562 views

Published on

In this paper, an exception-based programming
paradigm is envisioned to deal with timing constraints violations occurring in soft real-time and multimedia applications written in the C language. In order to prove viability of the approach, a mechanism allowing to use such paradigm has been designed and implemented as an open-source library of C macros making use of the standard POSIX API (a few Linux-specific optimizations are also briefly discussed).
The envisioned approach has been validated by modifying mplayer, one of the most widely used multimedia player for Linux, so as to use the introduced library. Experimental results demonstrate how the exception-based paradigm is effective in improving the audio/video delay exhibited by the player.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
613
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

An Exception Based Approach to Timing Constraints Violations in Real-Time and Multimedia Applications

  1. 1. SIES 2010 July 9th, Trento, Italy An Exception Based Approach to Timing Constraints Violations in Real-Time and Multimedia Applications Tommaso Cucinotta, Dario Faggioli Real-Time Systems Laboratory Scuola Superiore Sant'Anna Pisa, Italy Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 1/29
  2. 2. Summary Table of Contents  Introduction and motivation  Proposed solution  Experimental results  Future work Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 2/29
  3. 3. Introduction and motivation Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 3/29
  4. 4. Introduction Traditional (hard) real-time development  Violations of timing constraints not deemed as acceptable  would cause complete system failure, or life losses  Use of proper methodologies  WCET estimation  static code analysis  use of a Hard Real-Time OS  conservative admission control and schedulability tests  Common verifiable assumptions  No task will run for more than its declared WCET – Similar for blocking times, critical section lengths, …  All jobs of all tasks will respect their deadlines Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 4/29
  5. 5. Introduction Soft real-time development  Timing violations:  might occur at run-time – WCET based on benchmarks, but run-time conditions may be different – Use of a General-Purpose OS (for real-time, distributed, embedded apps) – Very complex software infrastructures preclude possibility of analysis – Resource sharing and synchronisation not exactly how modelled  they are foreseen by the programs and compensated – e.g., in multimedia, frame skipping – e.g., in control applications, feedback loops adjusting the Quality of Control depending on the dynamic requirements of applications or controller, or on availability of resources at run-time  lead to QoS degradation Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 5/29
  6. 6. Problem presentation How to deal with timing constraints violations ?  Common paradigms  Continue computations till the end, then compensate  Abort current computations (e.g., killing the faulty thread)  Triggering recovery logic (e.g., notify faulty thread by signal)  A mix of these techniques  Custom application-level logic Timing constraints violations  Expected to happen quite rarely, under proper design  Code development should  mainly focus on “normal” path of execution  foresee proper recovery logic – also in case of timing constraints violations Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 6/29
  7. 7. Sample scenario Periodic task Deadline constraint  On overall task activation WCET constraint  On overall task activation Component-based design  Leverage WCET estimations at the subcomponent level  Multiple timing constraints in place at the same time  Violations may occur at different levels Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 7/29
  8. 8. Sample scenario Periodic task Deadline constraint  On overall task activation WCET constraint  On overall task activation Component-based design  Leverage WCET estimations at the subcomponent level  Multiple timing constraints in place at the same time  Violations may occur at different levels Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 8/29
  9. 9. Sample scenario Periodic task Deadline constraint  On overall task activation WCET constraint  On overall task activation Component-based design  Leverage WCET estimations at the subcomponent level  Multiple timing constraints in place at the same time  Violations may occur at different levels Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 9/29
  10. 10. Proposed solution Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 10/29
  11. 11. Our proposal We propose  To use the well-known exception-handling paradigm  For dealing with timing constraints violations  Confining the recovery logic in proper exception handlers Example (pseudo-C) Acquire Acquire try (within 10 ms) { AcquireImage(); PreProcess Acquire Deadline PreProcess Acquire Expired PreProcessImage(); ComputePosition(); ComputePos ComputePos Interpolate Interpolate } catch (EDeadline) { InterpolatePosition(); } … … Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 11/29
  12. 12. Problems with Exception Handling Exception handling  Common paradigm in dealing with occasional faults  Focus on main error-free path  Clearly delineate code sections dealing with error conditions occurring rarely  Widely used in high-level languages (e.g., Java, C++)  Absent from the C language  One of the most widely used language for embedded applications Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 12/29
  13. 13. Our proposal Use a library for exceptions in C  Originally written by Alessandro Evangelista  Embedded within the Open Macro Library (OML) project  http://oml.sourceforge.net  Provides macro-oriented reusable functionality OML was extended with new macros  Timing constraints coded as special try blocks  Violations coded as special types of exception  Violation recovery logic coded as OML exception handler Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 13/29
  14. 14. Background on OML Objectives of OML  Explore extensive use of C macros for providing generic (template-like) reusable utilities  logging and debugging  collections (vector, list, queue, hash table, map, heap)  synchronisation  exceptions  etc.  Exploit standard C macro constructs plus commonly used extensions (e.g., variadic macros)  Extensible exceptions hierarchy Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 14/29
  15. 15. OML Exceptions Example Example Declare a new type of exception extending the base EException type #include <oml_exceptions/oml_exceptions.h> define_exception(ENotReady) extends(EException); Begin of a try block try { Begin of handlers list f(); } handle Handler for specific when (ENotReady) { ENotReady exception printf("Not Ready Exception !n"); } when (EException) { printf("General Exception !n"); Handler for generic type of } exception end; End of handlers list and of try block Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 15/29
  16. 16. Extensions to OML New exception types exception exception  exception  ex_time_constr_violation ex_time_constr_violation ex_time_constr_violation – ex_deadline_violation – ex_wcet_violation ex_deadline_violation ex_deadline_violation ex_wcet_violation ex_wcet_violation New macros  Begin a deadline-constrained block  try_within_abs(deadline_ts)  try_within_rel(deadline_ts)  Begin a WCET-constrained block  try_within_wcet  Atomic blocks, non-interruptible by asynchronous exceptions  try_within_disable  try_within_enable Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 16/29
  17. 17. Implementation details Mechanism builds on standard POSIX calls  Timer management  Signal handling  setjmp/longjmp Implementation  try() blocks  perform a setjmp()  post of signal delivery in the future – Deadline: use CLOCK_MONOTONIC – WCET: use CLOCK_THREAD_CPUTIME_ID  signal handler performs a longjmp()  handle … when() blocks  properly coded if() walking up the exceptions hierarchy Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 17/29
  18. 18. Benchmarking mode Painful question  How to properly set-up WCET and/or deadlines, at first executions of the application ? Solution  Benchmarking mode  may be enabled at compile-time defining a symbol  try() blocks do not enforce any timing constraint, but they actually log the absolute time and thread execution time Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 18/29
  19. 19. Devil is in the details Troublesome issues  On Linux  Absolute-time timers fire with a high precision, thanks to the high-resolution timers now built into the kernel – Deadline constraint violation notified with low latencies ~ 1 usec.  Per-thread timers fire at HZ boundaries (simplifying) – WCET violation notified with latencies largely influenced by HZ use high HZ=1000 for highest precision ~ 400 usec.  Future work: make WCET violations precise  No per-thread signal delivery system call in POSIX  Additional signal-specific thread required → higher overhead  Linux has a specific extension allowing thread-level signal delivery → lower overhead (its use may be enabled at compile-time)  Nesting-based matching of exceptions with handlers Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 19/29
  20. 20. Case study mplayer on Linux Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 20/29
  21. 21. Case study Proposed technique applied to  Frame dropping in the popular mplayer for Linux mplayer original heuristic  Keep the A/V delay under control, ideally below 100 ms  Drop as few frames as possible; avoid bursts of drops  The drop/no-drop decision is taken in advance, so the preventive decision might have been mistaken  If decoded, the dropped frame might not have exhibited a so high decoding time  A decoded frame might exhibit a far higher computation time than expected, leading to large A/V de-synchronisations Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 21/29
  22. 22. Modified mplayer-dlex Reworked exception-based heuristic  Use a try_within_rel() block around decoder  Set decoding deadline to:  current audio-frame pts + maximum tolerable A/V delay  Whenever decoder takes too much, it is aborted Pay attention  We never drop key frames Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 22/29
  23. 23. Experimental results Unloaded system: similar A/V delay and InterFrame Times Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 23/29
  24. 24. Experimental results Loaded system: -30% avg(A/V delay); -10% max(A/V delay); Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 24/29
  25. 25. Conclusions and Future Work Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 25/29
  26. 26. Conclusions We proposed  An exception-based management of timing constraints  For embedded real-time applications We provided  A full implementation of the framework in form of an open-source library of macros for the C language  Implementation relies on POSIX timers, signals and longjmp() We validated the approach  Modifying mplayer, an open-source multimedia player  We measured deadline miss rates and inter-frame times under various load conditions Experimental results show that  The more the system is loaded, the more the benefits Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 26/29
  27. 27. Future Work Mechanism level  Improving exception handling latency for WCET violation  Requires to post additional timers into the kernel (working on it)  Improving exception-handling syntax  It might be made more C friendly – causing more meaningful error messages on incorrect use of macros Application level  Experiment with applying the technique to other scenarios  Control applications  Anytime computing algorithms Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 27/29
  28. 28. Related Work Asynchronous Transfer of Control (ATC)  Present in common programming languages, e.g. Ada, Java, C Deadline instruction concept (hardware extension)  B. Lickly, I. Liu, S. Kim, H. D. Patel, S. A. Edwards, E. A. Lee Predictable programming on a precision timed architecture CASES 2008, Atlanta, Georgia, US, October 2008, pp. 137–146 Contribution of the paper  To provide a framework for the C language, built on top of POSIX, allowing for handling arbitrarily nestable time-constraints violations as exceptions Preliminary paper of ours on the topic  Cucinotta, T., Faggioli, D., Evangelista, A. Exception-Based Management of Timing Constraints Violations for Soft Real-Time Applications OSPERT 2009, Dublin, Ireland, June 2009 Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 28/29
  29. 29. Thanks for your attention! Questions ? Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 29/29

×