On Sun, Sep 5, 2010 at 9:25 AM, Tapas Mishra <mightydreams@xxxxxxxxx> wrote: Ok I have done some calculation using a pen and paper here is what are my results lets assume loops_per_jiffy = 1011 0010 > loopbit = loops_per_jiffy; So loopbit = 1011 0010 > /* Gradually work on the lower-order bits */ > while (lps_precision-- && (loopbit >>= 1)) { no idea of what lps_precision is may be some sort of check. loopbit = loopbit/2 by above operation so new value of loopbit is loopbit = 0101 1001 > loops_per_jiffy |= loopbit; Now due to above loops_per_jiffy = loops_per_jiffy | loopbit so the result of an OR operation loops_per_jiffy = 1011 0010 OR 0101 1001 = 1111 1011 which is higher than the initial value of loops_per_jiffy > ticks = jiffies; simple > while (ticks == jiffies); /* Wait until the start is also simple if due to some calculation you are in mid of jiffy interval then it will make sure that as tick==jiffies will come out of loop only at the start of jiffy > of the next jiffy */ > ticks = jiffies; simple > /* Delay */ > __delay(loops_per_jiffy); Will delay for the value loops_per_jiffy > if (jiffies != ticks) > /* longer than 1 tick */ > loops_per_jiffy &= ~loopbit; here comes the magic if it is not satisfying the if condition then will go back divide the loopbits by 2 as a result of >> (right shift) and the OR operation will make sure that the value which is divided by 2 of loopbits gets added to loops_per_jiffy will enter the delay loop and in this case if this time the "if" condition is true then the result of loops_per_jiffy &= ~loopbit is loops_per_jiffy = loops_per_jiffy AND (~loopbit) where taking complement of loopbit as above makes it negative (not sure on this part) and the result is the value is subtracted (as it was more than required value) and then loopbit is again divided so added and this cycle will continue until exact value of loops_per_jiffy is calculated. > } > > but such a logic which is used above is there any more example some where? -- Tapas http://mightydreams.blogspot.com http://wiki.xensource.com/xenwiki/Xen_on_4_app_servers -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ