lkml.org 
[lkml]   [1999]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: possible spinlock optimization

"On a uniprocessor queued spinlocks work exactly like normal spinlocks."

Huh? Anyone clues on this? "... exactly like normal spinlocks, that is:
they don't do anything" ?

"KeAcquireQueuedSpinlock" works like this: the function attempts to
acquire the spinlock by using the interlocked-exchange CPU instruction to
place the address of the current processor's PCR in the spinlock."

Surely there are machines without an atomic xchg instruction? And you
can't emulate the atomic behaviour with a spinlock, as we are implementing
one... :-)

"If the spinlock ....... from the spinlock."

1. %eax = pcr_of_this_processor
2. xchg (%eax, &spinlock);
3. if (%eax) return; /* we have the lock */
4. pcr_of_this_processor->waiting = 1
5. %eax->queue = pcr; /* %eax = pcr_of_other_processor */

How do they guarantee that steps 2,4,5 operate atomically?

CPU#0 CPU#1
grab the lock release lock

eax = pcr eax = 0
spinlock <-> eax
spinlock <-> eax
return;

eax = PCR_of_CPU#1

Now CPU#0 has in %eax the PCR of a processor which has just released the
lock, no? So CPU#0 will happily queue itself.... Am I missing something
here?

Greetings,
Lennert Buytenhek


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.033 / U:0.972 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site