I have 2 global variables var1 and var2. I init them to 0 at the beginning. Then i start two threads t0 and t1 and to synchronize their execution on t0 i am incrementing var2 and waiting for var1 to become 10 and on t1 i am incrementing var1 and waiting for var2 to become 10 .. Since both t0 and t1 are incrementing var1 and var2 while waiting for the other to become 10 ...
What i have noticed is that for t0 var1 is always 0 and for t1 var2 is always 0 so they wait on each other forever...
Does anyone have an idea why?
I start both threads t0 and t1 at the same time...t0 is running on core 0 and t1 is runnning on core 1 in a multiprocessor setup..
I tried to print values var1 and var2 at different intervals .. i always find t0 sees var1 =0 and t1 finds var2=0...
thanks
What i have noticed is that for t0 var1 is always 0 and for t1 var2 is always 0 so they wait on each other forever...
Does anyone have an idea why?
I start both threads t0 and t1 at the same time...t0 is running on core 0 and t1 is runnning on core 1 in a multiprocessor setup..
I tried to print values var1 and var2 at different intervals .. i always find t0 sees var1 =0 and t1 finds var2=0...
thanks