compiler / hardware reordering

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

 



In the following code:

a++

if (a > 5) {
  .....
} else {


}

Is it possible for "a++" to be swapped with the if-block?  If so, then
can I stop this reordering by making a as atomic_t?


In the second case:
....
spin_lock(&lock);
a++;
spin_unlock(&lock);
....
Is it possible for instructions to be reordered across a spin_lock
primitive?  If this is possible, then spinlocks will be pretty
useless........

Thanks!

Mark

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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