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");
}
Wednesday, April 12, 2006
How does this work?
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.
Subscribe to:
Post Comments (Atom)
1 comment:
You had me at "hello"...
Post a Comment