"Petrus Wrang�" <[EMAIL PROTECTED]> wrote:

> Ok, I can accept that. But if what your telling me is that there is no way
> of creating a similar callback function some other way, then, I can't accept
> that!
>
> Still, creating a millisecond delay must be possible. Right? (Even if I have
> to go to assembly level coding.)

Stop and think carefully about what you really want. I suspect you
don't really want a delay of exactly one millisecond. Instead, I
suspect you want one thing to happen exactly one millisecond after
another thing has happened. A one millisecond delay is insufficient; it
will simply cause one part of your code to execute a millisecond after
another part.

It takes CPU cycles to make things happen in the real world. When the
delay ends, your code takes over to cause that second thing, whatever
it is, to happen. Executing this code takes time. Depending upon what
it is you're trying to do, I would estimate there will be 20 to 100
microseconds between the end of the precisely timed millisecond delay
and the actual end result you're wanting to produce.

And there's more. It's difficult to write code that will produce a
precise delay on all Palm devices. Consider this:

    do_one_thing();
    PreciseDelay(1); // units is milliseconds
    do_another_thing();

The call to PreciseDelay() incurs some overhead: pushing the argument
onto the stack, executing the JSR or BSR call, etc. So even if the
PreciseDelay() routine gives you exactly the time you desire, the time
from the end of do_one_thing() to the beginning of do_another_thing()
will be slightly longer. And this overhead is not constant; it will
depend upon the CPU clock speed and memory wait states, which vary from
one model of Palm device to another. (And don't forget that users can
choose to run Cruise Control, Afterburner, etc.)

On top of that, you don't have control over interrupts in the device.
(Nor do you want to try to get control over them, for the same reasons
that you want to avoid the Sys... calls.) That means that one or more
ISRs might run in the time between the end of do_on_thing() and the
start of do_another_thing().

The bottom line: Palm OS is not a real-time environment. Be aware of
its limitations.

--
Roger Chaplin
<[EMAIL PROTECTED]>

--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to