down() function and assembly implementation

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

 



Hi all,

I am not getting the implementation of down() which is written in assembly language.

static inline void down(struct semaphore * sem)
{
#if WAITQUEUE_DEBUG
        CHECK_MAGIC(sem->__magic);
#endif
                                                                                                                            
        __asm__ __volatile__(
                "# atomic down operation\n\t"
                LOCK "decl %0\n\t"     /* --sem->count */
                "js 2f\n"
                "1:\n"
                LOCK_SECTION_START("")
                "2:\tcall __down_failed\n\t"
                "jmp 1b\n"
                LOCK_SECTION_END
                :"=m" (sem->count)
                :"c" (sem)
                :"memory");
}

if u look into the assembly produced by compiling it using -S option for gcc you will get


#APP
        # atomic down operation
        lock ; decl (%eax)
        js 2f
1:
.subsection 1
        .ifndef .text.lock.KBUILD_BASENAME
        .text.lock.KBUILD_BASENAME:
        .endif
        2:      call __down_failed
        jmp 1b
.previous
                                                                                                                            
#NO_APP

In the above listing its jumping forward first and calls __down_failed and after that again it jumps backword to label one. Why is it so ??? and also whats the meaning of      
         .ifndef .text.lock.KBUILD_BASENAME
        .text.lock.KBUILD_BASENAME:
        .endif
above assembly code. Plz guide me.

Thanks in advance,
Deepak Joshi.


Try the all-new Yahoo! Mail . "The New Version is radically easier to use" ? The Wall Street Journal

[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