developing embedded software for a dual-core mcu that is ARM Cortex-M where each core runs separate

I am developing embedded software for a dual-core microcontroller that is ARM Cortex-M where each core runs a separate thread. ~Thread 1 (Comms): Handles communication and triggers an event system that calls a callback function. ~Thread 2 (Compute): Focuses on heavy computations and actively uses a specific data object. But the callback function modifies the same data object that Thread 2 is using, causing the callback to hang indefinitely and stall the Comms thread. So Why might the callback function invoked by Thread 1 never return if it tries to modify data currently being used by Thread 2's computations? Please Devs, l really need you guyz help on this 🙏
4 Replies
Marvee Amasi
Marvee Amasi6mo ago
There is no proper synchronization here @UC GEE as you are accessing the same data object from different threads simultaneously
Marvee Amasi
Marvee Amasi6mo ago
Your thread 1 modifies the data object yh, thread 2 is also using it. You won't be able to predict it's behavior, including the callback function hanging indefinitely. When thread 1 tries to modify the data, it might find the data in an inconsistent state due to modifications by thread 2. The callback now will start to loop indefinitely, waiting for a certain state that might never stil come
Marvee Amasi
Marvee Amasi6mo ago
Try synchronization mechanism like a mutex or lock so that one thread can access the data objeect one at a time
UC GEE
UC GEE6mo ago
Thanks @Marvee Amasi for your awesome information. I will put this your educative point into practice.
Want results from more Discord servers?
Add your server