Reputation: 1170
Say you call spin_lock(&key) and key is having some type of operation being performed on it in a different thread at the same time. Is the other thread being paused/interrupted?
What happens to the other thread that's in the middle of altering or using key? Such as if the thread was calling copy_to_user(key), copy_from_user(key) or kmallocing/kfreeing key?
Upvotes: 0
Views: 464
Reputation: 27115
Don't know specifically about Linux kernel spin_lock()
, but in practically all programming environments, mutex locking is advisory. That means, locking a lock never prevents anything except, it prevents other threads from locking the same lock at the same time. If you want to use a lock to protect some variable or data structure, then it's entirely the programmer's responsibility to ensure that no code anywhere in the system ever accesses the data except when the lock is locked.
Upvotes: 2