Computer Chess Club Archives


Search

Terms

Messages

Subject: a timer using interrupts?

Author: Alessandro Damiani

Date: 00:23:05 06/10/98


Hi all!

Currently I am converting my program Fortress from Oberon2 to C (not
because I prefer C).

On my old Amiga I used an interrupt (frequency: 50Hz) to determine if
the search time is over:

  VAR
      TimerOn  * : BOOLEAN;
      ticks    * : INTEGER;
      Timer    * : LONGINT;
      TimeUsed * : LONGINT;

   PROCEDURE TimerInt;
      (* $SaveRegs+ *)
   BEGIN
      IF TimerOn THEN
         IF ticks>0 THEN
            DEC(ticks)
         ELSE
            ticks:= 50;
            IF Timer>0 THEN DEC(Timer) END;
            IF TimeUsed<MAX(LONGINT) THEN
               INC(TimeUsed)
            END
         END
      END
   END TimerInt;

Before the search is started the variable Timer is set to the time limit
and TimeUsed to 0. To determine if the time is over, one has only to
test if Timer is equal to 0. This is done in every node of the 'tree'.

I don`t like to read the clock after some nodes. So I want to use such a
timer in C. How can it be done on a SUN and on a PC?

thanks

Alessandro



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.