FreeBSD spinlock - compatibility layer

John Baldwin jhb at freebsd.org
Wed May 22 13:06:06 UTC 2013


On Wednesday, May 22, 2013 2:14:51 am Orit Moskovich wrote:
> From what I've read in "FreeBSD - device drivers" book by Joseph Kong on 
interrupt handling, you cannot voluntarily context switch (that is, sleep) in 
interrupt threads .

That is not the same thing.  By sleep it means call a *sleep() function or 
wait on a cond var.  Not block on a mutex or rwlock.

> In any case, I think that the functionality of spin mutex should remain as 
is, and not modified to sleep mutex, as it can be used in places that sleep 
mustn't be used, or that require the properties of the spin due to performance 
considerations.

No, spin locks are _slower_ and reduce performance.  FreeBSD is much more like 
Solaris in this regard.  Spin mutexes on FreeBSD are similar to dispatcher 
locks in Solaris which 99% of the kernel should never use.

-- 
John Baldwin


More information about the freebsd-arch mailing list