White RoomNEW

Eighty One Not Eighty Two

counter starts at 80 and two threads each run counter = counter + 1. On x86 that compiles to three instructions:

mov  0x8049a1c, %eax
add  $0x1, %eax
mov  %eax, 0x8049a1c

The scheduler produces this interleaving:

step thread instruction T1 %eax T2 %eax counter
1 T1 mov (load) 80 - 80
2 T1 add 81 - 80
3 - interrupt, switch to T2 81 - 80
4 T2 mov (load) 81 80 80
5 T2 add 81 81 80
6 T2 mov (store) 81 81 81
7 - switch back to T1 81 81 81
8 T1 mov (store) 81 81 ?

What is counter at step 8, and why?