Spinlock Use Guidelines
Here are some guidelines on using spinlocks to protect critical resources.
o
Define spinlocks only for critical resources. A
read only I/O port is not a critical resource. A set of read only I/O ports
that must all be read before a decision is made IS a critical resource.
o
Do not define too many spinlocks.
o
Use spinlocks for VERY SHORT
durations only. As a general rule, calls should be avoided while owning
a spinlock.
o
Leave interrupts
disabled after locking a spinlock. This prevents interrupts on the same
processor and possible deadlock.
o
Be
careful to not make any calls that may try to lock a spinlock that is already
locked. ADDs, when making asynchronous callbacks, can be reentered at their
IORB entry point.
o
Be aware
that DevHelp_Block called with spinlocks locked will unlock them. When the
block wakes up spinlocks must be reacquired.
o
Never
make a call that could block while owning a spinlock. For example, some
DevHelp calls can block.
[Back: Properties of Spinlocks]
[Next: Device Drivers In OS/2 for SMP V2.11]