simple (i386) spinlock implementation questions...

From: kumon@flab.fujitsu.co.jp
Date: Mon May 15 2000 - 20:31:51 EST


Brett Thompson! writes:
> Hello great kernel hackers!
> 1) What does spin_lock_string do in 2.2 (for SMP kernels)? It's:
> #define spin_lock_string \
> "\n1:\t" \
> "lock ; btsl $0,%0\n\t" \
> "jc 2f\n" \
> ".section .text.lock,\"ax\"\n" \
> "2:\t" \
> "testb $1,%0\n\t" \
> "jne 2b\n\t" \
> "jmp 1b\n" \
> ".previous"
> I've stared at it for at least an hour, and I am apparently unable to
> make coherent sense out of it.. It *looks* like an infinite loop, but it
> can't be? I'm so stupid, though, I'm not sure what btsl does, and the as
> info page doesn't talk about arch-specific instructions, eep.

This code should be read sumthing like that:

1:
        lock ; btsl $0,%0
        jc 2f

        CODE_JUST_FOLLOWS_THE SPIN_LOCK_STRING.
        .....
        .....
        .....

        org VERY_FAR_LOCATION
        .section .text.lock,\ax\
2:
        testb $1,%0
        jne 2b
        jmp 1b
        .previous

--
Computer Systems Laboratory, Fujitsu Labs.
kumon@flab.fujitsu.co.jp

- 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/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:27 EST