I wanted to know some API which allows me to set the value of variable, for example,
set_me = TRUE
without being pre-empted.
Actually, I have two threads viz a main thread and a timer thread, which gets invoke every second. The timer thread, every tick (say 1 ms) checks 2-3 test_me variables and based upon them change the value of 2 set_me variables. This timer thread may change the value of the set_me only in 15 - 30 ms (15-30 timeth the Timer Thread gets scheduled, it changes the set_me variable). Since the timer thread gets scheduled so often, I am reluctant to use mutex here.
So, any suggestions on how should I avoid any race conditions if possible.
I thought atomic_set could be the solution but I’ve no way to test it.