tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Simplelock v.s lock

Hey guys. I am a noob in netbsd. I had some experience with linux before though.
During my work, ive approached a problem when i need to use a
Linux-like spin locks.
I found out that i need to use either lock or simplelock in NetBSD.
My question is : what is the exact difference between those two ?
According to the manual:
'struct simplelock
              Provides a simple spinning mutex.  A processor will busy-wait
              while trying to acquire a simplelock.  The simplelock operations
              are implemented with machine-dependent locking primitives.
              Simplelocks are usually used only by the high-level lock manager
              and to protect short, critical sections of code.  Simplelocks
              are the only locks that can be used inside an interrupt handler.
              For a simplelock to be used in an interrupt handler, care must
              be taken to disable the interrupt, acquire the lock, do any pro-
              cessing, release the simplelock and re-enable the interrupt.
              This procedure is necessary to avoid deadlock between the inter-
              rupt handler and other threads executing on the same processor.
     struct lock
              Provides a high-level lock supporting sleeping/spinning until
              the lock can be acquired.  The lock manager supplies both exclu-
              sive-access and shared-access locks, with recursive exclusive-
              access locks within a single thread.  It also allows upgrading a
              shared-access lock to an exclusive-access lock, as well as down-
              grading an exclusive-access lock to a shared-access lock.'
Is the only difference that simplelocks are 'turining interrupts off'
, and the other is not ??
Thanks in advance for any reply.

Home | Main Index | Thread Index | Old Index