Entry and Exit Using Spinlocks
Now we can write the entry procedure:
while(test_and_set(&lock));
And the exit procedure:
lock = 0;
getlock: tsl $t0, lock
bne $t0, $zero, getlock
# critical section here
sw $zero, lock
Previous slide
Next slide
Back to first slide
View graphic version