James Gregory wrote:

On Wed, 2005-12-21 at 17:58 +1100, O Plameras wrote:
Spinlock is shown for UP.

What is spinlock for SMP ?

I omitted it because there's substantially more code to do it. The short
answer (which I'm only half sure of, I'm sure someone else here can
confirm or deny my allegations) is that it disables pre-emption, takes
out a bus lock and does all the standard stuff. It's a binary semaphore,
as per Dijkstra's original formulation of it.

Here's a wikipedia article on semaphores:

   http://en.wikipedia.org/wiki/Semaphore_%28programming%29

Here's the obscure assembly code that does the hard work:

   #define spin_lock_string \
       "\n1:\t" \
       "lock ; decb %0\n\t" \
       "jns 3f\n" \
       "2:\t" \
       "rep;nop\n\t" \
       "cmpb $0,%0\n\t" \
       "jle 2b\n\t" \
       "jmp 1b\n" \
       "3:\n\t"

which you'll find in include/asm-i386/spinlock.h.


Thanks, James.

I appreciate that.

O Plameras

--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to