Article View: comp.sys.amiga.tech
Article #8467Re: Frienndly waiting (not hogging the CPU)
From: SLMYQ
Date: Tue, 12 Apr 1988 04:12
Date: Tue, 12 Apr 1988 04:12
31 lines
1501 bytes
1501 bytes
> I was wondering if there was a friendly way for an amiga Process to
>Sleep for a period of time (in C). Currently to sleep for say,
>1 second I do a
>
>for(i=0;i<50;i++)
> WaitTOF();
>
>Is there a better, possibly more precise way of waiting for a period
>of time without hogging the CPU.
You bet. You can use the Delay() command. Just give it the number of ticks
to wait for. This would wait for one second:
Delay(50);
There are two problems. First, you must be operating on a process, not a
task, since it uses the DOS library, so you can only call it from the main
program or sub-PROCESSES - not sub-tasks. Second, there have been rumors
that using Delay(0) or an equivalent might corrupt the disk (and I believe
the rumors are actually true :).
You might want to open up the timer.device directly, but the only advantage
this would give is you could do something else while it's "ticking" - it's
asynchronous. You can use this method within tasks as well as processes,
but if you just want a synchronous wait within a task, using WaitTOF()
is probably better.
>Thanks
>-Roger
Bryan
Technical Details
Message-ID:
<8804120421.AA04436@jade.berkeley.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!faline!thumper!ulysses!ucbvax!USU.BITNET!SLMYQShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!faline!thumper!ulysses!ucbvax!USU.BITNET!SLMYQ From: SLMYQ@USU.BITNET Newsgroups: comp.sys.amiga.tech Subject: Re: Frienndly waiting (not hogging the CPU) Message-ID: <8804120421.AA04436@jade.berkeley.edu> Date: 12 Apr 88 04:12:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 31