Re: fine tuning the precision in calibrate.c

2010-09-05 Thread Tapas Mishra
On Sun, Sep 5, 2010 at 9:25 AM, Tapas Mishra  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 =  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 ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: fine tuning the precision in calibrate.c

2010-09-04 Thread Tapas Mishra
On Sun, Sep 5, 2010 at 9:25 AM, Tapas Mishra  wrote:
>
> loopbit = loops_per_jiffy;
> /* Gradually work on the lower-order bits */
> while (lps_precision-- && (loopbit >>= 1)) {
> loops_per_jiffy |= loopbit;

How is loops_per_jiffy |= loopbit;
OR operation above and
> ticks = jiffies;
> while (ticks == jiffies); /* Wait until the start
> of the next jiffy */
> ticks = jiffies;
> /* Delay */
> __delay(loops_per_jiffy);
>
> if (jiffies != ticks)
> /* longer than 1 tick */
> loops_per_jiffy &= ~loopbit;
AND with Inverse
loops_per_jiffy &= ~loopbit;
help to achieve the desired result.
> }
>
>


-- 
Tapas

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



fine tuning the precision in calibrate.c

2010-09-04 Thread Tapas Mishra
Hi,
on the following link
http://books.google.com/books?id=Boo57V0IOq0C&pg=PA24&lpg=PA24&dq=loopbit+%3D+loops_per_jiffy&source=bl&ots=pwHxgTVaX9&sig=mmFc_E2o9-xS7Xy-kzYXxTu1-a8&hl=en&ei=_RODTLP9H8bJcdPHpNAL&sa=X&oi=book_result&ct=result&resnum=5&ved=0CCQQ6AEwBA#v=onepage&q=loopbit%20%3D%20loops_per_jiffy&f=false

Following code  is given

loopbit = loops_per_jiffy;
/* Gradually work on the lower-order bits */
while (lps_precision-- && (loopbit >>= 1)) {
loops_per_jiffy |= loopbit;
ticks = jiffies;
while (ticks == jiffies); /* Wait until the start
of the next jiffy */
ticks = jiffies;
/* Delay */
__delay(loops_per_jiffy);

if (jiffies != ticks)
/* longer than 1 tick */
loops_per_jiffy &= ~loopbit;
}


Can any one help to understand this section?
-- 
Tapas

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ