An improved system and method for improving complex storage locks that manage
access to a shared resource. A FIFO queue is maintained for processes waiting to
read or write to the shared resource. When the shared resource is available, the
first item is read from the queue. If the first item is a write requestor, the
requestor is woken up in order to request the lock. If the first item on the queue
is a read requestor, then that read requestor is woken up along with any other
read requestors read from the queue until a write requestor is encountered or the
end of the queue is reached. When the write wanted flag is set, new read requestors
are denied access to the read lock, however any read requestors that were woken
up in order to use the read lock are granted a read lock.