问题
in Linux kernel source code, I find below code:
h++;
pending >>= 1;
It is part of __do_softirq(void). But what does ">>=" mean? Why isn't it ">>" as I remember?
Thanks!
回答1:
It simply does
pending = pending >>1;
In short it divides by 2 an unsigned int.
That's the same construct than +=, /=, etc.
It's not just pending >>1 as you remember because that wouldn't store the result of the shift operation in the variable.
回答2:
It's equivalent to
pending = pending >> 1;
Which bitshifts right the bits in pending. This would have the effect of dividing an unsigned int by 2. >> and << are the bitshift operators, and the combination with = behaves the same way += and /= do.
来源:https://stackoverflow.com/questions/11246466/what-does-mean-in-linux-kernel-source-code