Thread synchronisation in real-time audio processing with RCU (Read-Copy-Update) - Timur Doumler ADC

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • audio.dev/ -- @audiodevcon
    Thread synchronisation in real-time audio processing with RCU (Read-Copy-Update) - Timur Doumler - ADC22
    When developing real-time audio processing applications in C++, the following problem arises almost inevitably: how can we share data between the real-time audio thread and the other threads (such as a GUI thread) in a way that is real-time safe? How can we synchronise reads and writes to C++ objects across threads, and manage the lifetime of these objects, while remaining wait-free on the real-time thread?
    In certain cases, we can store the objects inside a std::atomic or use techniques such as lock-free FIFOs, spinlocks, and double buffering. However, typically in the generic case of reading the value of a sufficiently large, persistent object on the real-time thread that is simultaneously mutated on another thread, none of these are applicable. What do we do then? How do we avoid memory leaks while ensuring that the real-time audio thread won't end up blocking, performing deallocations, or reading an object that has already been deleted from under it?
    One possibility is to use atomic_shared_ptr, but correct and lock-free implementations are hard to come by. And even if you have such an implementation, this approach typically suffers from slow performance, has poor portability across platforms, and introduces even more complexity. Is there an alternative solution?
    If we look beyond the audio industry, it turns out there is actually another strategy that solves this problem quite elegantly: RCU (Read-Copy-Update). RCU has been successfully used in the Linux kernel for two decades. More recently, it has been adapted for user space applications as well. There is even a proposal to add RCU to the C++ standard library.
    In this talk, we take a detailed look at the RCU (Read-Copy-Update) mechanism. We discuss how it works, what the tradeoffs and design choices are, and how to adapt the algorithm for a real-time audio context.
    Slides: link will be updated when available.
    _
    Timur Doumler
    Timur Doumler is C++ Developer Advocate at JetBrains and an active member of the ISO C++ standard committee. As a developer, he worked many years in the audio and music technology industry and co-founded the music tech startup Cradle. Timur is passionate about building inclusive communities, clean code, good tools, low latency, and the evolution of the C++ language.
    --
    Streamed & Edited by Digital Medium Ltd - online.digital-medium.co.uk
    _
    Organized and produced by JUCE: juce.com/
    _
    Special thanks to the ADC22 Team:
    Lina Berzinskas
    Sophie Carus
    Derek Heimlich
    Andrew Kirk
    Bobby Lombardi
    Tom Poole
    Ralph Richbourg
    Jim Roper
    Jonathan Roper
    #audiodevcon #audiodev #audioprogramming

КОМЕНТАРІ • 2

  • @10e999
    @10e999 Рік тому

    Really good talk.
    The example was well chosen and the progression, from simple atomic to coeff was great at explaining the problem clearly.
    I'm looking forward to seeing the benchmark!

  • @mykeul49
    @mykeul49 Рік тому

    Great talk, as usual.
    Where could we find the slides please ?