A practical guide to implementing safe, low-overhead inter-process communication on bare-metal embedded systems using a double-buffering variant called the 'Revolving Fireplace.' The pattern enables an ISR (Speedy, running at 10kHz) and a non-real-time main loop (Poky) to exchange data without mutexes or blocking. Two concrete C implementations are presented: one where Poky switches the shared memory buffers, and one where Speedy handles the switch on request. The article also covers the atomicity and volatile requirements needed to make the mechanism correct, including a deep dive into C11 stdatomic.h, GCC builtins, and inline assembly alternatives for compilers lacking C11 support. Testing strategies using guard variables and a linear congruential generator for reproducible ADC mock data are also discussed.

39m read timeFrom embeddedrelated.com
Post cover image
Table of contents
Speedy and PokyBlocking and Non-Blocking ConcurrencyThe Revolving FireplaceAtomic and volatile: Another Visit to the BasementRevolving Fireplace, Example 1Revolving Fireplace, Example 2A Few Other NotesWrapup
1 Impression