Spin Lock
Posted: Wed Aug 28, 2013 7:24 am
My code can run successfully on bochs and QEMU. However, but when I put it on virtualbox (in SMP), it stops running.(1 Core in virtualbox is OK) It seems that the processes are stopped from being scheduled. I guess that my spin lock have a little problem:
Can anyone check if the code was wrong or not? I think it is correct
Code: Select all
spin_lock:
mov edx, [esp+4]
.spin:
mov eax, 1
xchg eax, [edx]
or eax, eax
jz .ret
pause
jmp .spin
.ret:
ret
spin_unlock:
mov edx, [esp+4]
mov dword[edx], 0
ret