tech-kern archive
[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?
>> 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 loop works; I honestly think that the bit is cleared in a
> negligible amount of time,
If you're curious, then count the iterations and report the number
after the loop:
int loops;
for (loops=0;;loops++) { if (! (bus_space_read_... & ...)) break; }
printf("loop count %d\n",loops);
A printf like that is a bad idea in production code, but you are
nowhere near production at this point.
> but it's right and proper to handle a failure.
True. It's often hard to test error-handling code, but that doesn't
make it unimportant. (Though, for emulated hardware like this,
hardware failure is effectively impossible, so hardware failure
handling code is important only for what it teaches you.)
/~\ 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
Home |
Main Index |
Thread Index |
Old Index