Everything that can be called a lock (exclude other threads from the critical section until the current thread unlock) is by definition not blocked. And yes, spin locks are a kind of lock.
If a thread is delayed while holding a lock, no other thread can receive it and make progress forward, and locks cannot prevent this. The OS can ignore the stream whenever it wants, even if it is in the middle of a critical section.
Please note that “lock-free” is not the same as “no wait”, so an algorithm without locking can still have things like cmpxchg repeat loops, but as long as one thread executes each times, it blocks free.
Without waiting, the algorithm cannot even do this, and at best it should wait for a cache miss / hardware arbitration as a result of the approved atomic operations. A Wikipedia article on a non-blocking algorithm defines in more detail lifeless and blocking access.
I think you are confusing the two definitions of "blocking."
I think you are talking about the spin_trylock function, which tries to get a spin lock , and returns with an error if it fails, rather than spinning. Thus, it is non-blocking in the same sense as non-blocking I / O: an error fails instead of waiting for resources to be available.
This does not mean that any flow in the system is moving forward in the subject protected by spin-lock. It just means that your thread can go and do something else before trying again, instead of having to use separate threads to do something in parallel with waiting for a lock.
Spinning in an infinite loop is considered blocking / non-constituent progress. For this definition, there is no difference between a clean spin lock and what (with the help of the OS) sleeps until another thread is unlocked.
The definition of blocking is not connected with the loss of time / processor power to free up space for independent work.
To some extent: the acquisition of non-contact spin-lock does not require a system call, which means an “easy” lock. Some lock implementations always use a (relatively slow) system call, even in an insecure case. See Jeff Preshing Always Use The Lightweight Mutex . Also read Jeff other posts to learn more about non-locking programming because they are excellent. It’s actually so good that wiki links [lock-free] link to them.