[Yoda <bett@dialup.ptt.ru> writes:]
>Can you describe me how works spin-locks when somebody take the semaphor
>?
Semaphores and spinlocks occupy different levels in the hierarchy of locking
within VSTa. Spinlocks are at the lowest level; it is a fatal error to
sleep on a semaphore while holding a lock. Since spinlocks do not
relinquish the CPU, they have only two uses:
- On uniprocessor systems, they disable interrupts
- On multiprocessor systems, they coordinate low-level access to a
shared structure.
>I don't see any "hold check" in p_lock declaration (except debug
>assert).
On a multiprocessor, when you see the lock held, you spin until some other
CPU who holds the lock releases it. On a uniprocessor, if you see the lock
held, since there isn't another CPU, you can assume you have a locking bug.
>And why you don't put there (on semaphor fields) ordinary sleep-locks ?
On fields within a sema_t? A semaphore is the basic primitive for sleeping.
So the mutex to manipulate this primitive has to be non-sleeping--that is, a
spinlock.
Andy
Received on Thu May 21 12:39:13 1998
This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:43 PDT