two questions about test_and_c​lear_bit()

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

 



Hi,

    For the following function, I have two questions:

static inline int test_and_set_bit(int nr, volatile unsigned long * addr)
{
    int oldbit;

    __asm__ __volatile__( LOCK_PREFIX
                          "btsl %2,%1\n\tsbbl %0,%0"
                          :"=r" (oldbit),"+m" (ADDR)
                          :"Ir" (nr) : "memory");
    return oldbit;
}

1. There are two instructions in the inline assemably, namely btsl and
sbbl. But, can the only one LOCK_PREFIX ensure that the operation is
atomic?

2. The clobber list of the inline assembly contains a string of
"memory". What is the meaning of this declaration and why does the
operation need it ? After all, some other operations such as
clear_bit() dose not need "memory" indeed. The declaration of "memory"
appears in source code of kernel here and there, and bothers me for a
long time. So any details about it will be appreciated.

static inline void clear_bit(int nr, volatile unsigned long * addr)
{
    __asm__ __volatile__( LOCK_PREFIX
                          "btrl %1,%0"
                          :"+m" (ADDR)
                          :"Ir" (nr));
}

 Thanks!

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[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