<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Mon, 26 Sep 1994 11:06:01 -0600
From   : barnett@... (David Barnett)
Subject: Timer IRQ emulation

>Chris Lam wrote:
>
>>won't you need to decrement and check for EACH possible interrupt? my
>>structure
>>is
>
James B. Replied:
>Yes, but you only need decrement a common figure - the 'next' interrupt. Then
>once this occurs you decrement your other interrupt timers and compute the
>'next' figure again.
>

I agree with James but would recommend one modification to his scheme for
the sake of cleanliness and ease of maintenance/debugging:

Maintain an absolute counter as a kind of "world time".  Maintain a list of
next interrupt times (in "world time"), sorted so that the nearest one is
at the top. This one can be compared with world time at no extra cost.
Whenever an interrupt is serviced, it can be dropped from the list and the
reset version inserted at the correct place.  The next one in line is now
the head.

For speed I suggest that the most critical emulator registers be declared
"register".  If the inner loop is small enough then it may live entirely in
the cpu cache graetly enhancing performance on some machines.

David Barnett
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>