Use xchg in Xcpustop to close a race and make cpustop_restartfunc truly

one-shot in the SMP case (before using the simple mov / cmp / mov sequence
could allow multiple CPUs to execute the restart function on resume).
This commit is contained in:
John Baldwin 2005-10-24 20:52:26 +00:00
parent 6b1e0d75b0
commit 95d84e5461
2 changed files with 6 additions and 4 deletions

View File

@ -297,10 +297,11 @@ IDTVEC(cpustop)
test %eax, %eax
jnz 2f
movq cpustop_restartfunc, %rax
xorq %rax, %rax
lock
xchgq cpustop_restartfunc, %rax
testq %rax, %rax
jz 2f
movq $0, cpustop_restartfunc /* One-shot */
call *%rax
2:

View File

@ -340,10 +340,11 @@ IDTVEC(cpustop)
test %eax, %eax
jnz 2f
movl CNAME(cpustop_restartfunc), %eax
xorl %eax, %eax
lock
xchgl CNAME(cpustop_restartfunc), %eax
test %eax, %eax
jz 2f
movl $0, CNAME(cpustop_restartfunc) /* One-shot */
call *%eax
2: