How does this work?

Cyclelicious Shop
Bicycle Lights - Wald Baskets - Dahon - Strida
Loading


IMPORTANT: This content is deprecated. Please visit the new CYCLELICIOUS 2.0.
Wednesday, April 12, 2006
By Yokota Fritz


Are there any x86 programming geeks that now how this down() function works? A colleague and I were puzzling over the "jmp 1b" code below (bolded). How does this function ever break out of this? This is from the file include/asm-i386/semaphore.h in the Linux kernel source.

static inline void down(struct semaphore * sem)
{
might_sleep();
__asm__ __volatile__(
"# atomic down operation\n\t"
LOCK "decl %0\n\t" /* --sem->count */
"js 2f\n"
"1:\n"
LOCK_SECTION_START("")
"2:\tlea %0,%%eax\n\t"
"call __down_failed\n\t"
"jmp 1b\n"
LOCK_SECTION_END
:"=m" (sem->count)
:
:"memory","ax");
}



    IMPORTANT: Please post comments for this article at the new CYCLELICIOUS 2.0 version of this page.
Comments:
You had me at "hello"...
 
Post a Comment



Links to this post:

Create a Link

Blog Widget by LinkWithin Cyclelicious Home




Scotts Valley Cycle Sport

Scotts Valley Cycle Sport Santa Cruz California


YEN

Powered by Blogger

Subscribe to
Posts [Atom]