spinlocks and Adaptive Locks in Solaris Kernel development

I need to use a spinlock in my VMCI Solaris device driver. After reading some documentation, I figured out that there are 2 types of locks in solaris: adaptive locks and spinlocks.

Adaptive locks are the most common type in Solaris and they can either 'block' or 'spin' depending on whether the process/thread holding the lock is running or sleeping respectively whereas, in the case of spinlocks, context switching is not allowed (by raising the interrupt level of the processor when the lock is acquired thereby making sure that the lower-priority dispatcher cannot execute to do the context-switch).

On referring to the 9F section of the man page for mutex_init() using "man -s 9f mutex_init", I could see that the 'type' argument to this function "should be" MUTEX_DRIVER (as per the man page).. <http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/sy s/mutex.h#42> confirms this.... and it also tells that the type of lock (adaptive or spinlock) depends on the type of ddi_iblock_cookie passed to mutex_init()

I lloked into all the related man pages but looks like I am confused.....I feel that using high-level interrupt handler (that interrupts at a level of scheduler or above and thus making it non context-switchable) would help me design spinlocks.

I also noodled <http://docs.sun.com/app/docs/doc/819-3196/6n5ed4gqf?a=view>, example 8-10 but just wanted to know this soft/hard-level interrupt handling mechanisns and whether I am thinking in the correct direction.

If somebody can provide a working snippet of a spinlock, it would be greatly appreciated.

-Kaushik

[1657 byte] By [Kaushikgoa1a] at [2007-11-27 6:39:25]
# 1
Also, another basic (but still not answered by google) question: when we declare a lock of type kmutex_t, will it always be an adaptive lock ?
Kaushikgoa1a at 2007-7-12 18:08:30 > top of Java-index,Solaris Operating System,Solaris Essentials - General Technical Questions...