-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Hi!
First, let me thank you for this great book.
Chapter 8 of this book does a great job of introducing resource management and the problems that come with sharing.
That said, as somebody who's done a bit of multi-threaded programming on desktop, I'm a bit confused on how the kernel primitive interacts with the C11 memory model (like using atomics and memory barrier) and compiler intrinsics (like gcc's __atomic_load).
When looking at forums, I see I'm not alone with this confusion.
I believe this book could serve as an authoritative point of reference on the topic and help people bridge the gap between "desktop system programming" and "RTOS programming."
Here are some examples of questions I encountered while thinking about this topic:
When compiling with arm-none-eabi-gcc, the produced assembly will call __atomic_* functions. They are defined in the linked library libatomic. To my understanding, libatomic will implement those functions by disabling interrupts and doing some BASEPRI masking. How does this BASEPRI interact with FreeRTOS primitives?
When using _Atomic on a variable bigger than the architecture, the atomic access becomes lock-access-unlock, which is rather slower and has some implications for signal handlers.
Does that mean that I can deadlock myself using it in an ISR?
How does portMEMORY_BARRIER() interact with a function that specifies memory order like atomic_store_explicit?
Thanks for reading.