Re: jmp 1b, how does this exit?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Link must point to
http://lxr.linux.no/source/include/asm-i386/semaphore.h?v=2.6.10#L105

Sorry for that.
Regards,
om.

On 4/13/06, Om Narasimhan <om.turyx@xxxxxxxxx> wrote:
> Hi,
> In the below code fragment, how does this escape an infinite loop
> (line 116 down)?
> From linux-2.6.16/include/asm-i386/semaphore.h (
> http://lxr.linux.no/ident?v=2.6.10;i=down )
> 105   static inline void down(struct semaphore * sem)
> 106  {
>    might_sleep();
>    __asm__ __volatile__(
>        "# atomic down operation\n\t"
>        LOCK "decl %0\n\t"     /* --sem->count */ // locked and decremented.
>        "js 2f\n" // if sign is set jump to 2:
>        "1:\n"
>        LOCK_SECTION_START("") // starts a new section in elf, what
> does this mean?
>        "2:\tlea %0,%%eax\n\t" // loads &sem (==&sem->count) into eax.
>        "call __down_failed\n\t" // this eventually returns when sem is acquired
> 116        "jmp 1b\n" // goes back to 1: ... how would this function
> ever return?
> 117         LOCK_SECTION_END
>        :"=m" (sem->count)
>        :
>        :"memory","ax");
> }
>
> Any pointers/ideas? I checked the man pages of as. I did not quite
> follow the .previous...etc directives.
>
> Regards,
> Om.
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux