After another thought, I came up with a different scenario for this case.
if the xadd microcode xadd is like this:
temp = ax + newSS newSS = ax ax = temp ; the last 2 are actual xchg
we have a problem in this scenario:
Suppose newSS is split between two threads.
Topic # 0 ( t0 with her ax equal to 5) loads and adds newSS with ax and puts it in temp register .
Suppose that at this point we have a context switch. Then t1 with it ax is 5 attempts to load newSS and add it to ax and put the result in temp register . and then the context switches to t0 ... Both stack segment registers point to the same address.
Obviously, there is a problem. If the microcode implementation is not like this:
tmp register = ax xchg ax, newSS ax = ax + tmpRegister
in any other way that the newSS variable is read more than once or read and written in different instructions, we need a lock.
source share