Whenever you're ready, walk me through how you'd approach this.
How do you handle race conditions in an embedded multi-threaded environment? Explain how you identify shared mutable state, select synchronization primitives, and ensure memory visibility between threads and interrupt handlers. Include the trade-offs involving mutexes, atomics, interrupt context, priority inversion, and real-time latency.