Author: Robert Hyatt
Date: 06:57:46 06/10/98
Go up one level in this thread
On June 10, 1998 at 08:48:33, Alessandro Damiani wrote:
>On June 10, 1998 at 06:41:15, Inmann Werner wrote:
>
>>On June 10, 1998 at 03:23:05, Alessandro Damiani wrote:
>>
>>>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
>>
>>Hello Alessandro
>>
>>My program also is in c.
>>
>>In most C Compilers, there is a function called ftime
>>
>>You have to include some file like "time.h" (see compiler)
>>
>>program
>>
>>#include <stdio.h>
>>#include <time.h>
>>#include <timeb.h>
>>
>>main()
>>{
>>struct timeb tt;
>>long mytime;
>>
>>ftime(&tt);
>>mytime=tt.time*1000+tt.millitm;
>>
>>
>>if you do this, you have the time in millisec in mytime as a start time
>>
>>youse the same routinme sometimes else with another long variable and
>>the
>>difference is the ellapsed time.
>>
>>I don“t know, if it helps you!
>>
>>Best wishes
>>
>>Werner
>
>this means reading the clock every n nodes in the search, which I wanted
>to avoid (the test if (Timer==0) 'abort search'; in every node is
>faster).
>
>In Crafty Bob reads the clock, too. Is my implementation too hardware
>specific?
>
>Alessandro
In unix, you can set an "event" as you suggest, picking a future time
and saying "send me a signal when this time arrives". But it is
dangerous
if you don't know how to handle signals and understand how they affect
your
I/O-in-progress when they arrive. And if you are interested in multi-
threading or parallel search, forget about them totally as portability
is
a huge problem there...
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.