Re: [AD] SetTimer for the timer |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] SetTimer for the timer
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Mon, 9 Jan 2006 02:15:17 -0800
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=JI2TAsthWN38Cdg2hQuZhEcqiImrvBidUrfCRxSpCRrL7LvhnkN26JADC1e0oiSFzvOtun96bsW+C53XvBzfxvtzR3eeCjmH5JX386660yozCszS0i8fjwGB5DPfTNfq7zD/9GUuGXq3YhHvJJUqZmYhG0775rJgTcOO6+QcL4Y=
On Monday 09 January 2006 01:37, Peter Wang wrote:
> Apparently it is not very accurate though.
Unfortuante. :( Though I wouldn't call the NT/2K/XP accuracy very bad,
considering that's about as accurate as it is now. The message priority is a
problem, though. Is there any way to increase the accuracy for 9x and
increase the message priority? Or are those hard-coded?
> > It seems these would fit better than the current hackish way
> > of running a timed thread.
>
> Why is it hackish? It's pretty straight forward.
Because they were originally designed to run in an interupt context, not
concurrently with the main program (which has led to sloppiness and the
mistaken belief that you can wait in a timer for something to occur in the
main thread; eg. a mutex). To put it into perspective, if the timer was
accurate and better prioritized so it would be used, anything that uses the
software mouse or calls a sound/graphic function would randomly freeze solid.
Granted the latter shouldn't be done anyway, and the former would hopefully
be fixed in some way, but the current implementation clearly allows it.
As well, there's problems making a single thread having to keep track of all
the timers which can have different speeds. This is either handled by
sleeping at the lowest-common-multiple and checking each function upon wakeup
which would cause it to recheck needlessly often when using two speeds that
don't cleanly divide, or by dynamically calculating the time until the next
interrupt would occur (current implementation, I believe) which causes more
delayed jitter which is expounded by the sleeping function's inherent
innacuracy.