previous | start | next

Mutual Exclusion

Consider that 2 threads might execute this statement where the initial value of x is 5 and y is 10

x = x + y;

Assembler instructions could be:

movl   x, %ebx
addl   y, %ebx
movl   %ebx, x
   

The final value in x should/can be what after the 2 threads execute? Is it 25?



previous | start | next