func (s *Spinlock) Lock() {
for {
test := 0
Cmpxchg(&test, &s.held, 1)
if test == 0 {
break
}
}
}
func (s *Spinlock) Unlock() {
// You don't need to use Cmpxchg here because
// only one thread should have ownership of the
// lock
s.held = 0
}
Since RPCs go across systems, we want to send the value that the pointer is pointing to.