Messages in this thread | | | Subject | Re: patch: delay_50ms() in ide-probe.c in 2.2.14 | Date | Mon, 21 Feb 2000 10:16:09 +0100 (MET) | From | (Rogier Wolff) |
| |
<arijort@valinux.com> wrote: > > Simple arithmetic tells me this patch > > a) produces same behavior as previous code, and
No.
> b) does it with fewer calculations. > > So it has to be good, right?
No. Its bad and doesn't work.
> But then how do we exit the while loop?
In your case: never.
> How does jiffies change?
It is modified from the timer interrupt. It is also marked "volatile". This means that the compiler is NOT allowed to move the "move jiffies into a register" outside the while loop.
So, without that volatile the compiler would indeed be allowed to do something like
load jiffies, r4 ; jiffies temporarily in r4. add r4, 6, r5 ; calculate timeout into r5.
0: sub r4, r5, r0 jnz 0b
(which if the compiler is really good actually optimizes even futher: 0: jmp 0b )
but with the volatile attribute on the "jiffies" variable, it will need to reload "jiffies" every time around the loop:
load jiffies, r4 ; jiffies temporarily in r4. add r4, 6, r5 ; calculate timeout into r5.
0: load jiffies, r4 ; reload jiffies in r4. sub r4, r5, r0 jnz 0b
And the timer interrupt will increment jiffies 100 times a second, until the thing times out.
Roger.
-- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* * Common sense is the collection of * ****** prejudices acquired by age eighteen. -- Albert Einstein ********
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |