Condition variable question
C / C++ / MFC
10
Posts
3
Posters
0
Views
1
Watching
-
Try to write a small program.almost forgot task sync concept, need some help. task1: if (cx == True) { do task1(); cx = False; } task2: if (cx == False) { do task2(); cx = True; } Is possible the 2 tasks step in a deadlock situation? Thanks
-
Yes; see Thread Synchronization for Beginners[^].
-
Because they are both using the same variable without checking that it is free to update. Follow the link in my response and read about thread synchronisation.
-
Sure, the code is embedded software code, no OS, so, do you think there is a better way to implement the condition variable?