SlideShare a Scribd company logo
1 of 42
Linux Audio Conference 2011
            May 6-8th, Maynooth




   Low-Latency Audio on Linux
by Means of Real-Time Scheduling


 Tommaso Cucinotta, Dario Faggioli, Giacomo Bagnoli
         Cucinotta,
           Real-Time Systems Lab (RETIS)
       Scuola Superiore Sant'Anna, Pisa (Italy)
Motivations and background
Problem Presentation
    General-Purpose Operating Systems
       Very effective for storing & managing multimedia contents

       Designed for
           • average-case performance

           • serving applications on a best-effort basis

       They are not the best candidate for serving real-time
        applications with tight timing constraints
           • like real-time multimedia
           • or computing with precise QoS assurance


Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 3
Possible Solutions

    Overcoming limitations of a GPOS for multimedia
       Large buffers used to compensate unpredictability
           • ==> poor real-time interactivity and no low-latency multimedia
       One-application one-system paradigm
           • For example, for low-latency real-time audio processing (jack),
             gaming, CD/DVD burning, plant control, etc...
       POSIX real-time extensions
           • Priority-based, no temporal isolation
           • Not appropriate for deploying the multitude of (soft) real-time
             applications populating the systems of tomorrow
       Linux Real-Time Throttling extension
           • Designed for limiting, not guaranteeing



Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 4
POSIX
                     Real-Time Scheduling
 Multi-queue priority-based scheduler
 Processes at same priority
       Round-Robin (SCHED_RR)
       FIFO (SCHED_FIFO)
                                                          Max RT Prio
       Sporadic Server                                         …
        (see later)
                                                                                      CPU
                                                                                      CPU
                                      Process
                                                          Min RT Prio


                                                          Non RT




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 5
Traditional RT Systems
                   (and Priority Scheduling)
    All deadlines respected as far as system behaves
    as foreseen at design time
       Traditional (C, T) task model
           • C: Worst-Case Execution Time (WCET)
           • T: Minimum inter-arrival period

    Admission Control, e.g., for RM:

                                                                              ~83.3%
   High priority
   (2, 6)                                                                     Overall
                                                                       t      Load

   Low priority
   (4, 8)
                                                                        t
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 6
Problems of
                        Priority Scheduling
    High-priority processes may indefinitely delay
    low-priority ones
       Coherent with the typical real-time/embedded scenario
           • Higher-priority processes are more important (e.g., safety critical)



                                              bad job
                                                                              ~83.3%
   High priority
   (2, 6)                                                                     Overall
                                                                       t      Load
                                                                            deadline missed
   Low priority                                                               by good job
   (4, 8)
                                                                        t
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 7
Problems of
                        Priority Scheduling
    High-priority processes may indefinitely delay
    low-priority ones
       Coherent with the typical real-time/embedded scenario
           • Higher-priority processes are more important (e.g., safety critical)
       What if processes have same importance/criticality ?
                                              bad job
                                                                              ~83.3%
   High priority
   (2, 6)                                                                     Overall
                                                                       t      Load
                                                                            deadline missed
   Low priority                                                               by good job
   (4, 8)
                                                                        t
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 8
Recently Proposed
                   Real-Time Scheduler(s)
    Features (schedulers implement)
       Temporal isolation among tasks and task groups
       Need for provisioning of reservation parameters
        (sporadic real-time task model)
           • runtime every period
           • Optional allowance to use more CPU if available (soft reservations)
       Simple admission control scheme
           • May be disabled if custom user-space policy needed
           • Optional over-subscription possibility
             with graceful, controlled management of overloads
       Priority-based, Deadline-based, mixed scheduling
       Hierarchical scheduling
           • Attach more tasks as a whole to a single reservation
           • Nesting of groups and subgroups at arbitrary levels

Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 9
Recently proposed schedulers
                   and their APIs
    AQuoSA EDF-based scheduler
    EDF RT Throttling (a.k.a., The IRMOS Scheduler)
       Parameters: runtime, period, cpu mask, tasks
           • RT priorities of real-time tasks
       cgroup-based interface
           • Problem of atomic changes to scheduling parameters
    SCHED_SPORADIC
       Parameters: runtime, period, priority, low-priority
       POSIX standard system call: sched_setscheduler()
           • Breaks binary interface & compatibility
       Alternative system call: sched_setscheduler_ex()
    SCHED_DEADLINE
       Parameters: runtime, period, flags
       system call: sched_setscheduler_ex()
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 10
Programming Paradigm
    SCHED_DEADLINE
         struct sched_param_ex sp = {
           .sched_runtime = runtime_ts;   // struct timespec
           .sched_deadline = deadline_ts; // struct timespec
           .flags = 0;
         };
         sched_setscheduler_ex(pid, SCHED_DEADLINE, &sp);
         /* Now you get runtime_ts every deadline_ts guaranteed */




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 11
Programming Paradigm
                                    IRMOS Scheduler
       Pre-requisite at run-time: mount cgroups
          mkdir /cg
          mount -t cgroup -o cpu,cpuacct cgroup /cg
       Reduce runtime for root-level tasks
          echo 200000 > /cg/cpu.rt_rt_task_runtime_us
           (root-group runtime remains at default of 950000)
       Create group, with reservation of 10ms every 100ms
            mkdir /cg/g1
            echo 100000 > /cg/g1/cpu.rt_period_us
            echo 10000 > /cg/g1/cpu.rt_runtime_us
            echo 100000 > /cg/g1/cpu.rt_task_period_us
            echo 10000 > /cg/g1/cpu.rt_task_runtime_us
       Attach task with tid=1421
          echo 1421 > /cg/g1/tasks
       Detach task
          echo 1421 > /cg/tasks
       Attach process with pid=1700
          for tid in `ls /proc/1700/task`; do echo $tid > /cg/g1/tasks; done
       Destroy group
          rmdir /cg/g1


Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore
Programming Paradigm
                   IRMOS Scheduler with AQuoSA API

    AQuoSA
         qres_params_t p = (qres_params_t) {
           .Q = 10000,
           .Q_min = 10000,
           .P = 40000,
           .flags = 0
         };
         if (qres_create_server(&params, &sid) == QOS_OK) {
           qres_attach_task(sid, 0, 0);
           /* Now we get 10ms every 40ms guaranteed */
         }



Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 13
Using resource reservations

  (and deadline-based scheduling)

in the Jack low-latency infrastructure
Our Work
    We modified Jack so as to
       Use a deadline-based real-time scheduling policy
       With automatic tuning of scheduling parameters
           • Period computed on the basis of the cycle duration/deadline
           • Budget computed through a feedback-based loop
       With minimum changes to the Jack daemon and library
       Without any change required to applications/clients
    We measured the obtained performance
       No performance drop when running alone
       Performance is kept despite other real-time workload


Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 15
Jack Periodic Cycle
    Arbitrary complex DAG of computations




                                                                               Output
        Input                                                                  driver
        driver




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 16
Jack Periodic Cycle
    Arbitrary complex DAG of computations
    All computations must complete within the cycle




                                                                               Output
        Input                                                                  driver
        driver




                                                                  t
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 17
Jack Periodic Cycle
    Arbitrary complex DAG of computations
    All computations must complete within the cycle
    Each computation belongs to a different process


                                                                               Output
        Input                                                                  driver
        driver

                                Jack Rack            JackEq
                                  GUI                 GUI


Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 18
Jack Periodic Cycle
    All client threads attached to a single reservation




                                                                               Output
        Input                  Resource Reservation
                                                                               driver
        driver

                                Jack Rack            JackEq
                                  GUI                 GUI


Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 19
Jack Periodic Cycle
    All client threads attached to a single reservation
    Budget identified by feedback-based scheduling




                               Resource Reservation


                 (Q, P)

                                       Controller

Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 20
Controller
    Percentile estimator
       Can be configured to estimate a percentile (can be 100%)
        of the observed consumed budget distribution over a
        moving window
    Additional heuristics
       Addition of a safety threshold (over-provision)
       Temporary budget boost on new client
       Temporary budget boost on xrun
           • (prevents further xrun from occurring after an xrun)




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 21
Problems
    Still we could see some xruns
       Some workload peaks cannot be foreseen
           • e.g., MPEG decoding or MIDI synthesizer




    Solution
       Use soft resource reservations
           • Tasks are allowed to run beyond budget exhaustion
           • The budget is still a minimum guarantee for the tasks
       We used the SHRUB algorithm
           • Fair redistribution of unused bandwidth to active RT tasks
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 22
Experimental Results
Testbed set-up
    Hardware
       Processor: Intel E8400 @ 3GHz
       Sound Card: Terratec EWX24/96 PCI
    Software
       Linux Kernel: 2.6.29
       RT Scheduler: POSIX and AQuoSA scheduler
       Workload: jack and rt-app
       rt-app parameters: 5ms every 40ms




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 24
Jack @ 1333 us
                       96 kHz, 128 samples




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 25
Jack @ 1333 us
                       96 kHz, 128 samples




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 26
Concluding Remarks
    Summarizing
       We tackled a challenging case-study for using
        resource reservations in Linux
       We modified Jack to use a deadline scheduler
       The critical issue was budget identification
       The performance of Jack alone doesn't get worse
       The set-up and deployment of a complex mix of real-time
        applications is simplified
           • Each one declares its own timing requirements




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 27
Future Work
    This work is far from being finished
       Better handling of budget boost for new clients
       Collaboration from clients with very dynamic workloads
           • e.g., MIDI synthesizer
       Use a more recent scheduler
       Experiment with the PREEMPT_RT version of the deadline
        scheduler
       Experiment with SMP and parallelization




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 28
Related Publications
          Hierarchical Multiprocessor CPU Reservations for the Linux
           Kernel
           F. Checconi, T. Cucinotta, D. Faggioli, G. Lipari
           OSPERT 2009, Dublin, Ireland, June 2009
          An EDF Scheduling class for the Linux kernel
           D. Faggioli, F. Checconi, M. Trimarchi, C. Scordino
           RTLWS 2009, Dresden, October 2009
          Access Control for Adaptive Reservations on Multi-User Systems
           T. Cucinotta
           RTAS 2008, St. Louis, MO, United States, April 2008
          Self-tuning Schedulers for Legacy Real-Time Applications
           T. Cucinotta, F. Checconi, L. Abeni, L. Palopoli
           EuroSys 2010, Paris, April 2010
          Respecting temporal constraints in virtualised services
           T. Cucinotta, G. Anastasi, L. Abeni
           RTSOAA 2009, Seattle, Washington, July 2009
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore
Thanks for your attention




                                    Questions?



      http://retis.sssup.it/people/tommaso

Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 30
Deadline-based Scheduling
  for Temporal Isolation
        in Linux
Deadline-based Scheduling
    Optimum for single-processor systems
       Necessary and sufficient admission control test
        for simple task model:


    Same problems of PS
       Deadlines respected as far as the WCETs are respected
       Things may go bad when
           • One or more tasks exhibit higher computation times than foreseen
           • One or more tasks behaves differently than foreseen
                – e.g., it blocks on a critical section for more than foreseen
       The task that suffers may not be the misbehaving one
    Cannot provide Temporal Isolation unless . . .
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 32
Real-time theory

    Reservation-based scheduling: (Qi, Pi)
       “Qi time units guaranteed on a CPU every Pi time units”


          (5, 9)                                                              ~88.9%
                                                                  t           Overall
                                                                              Load
          (2, 6)
                                                                  t
       Independently of how others behave
        (temporal isolation)


Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 33
Temporal Isolation

    Enforcement of temporal isolation
       Not only EDF scheduling
                                              bad job

          (5, 9)
                                                                        t
                                                                            deadline missed
                                                                              by good job
          (2, 6)
                                                                        t




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 34
Temporal Isolation

    Enforcement of temporal isolation
       Once budget exhausted, delay to next activation period
                                                                            Deadline missed
                                              bad job                         by bad job

          (5, 9)
                                                                                       t

          (2, 6)
                                                                                       t




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 35
Temporal Isolation

    Is needed despite blocks/unblocks
       Not only EDF scheduling
                                          block     unblock


          (5, 9)
                                                                    t
                                                                        deadline-miss

          (2, 6)
                                                                    t




Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 36
Temporal Isolation

    Is needed despite blocks/unblocks
       Not only EDF scheduling
                                          block     unblock


          (5, 9)
                                                                           t

          (2, 6)
                                                                           t
    See the “unblock rule” of the Constant Bandwidth
    Server (CBS, Abeni '98)

Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 37
POSIX Sporadic Server
    SCHED_SS
       Provides a form of temporal isolation
       Parameters: (Q, P, RT Priority, Low RT Priority)
       Budget exhausted => lower the priority till next recharge
       For every time interval in which the task executes, post a
        recharge of budget equal to the consumed CPU time one
        period apart 2             2       1    1

                 (2, 6)

                 current
                 budget

    SCHED_SS may be analysed using FP techniques
       Patching the standard for getting rid of the “bug”
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 38
IRMOS RT Scheduler
                    Design Goals

    Replace real-time throttling
    Tight integration in Linux kernel
         Modification to the Linux RT scheduler
    Reuse as many Linux features as
    possible
         Management of task hierarchies and
          scheduling parameters via cgroups
         POSIX compatibility and API
    Efficient for SMP
         Independent runqueues
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore
IRMOS Scheduler

          Slice the available computing power into
          reservations




  CPU 0
  CPU 1
  CPU 2
  CPU 3

Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore
Hierarchical Scheduling

                                                                               EDF
                                                                               EDF
                                          Max RT Prio
                                                …
                                                                     FP
                                                                     FP                   FP
                                                                                          FP


                                          Min RT Prio           T1
                                                                T1        T2
                                                                          T2         T3
                                                                                     T3        T4
                                                                                               T4

    Needed operations
       create & destroy reservations
       attach & detach tasks ↔ reservations
       list tasks attached to reservations (and list reservations)
       Standard operations: get & set parameters
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 41
Other Features
    Warning: features & parameters may easily grow
       Addition of parameters, such as
           • deadline
           • desired vs guaranteed runtime (for adaptive reservations)
       Set of flags for controlling variations on behaviour
           •   work conserving vs non-conserving reservations
           •   what happens at fork() time
           •   what happens on tasks death (automatic reclamation)
           •   notifications from kernel (e.g., runtime exhaustion)
       Controlled access to RT scheduling by unprivileged
        applications (e.g., per-user “quotas”)
       Monitoring (e.g., residual runtime, available bandwidth)
       Integration/interaction with power management
Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna
                                                                        © 2007 Scuola Superiore 42

More Related Content

What's hot

Real Time Systems & RTOS
Real Time Systems & RTOSReal Time Systems & RTOS
Real Time Systems & RTOSVishwa Mohan
 
Rtos concepts
Rtos conceptsRtos concepts
Rtos conceptsanishgoel
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systemsknowdiff
 
Real time operating-systems
Real time operating-systemsReal time operating-systems
Real time operating-systemskasi963
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating SystemsRohit Joshi
 
Slides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And GagneSlides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And Gagnesarankumar4445
 
Real time-system
Real time-systemReal time-system
Real time-systemysush
 
Hard versus Soft real time system
Hard versus Soft real time systemHard versus Soft real time system
Hard versus Soft real time systemKamal Acharya
 
Real-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsReal-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsAJAL A J
 
Real Time Operating Systems for Embedded Systems
Real Time Operating Systems for Embedded SystemsReal Time Operating Systems for Embedded Systems
Real Time Operating Systems for Embedded SystemsAditya Vichare
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstStefano Bragaglia
 
Components in real time systems
Components in real time systemsComponents in real time systems
Components in real time systemsSaransh Garg
 
RTOS- Real Time Operating Systems
RTOS- Real Time Operating Systems RTOS- Real Time Operating Systems
RTOS- Real Time Operating Systems Bayar shahab
 
Reference model of real time system
Reference model of real time systemReference model of real time system
Reference model of real time systemKamal Acharya
 

What's hot (20)

Real-Time Operating Systems
Real-Time Operating SystemsReal-Time Operating Systems
Real-Time Operating Systems
 
Real Time Systems & RTOS
Real Time Systems & RTOSReal Time Systems & RTOS
Real Time Systems & RTOS
 
Rtos concepts
Rtos conceptsRtos concepts
Rtos concepts
 
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time SystemsSara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
 
Real time operating-systems
Real time operating-systemsReal time operating-systems
Real time operating-systems
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
Slides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And GagneSlides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And Gagne
 
Real Time System
Real Time SystemReal Time System
Real Time System
 
RTOS
RTOSRTOS
RTOS
 
Real time-system
Real time-systemReal time-system
Real time-system
 
Hard versus Soft real time system
Hard versus Soft real time systemHard versus Soft real time system
Hard versus Soft real time system
 
Real time systems 1 and 2
Real time systems 1 and 2Real time systems 1 and 2
Real time systems 1 and 2
 
Real-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsReal-Time Scheduling Algorithms
Real-Time Scheduling Algorithms
 
Real Time Operating Systems for Embedded Systems
Real Time Operating Systems for Embedded SystemsReal Time Operating Systems for Embedded Systems
Real Time Operating Systems for Embedded Systems
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline First
 
Components in real time systems
Components in real time systemsComponents in real time systems
Components in real time systems
 
RTOS- Real Time Operating Systems
RTOS- Real Time Operating Systems RTOS- Real Time Operating Systems
RTOS- Real Time Operating Systems
 
Periodic
PeriodicPeriodic
Periodic
 
Reference model of real time system
Reference model of real time systemReference model of real time system
Reference model of real time system
 
P341 dijkstra
P341 dijkstraP341 dijkstra
P341 dijkstra
 

Viewers also liked

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 Componentstcucinotta
 
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 Applicationstcucinotta
 
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 Platformtcucinotta
 
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 Assurancetcucinotta
 
Improving Responsiveness for Virtualized Networking Under Intensive Computing...
Improving Responsiveness for Virtualized Networking Under Intensive Computing...Improving Responsiveness for Virtualized Networking Under Intensive Computing...
Improving Responsiveness for Virtualized Networking Under Intensive Computing...tcucinotta
 

Viewers also liked (6)

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
 
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
 
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
 
Real-Time API
Real-Time APIReal-Time API
Real-Time API
 
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
 
Improving Responsiveness for Virtualized Networking Under Intensive Computing...
Improving Responsiveness for Virtualized Networking Under Intensive Computing...Improving Responsiveness for Virtualized Networking Under Intensive Computing...
Improving Responsiveness for Virtualized Networking Under Intensive Computing...
 

Similar to 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 Applicationsguestbbe1c83
 
pptonrtosbychetan001-140213003314-phpapp02.pdf
pptonrtosbychetan001-140213003314-phpapp02.pdfpptonrtosbychetan001-140213003314-phpapp02.pdf
pptonrtosbychetan001-140213003314-phpapp02.pdfJaganBehera8
 
presentation on real time operating system(RTOS's)
presentation on real time operating system(RTOS's)presentation on real time operating system(RTOS's)
presentation on real time operating system(RTOS's)chetan mudenoor
 
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 Cloudstcucinotta
 
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...tcucinotta
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05Rajesh Gupta
 
Real-Time Operating Systems Real-Time Operating Systems RTOS .ppt
Real-Time Operating Systems Real-Time Operating Systems RTOS .pptReal-Time Operating Systems Real-Time Operating Systems RTOS .ppt
Real-Time Operating Systems Real-Time Operating Systems RTOS .pptlematadese670
 
Bertrand Delsart Java R T S
Bertrand Delsart Java R T SBertrand Delsart Java R T S
Bertrand Delsart Java R T Sdeimos
 
Introduction to Scheduling
Introduction to SchedulingIntroduction to Scheduling
Introduction to Schedulingpec2013
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 

Similar to Low-Latency Audio on Linux by Means of Real-Time Scheduling (20)

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
 
Rt kernel-prn
Rt kernel-prnRt kernel-prn
Rt kernel-prn
 
pptonrtosbychetan001-140213003314-phpapp02.pdf
pptonrtosbychetan001-140213003314-phpapp02.pdfpptonrtosbychetan001-140213003314-phpapp02.pdf
pptonrtosbychetan001-140213003314-phpapp02.pdf
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
presentation on real time operating system(RTOS's)
presentation on real time operating system(RTOS's)presentation on real time operating system(RTOS's)
presentation on real time operating system(RTOS's)
 
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
 
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...
 
Rtos 8051
Rtos 8051Rtos 8051
Rtos 8051
 
Event Scheduling
Event SchedulingEvent Scheduling
Event Scheduling
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
rtos.ppt
rtos.pptrtos.ppt
rtos.ppt
 
Pharos
PharosPharos
Pharos
 
Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
 
Real-Time Operating Systems Real-Time Operating Systems RTOS .ppt
Real-Time Operating Systems Real-Time Operating Systems RTOS .pptReal-Time Operating Systems Real-Time Operating Systems RTOS .ppt
Real-Time Operating Systems Real-Time Operating Systems RTOS .ppt
 
ESC UNIT 3.ppt
ESC UNIT 3.pptESC UNIT 3.ppt
ESC UNIT 3.ppt
 
Bertrand Delsart Java R T S
Bertrand Delsart Java R T SBertrand Delsart Java R T S
Bertrand Delsart Java R T S
 
Introduction to Scheduling
Introduction to SchedulingIntroduction to Scheduling
Introduction to Scheduling
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Scheduling
SchedulingScheduling
Scheduling
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Low-Latency Audio on Linux by Means of Real-Time Scheduling

  • 1. Linux Audio Conference 2011 May 6-8th, Maynooth Low-Latency Audio on Linux by Means of Real-Time Scheduling Tommaso Cucinotta, Dario Faggioli, Giacomo Bagnoli Cucinotta, Real-Time Systems Lab (RETIS) Scuola Superiore Sant'Anna, Pisa (Italy)
  • 3. Problem Presentation General-Purpose Operating Systems  Very effective for storing & managing multimedia contents  Designed for • average-case performance • serving applications on a best-effort basis  They are not the best candidate for serving real-time applications with tight timing constraints • like real-time multimedia • or computing with precise QoS assurance Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 3
  • 4. Possible Solutions Overcoming limitations of a GPOS for multimedia  Large buffers used to compensate unpredictability • ==> poor real-time interactivity and no low-latency multimedia  One-application one-system paradigm • For example, for low-latency real-time audio processing (jack), gaming, CD/DVD burning, plant control, etc...  POSIX real-time extensions • Priority-based, no temporal isolation • Not appropriate for deploying the multitude of (soft) real-time applications populating the systems of tomorrow  Linux Real-Time Throttling extension • Designed for limiting, not guaranteeing Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 4
  • 5. POSIX Real-Time Scheduling Multi-queue priority-based scheduler Processes at same priority  Round-Robin (SCHED_RR)  FIFO (SCHED_FIFO) Max RT Prio  Sporadic Server … (see later) CPU CPU Process Min RT Prio Non RT Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 5
  • 6. Traditional RT Systems (and Priority Scheduling) All deadlines respected as far as system behaves as foreseen at design time  Traditional (C, T) task model • C: Worst-Case Execution Time (WCET) • T: Minimum inter-arrival period Admission Control, e.g., for RM: ~83.3% High priority (2, 6) Overall t Load Low priority (4, 8) t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 6
  • 7. Problems of Priority Scheduling High-priority processes may indefinitely delay low-priority ones  Coherent with the typical real-time/embedded scenario • Higher-priority processes are more important (e.g., safety critical) bad job ~83.3% High priority (2, 6) Overall t Load deadline missed Low priority by good job (4, 8) t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 7
  • 8. Problems of Priority Scheduling High-priority processes may indefinitely delay low-priority ones  Coherent with the typical real-time/embedded scenario • Higher-priority processes are more important (e.g., safety critical)  What if processes have same importance/criticality ? bad job ~83.3% High priority (2, 6) Overall t Load deadline missed Low priority by good job (4, 8) t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 8
  • 9. Recently Proposed Real-Time Scheduler(s) Features (schedulers implement)  Temporal isolation among tasks and task groups  Need for provisioning of reservation parameters (sporadic real-time task model) • runtime every period • Optional allowance to use more CPU if available (soft reservations)  Simple admission control scheme • May be disabled if custom user-space policy needed • Optional over-subscription possibility with graceful, controlled management of overloads  Priority-based, Deadline-based, mixed scheduling  Hierarchical scheduling • Attach more tasks as a whole to a single reservation • Nesting of groups and subgroups at arbitrary levels Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 9
  • 10. Recently proposed schedulers and their APIs AQuoSA EDF-based scheduler EDF RT Throttling (a.k.a., The IRMOS Scheduler)  Parameters: runtime, period, cpu mask, tasks • RT priorities of real-time tasks  cgroup-based interface • Problem of atomic changes to scheduling parameters SCHED_SPORADIC  Parameters: runtime, period, priority, low-priority  POSIX standard system call: sched_setscheduler() • Breaks binary interface & compatibility  Alternative system call: sched_setscheduler_ex() SCHED_DEADLINE  Parameters: runtime, period, flags  system call: sched_setscheduler_ex() Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 10
  • 11. Programming Paradigm SCHED_DEADLINE struct sched_param_ex sp = { .sched_runtime = runtime_ts; // struct timespec .sched_deadline = deadline_ts; // struct timespec .flags = 0; }; sched_setscheduler_ex(pid, SCHED_DEADLINE, &sp); /* Now you get runtime_ts every deadline_ts guaranteed */ Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 11
  • 12. Programming Paradigm IRMOS Scheduler Pre-requisite at run-time: mount cgroups  mkdir /cg  mount -t cgroup -o cpu,cpuacct cgroup /cg Reduce runtime for root-level tasks  echo 200000 > /cg/cpu.rt_rt_task_runtime_us (root-group runtime remains at default of 950000) Create group, with reservation of 10ms every 100ms  mkdir /cg/g1  echo 100000 > /cg/g1/cpu.rt_period_us  echo 10000 > /cg/g1/cpu.rt_runtime_us  echo 100000 > /cg/g1/cpu.rt_task_period_us  echo 10000 > /cg/g1/cpu.rt_task_runtime_us Attach task with tid=1421  echo 1421 > /cg/g1/tasks Detach task  echo 1421 > /cg/tasks Attach process with pid=1700  for tid in `ls /proc/1700/task`; do echo $tid > /cg/g1/tasks; done Destroy group  rmdir /cg/g1 Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore
  • 13. Programming Paradigm IRMOS Scheduler with AQuoSA API AQuoSA qres_params_t p = (qres_params_t) { .Q = 10000, .Q_min = 10000, .P = 40000, .flags = 0 }; if (qres_create_server(&params, &sid) == QOS_OK) { qres_attach_task(sid, 0, 0); /* Now we get 10ms every 40ms guaranteed */ } Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 13
  • 14. Using resource reservations (and deadline-based scheduling) in the Jack low-latency infrastructure
  • 15. Our Work We modified Jack so as to  Use a deadline-based real-time scheduling policy  With automatic tuning of scheduling parameters • Period computed on the basis of the cycle duration/deadline • Budget computed through a feedback-based loop  With minimum changes to the Jack daemon and library  Without any change required to applications/clients We measured the obtained performance  No performance drop when running alone  Performance is kept despite other real-time workload Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 15
  • 16. Jack Periodic Cycle Arbitrary complex DAG of computations Output Input driver driver Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 16
  • 17. Jack Periodic Cycle Arbitrary complex DAG of computations All computations must complete within the cycle Output Input driver driver t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 17
  • 18. Jack Periodic Cycle Arbitrary complex DAG of computations All computations must complete within the cycle Each computation belongs to a different process Output Input driver driver Jack Rack JackEq GUI GUI Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 18
  • 19. Jack Periodic Cycle All client threads attached to a single reservation Output Input Resource Reservation driver driver Jack Rack JackEq GUI GUI Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 19
  • 20. Jack Periodic Cycle All client threads attached to a single reservation Budget identified by feedback-based scheduling Resource Reservation (Q, P) Controller Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 20
  • 21. Controller Percentile estimator  Can be configured to estimate a percentile (can be 100%) of the observed consumed budget distribution over a moving window Additional heuristics  Addition of a safety threshold (over-provision)  Temporary budget boost on new client  Temporary budget boost on xrun • (prevents further xrun from occurring after an xrun) Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 21
  • 22. Problems Still we could see some xruns  Some workload peaks cannot be foreseen • e.g., MPEG decoding or MIDI synthesizer Solution  Use soft resource reservations • Tasks are allowed to run beyond budget exhaustion • The budget is still a minimum guarantee for the tasks  We used the SHRUB algorithm • Fair redistribution of unused bandwidth to active RT tasks Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 22
  • 24. Testbed set-up Hardware  Processor: Intel E8400 @ 3GHz  Sound Card: Terratec EWX24/96 PCI Software  Linux Kernel: 2.6.29  RT Scheduler: POSIX and AQuoSA scheduler  Workload: jack and rt-app  rt-app parameters: 5ms every 40ms Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 24
  • 25. Jack @ 1333 us 96 kHz, 128 samples Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 25
  • 26. Jack @ 1333 us 96 kHz, 128 samples Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 26
  • 27. Concluding Remarks Summarizing  We tackled a challenging case-study for using resource reservations in Linux  We modified Jack to use a deadline scheduler  The critical issue was budget identification  The performance of Jack alone doesn't get worse  The set-up and deployment of a complex mix of real-time applications is simplified • Each one declares its own timing requirements Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 27
  • 28. Future Work This work is far from being finished  Better handling of budget boost for new clients  Collaboration from clients with very dynamic workloads • e.g., MIDI synthesizer  Use a more recent scheduler  Experiment with the PREEMPT_RT version of the deadline scheduler  Experiment with SMP and parallelization Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 28
  • 29. Related Publications  Hierarchical Multiprocessor CPU Reservations for the Linux Kernel F. Checconi, T. Cucinotta, D. Faggioli, G. Lipari OSPERT 2009, Dublin, Ireland, June 2009  An EDF Scheduling class for the Linux kernel D. Faggioli, F. Checconi, M. Trimarchi, C. Scordino RTLWS 2009, Dresden, October 2009  Access Control for Adaptive Reservations on Multi-User Systems T. Cucinotta RTAS 2008, St. Louis, MO, United States, April 2008  Self-tuning Schedulers for Legacy Real-Time Applications T. Cucinotta, F. Checconi, L. Abeni, L. Palopoli EuroSys 2010, Paris, April 2010  Respecting temporal constraints in virtualised services T. Cucinotta, G. Anastasi, L. Abeni RTSOAA 2009, Seattle, Washington, July 2009 Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore
  • 30. Thanks for your attention Questions? http://retis.sssup.it/people/tommaso Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 30
  • 31. Deadline-based Scheduling for Temporal Isolation in Linux
  • 32. Deadline-based Scheduling Optimum for single-processor systems  Necessary and sufficient admission control test for simple task model: Same problems of PS  Deadlines respected as far as the WCETs are respected  Things may go bad when • One or more tasks exhibit higher computation times than foreseen • One or more tasks behaves differently than foreseen – e.g., it blocks on a critical section for more than foreseen  The task that suffers may not be the misbehaving one Cannot provide Temporal Isolation unless . . . Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 32
  • 33. Real-time theory Reservation-based scheduling: (Qi, Pi)  “Qi time units guaranteed on a CPU every Pi time units” (5, 9) ~88.9% t Overall Load (2, 6) t  Independently of how others behave (temporal isolation) Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 33
  • 34. Temporal Isolation Enforcement of temporal isolation  Not only EDF scheduling bad job (5, 9) t deadline missed by good job (2, 6) t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 34
  • 35. Temporal Isolation Enforcement of temporal isolation  Once budget exhausted, delay to next activation period Deadline missed bad job by bad job (5, 9) t (2, 6) t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 35
  • 36. Temporal Isolation Is needed despite blocks/unblocks  Not only EDF scheduling block unblock (5, 9) t deadline-miss (2, 6) t Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 36
  • 37. Temporal Isolation Is needed despite blocks/unblocks  Not only EDF scheduling block unblock (5, 9) t (2, 6) t See the “unblock rule” of the Constant Bandwidth Server (CBS, Abeni '98) Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 37
  • 38. POSIX Sporadic Server SCHED_SS  Provides a form of temporal isolation  Parameters: (Q, P, RT Priority, Low RT Priority)  Budget exhausted => lower the priority till next recharge  For every time interval in which the task executes, post a recharge of budget equal to the consumed CPU time one period apart 2 2 1 1 (2, 6) current budget SCHED_SS may be analysed using FP techniques  Patching the standard for getting rid of the “bug” Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 38
  • 39. IRMOS RT Scheduler Design Goals Replace real-time throttling Tight integration in Linux kernel Modification to the Linux RT scheduler Reuse as many Linux features as possible Management of task hierarchies and scheduling parameters via cgroups POSIX compatibility and API Efficient for SMP Independent runqueues Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore
  • 40. IRMOS Scheduler Slice the available computing power into reservations CPU 0 CPU 1 CPU 2 CPU 3 Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore
  • 41. Hierarchical Scheduling EDF EDF Max RT Prio … FP FP FP FP Min RT Prio T1 T1 T2 T2 T3 T3 T4 T4 Needed operations  create & destroy reservations  attach & detach tasks ↔ reservations  list tasks attached to reservations (and list reservations)  Standard operations: get & set parameters Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 41
  • 42. Other Features Warning: features & parameters may easily grow  Addition of parameters, such as • deadline • desired vs guaranteed runtime (for adaptive reservations)  Set of flags for controlling variations on behaviour • work conserving vs non-conserving reservations • what happens at fork() time • what happens on tasks death (automatic reclamation) • notifications from kernel (e.g., runtime exhaustion)  Controlled access to RT scheduling by unprivileged applications (e.g., per-user “quotas”)  Monitoring (e.g., residual runtime, available bandwidth)  Integration/interaction with power management Tommaso Cucinotta – Real Time Systems Laboratory (ReTiS) – Scuola Superiore Sant'Anna Sant’Anna © 2007 Scuola Superiore 42