2012-05-29

原共筆紀錄 http://sync.in/ep/pad/view/juluosdev/1Nrh8n9Fny

2012-05-29

第11次星系統社群小聚:MIT OSE 讀書會: 複習Lab3 與預習Lab4背景知識

http://registrano.com/events/345d7c

System call overview

Preparation for Lab 4 overview

lock: ; The lock variable. 1 = locked, 0 = unlocked.

dd 0

spin_lock:

mov eax, 1

xchg eax, [lock] ; Atomically swap EAX register with lock variable.

test eax, eax

jnz spin_lock

ret

spin_unlock:

mov eax, 0 ; Set the EAX register to 0.

xchg eax, [lock] ; Atomically swap EAX register with lock variable.

ret ; The lock has been released.

xchg --> cmpxchgl ??

http://stackoverflow.com/questions/1746344/illegal-instruction-in-asm-lock-cmpxchg-dest-src

lock cmpxchgl %edx, (%eax)