SlideShare una empresa de Scribd logo
1 de 29
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
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
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
       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
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
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
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
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
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
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 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
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
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
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
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
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
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
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
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
Case study
                   mplayer on Linux




Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy   20/29
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
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
Experimental results

Unloaded system: similar A/V delay and InterFrame Times




     Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy   23/29
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
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 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
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
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
Thanks for your attention!




                        Questions ?




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

Más contenido relacionado

Destacado

VDT Letter of Commendation
VDT Letter of CommendationVDT Letter of Commendation
VDT Letter of Commendation
Abideen Adebayo
 
Lions dr. massoff
Lions   dr. massoffLions   dr. massoff
Lions dr. massoff
John Brown
 
SLAs in Virtualized Cloud Computing Infrastructures with QoS Assurance
SLAs in Virtualized Cloud Computing Infrastructures with QoS AssuranceSLAs in Virtualized Cloud Computing Infrastructures with QoS Assurance
SLAs in Virtualized Cloud Computing Infrastructures with QoS Assurance
tcucinotta
 
Narnia review Gruppe5
Narnia review Gruppe5Narnia review Gruppe5
Narnia review Gruppe5
Erasmus+
 

Destacado (6)

VDT Letter of Commendation
VDT Letter of CommendationVDT Letter of Commendation
VDT Letter of Commendation
 
Lions dr. massoff
Lions   dr. massoffLions   dr. massoff
Lions dr. massoff
 
SLAs in Virtualized Cloud Computing Infrastructures with QoS Assurance
SLAs in Virtualized Cloud Computing Infrastructures with QoS AssuranceSLAs in Virtualized Cloud Computing Infrastructures with QoS Assurance
SLAs in Virtualized Cloud Computing Infrastructures with QoS Assurance
 
Virtualised e-Learning with Real-Time Guarantees on the IRMOS Platform
Virtualised e-Learning with Real-Time Guarantees on the IRMOS PlatformVirtualised e-Learning with Real-Time Guarantees on the IRMOS Platform
Virtualised e-Learning with Real-Time Guarantees on the IRMOS Platform
 
Job Search Simulation
Job Search SimulationJob Search Simulation
Job Search Simulation
 
Narnia review Gruppe5
Narnia review Gruppe5Narnia review Gruppe5
Narnia review Gruppe5
 

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

Research in Soft Real-Time and Virtualized Applications on Linux
Research in Soft Real-Time and Virtualized Applications on LinuxResearch in Soft Real-Time and Virtualized Applications on Linux
Research in Soft Real-Time and Virtualized Applications on Linux
tcucinotta
 
REAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEMREAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEM
prakrutijsh
 

Similar a An Exception Based Approach to Timing Constraints Violations in Real-Time and Multimedia Applications (20)

Modeling and simulation of power consumption and execution times for real-tim...
Modeling and simulation of power consumption and execution times for real-tim...Modeling and simulation of power consumption and execution times for real-tim...
Modeling and simulation of power consumption and execution times for real-tim...
 
Optimum Scalability Point for Parallelisable Real-Time Components
Optimum Scalability Point for Parallelisable Real-Time ComponentsOptimum Scalability Point for Parallelisable Real-Time Components
Optimum Scalability Point for Parallelisable Real-Time Components
 
MicroC/OS-II
MicroC/OS-IIMicroC/OS-II
MicroC/OS-II
 
The Wizard of OS: a Heartbeat for Legacy Multimedia Applications
The Wizard of OS: a Heartbeat for Legacy Multimedia ApplicationsThe Wizard of OS: a Heartbeat for Legacy Multimedia Applications
The Wizard of OS: a Heartbeat for Legacy Multimedia Applications
 
Virtual Network Functions as Real-Time Containers in Private Clouds
Virtual Network Functions as Real-Time Containers in Private CloudsVirtual Network Functions as Real-Time Containers in Private Clouds
Virtual Network Functions as Real-Time Containers in Private Clouds
 
Real-Time API
Real-Time APIReal-Time API
Real-Time API
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
 
Research in Soft Real-Time and Virtualized Applications on Linux
Research in Soft Real-Time and Virtualized Applications on LinuxResearch in Soft Real-Time and Virtualized Applications on Linux
Research in Soft Real-Time and Virtualized Applications on Linux
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
 
Mastering Real-time Linux
Mastering Real-time LinuxMastering Real-time Linux
Mastering Real-time Linux
 
Self-tuning Schedulers for Legacy Real-Time Applications
Self-tuning Schedulers for Legacy Real-Time ApplicationsSelf-tuning Schedulers for Legacy Real-Time Applications
Self-tuning Schedulers for Legacy Real-Time Applications
 
Low-Latency Audio on Linux by Means of Real-Time Scheduling
Low-Latency Audio on Linux by Means of Real-Time SchedulingLow-Latency Audio on Linux by Means of Real-Time Scheduling
Low-Latency Audio on Linux by Means of Real-Time Scheduling
 
Self-tuning Schedulers for Legacy Real-Time Applications
Self-tuning Schedulers for Legacy Real-Time ApplicationsSelf-tuning Schedulers for Legacy Real-Time Applications
Self-tuning Schedulers for Legacy Real-Time Applications
 
Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applications
 
Lab3F22.pdf
Lab3F22.pdfLab3F22.pdf
Lab3F22.pdf
 
Software development effort reduction with Co-op
Software development effort reduction with Co-opSoftware development effort reduction with Co-op
Software development effort reduction with Co-op
 
An Evaluation of Adaptive Partitioning of Real-Time Workloads on Linux
An Evaluation of Adaptive Partitioning of Real-Time Workloads on LinuxAn Evaluation of Adaptive Partitioning of Real-Time Workloads on Linux
An Evaluation of Adaptive Partitioning of Real-Time Workloads on Linux
 
Week7_ExceptionHandling.ppt
Week7_ExceptionHandling.pptWeek7_ExceptionHandling.ppt
Week7_ExceptionHandling.ppt
 
REAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEMREAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEM
 
Python for Machine Learning
Python for Machine LearningPython for Machine Learning
Python for Machine Learning
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

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

  • 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. 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. Introduction and motivation Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 3/29
  • 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. 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. 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. 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. 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. 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. Proposed solution Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 10/29
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. Case study mplayer on Linux Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 20/29
  • 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. 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. Experimental results Unloaded system: similar A/V delay and InterFrame Times Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 23/29
  • 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. Conclusions and Future Work Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 25/29
  • 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. 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. 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. Thanks for your attention! Questions ? Tommaso Cucinotta – ReTiS Lab – Scuola Superiore Sant'Anna – Pisa – Italy 29/29