This looks exactly like atomicCAS from later in the slides. I've never worked with flags before in c level code, so how would a programmer go about using this function or what c functions interface with this x86 function?
gsamp
@gohan2021, assuming 1 signals the lock is locked and 0 signals it's unlocked, why would the initial state be locked?
I didn't want to spoil the answer, but here is my solution:
init(): set EAX to 1, and x = 0.
lock(): while(compare_and_exchange(x, 1) == 1) { // spin }
unlock(): set x = 0.