AnsweredAssumed Answered

Avoid race conditions with global struct and ISR

Question asked by vix on Apr 22, 2016
Latest reply on May 17, 2016 by Kader.M
  • VDK application developed with VDSP++ 5.1.2 for BF527
  • I have a global struct which handles the status (High/Low) of every INPUT pin of my board
  • A timer ISR periodically reads the status of the pins calling adi_flag_Sense() and updates the fields of the global struct
  • Some other threads read the fields of the struct and decide what to do based on their vale

 

I need to protect my code from race conditions (i.e. the ISR writes the struct while other threads have been reading the values of the fields).

I use mutexes to protect hardware resources from concurrent access, but it's not allowed to call GetMutex() inside an ISR.

 

Which is the recommended approach for this situation?

Outcomes