|
|
#include <sys/ci/cilock.h>
struct lockb {
unsigned char ciflag;
unsigned char ciowner;
};
ciflagciowner struct lockb lock_xxtab = {0,0}
A driver may define as many individual
lock_xxtab[0...n] structures as necessary.
Spacing the locks apart is recommended
to avoid cache thrashing.
In most cases, just having other declarations
in between the lockb declarations is adequate.
When declaring a large number of locks in one place
(such as happens in the kernel's space.c file),
use the LOCKVAR macro to declare the lock
to avoid any thrashing.
The lockb structure can be padded for performance to make it a 16-byte entry. This allows the hardware cache mechanism to execute optimally. Padding can be implemented as follows:
char jnkl[12] = {0};
struct lockb lock_xxtab = {0,0};
char jnk2[12] = 0;
A driver must never directly read or modify the lockb structure.
``Spin locks (ODDI)'' in HDK Technical Reference