[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Waiting for a bit in a register to be cleared: which strategy?
>> Efficient in terms of what resource? That is, what measure of
>> efficiency are you interested in here?
> Above all, the code complexity (not the hardware resource
Then, yes, just loop. First make it work, then make it better.
>> The simplest is probably to just put a limit on the iteration count:
>> But this makes the timeout inherently dependent on the host CPU speed.
> Yes, I excluded this because I would like to avoid using the CPU for
> (potentially) millions of cycles and - as you said - because of the
> CPU-dependent variable increment.
>> If that's a problem, you could add a delay in the loop
> I think this is the best in my case.
Well, be aware that DELAY() on many machines, especially for small
arguments, _is_ just a cycle-burning loop - it just multiplies the
argument by a constant calculated based on CPU speed.
> Interrupts are maybe the ideal solution, but I'm completely unable to
> handle them in a driver. I'm a complete newbie.
>> The last two options have the advantage that they release the CPU to
>> do other useful work while waiting. They have the disadvantage that
>> they decrease responsiveness [...].
> Yes, of coure.
If that's "of course" to you, you're not a _complete_ newbie. :-)
I'd say, just use the simple loop. Once you have that much working,
*then* worry about things like handling (pseudo-)hardware failures or
interrupts, or sleeping instead of busy-waiting.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Main Index |
Thread Index |