Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Threaded input library

Author: Harald Lüßen

Date: 17:10:08 10/15/04

Go up one level in this thread


On October 15, 2004 at 18:56:48, Alessandro Scotti wrote:

>Hi,
>a while ago I posted the source code for an input library that used a separate
>thread for reading input.
>Today Ross Boyd contacted me and reported a problem he found using the library
>on Windows, when the input thread will hang for several or even many seconds.
>During this time, the engine is not able to read input and may well lose the
>game on time, as occurred to Ross.
>I can now reproduce the problem relatively easily and have spent hours
>investigating it, but have no solution. The thread blocks inside a call to
>ReadFile, which is a system call and can't be debugged for now. The call does
>not return even when there should be input already available, and when it exits
>it's always after a number of seconds that is a multiple of 5, a "magic" number
>that I do not use.
>What I suspect after a lot (and I mean a lot) of experiments: the main thread is
>always given priority over the thread that is feeding input (e.g. Winboard)
>until some sort of timeout occurs internally to the operating system. The reason
>I say that is the problem seems to disappear if I lower the priority of the
>engine main thread, but not if I raise that of the input thread. Or, also the
>problem disappears if I put the main thread in infinite sleep.
>Anyway, regardless of these technical details, if by any chance you are using
>this library in your code and playing in tournaments, probably it's better to
>switch back to single-thread input code, i.e. polling. Otherwise you risk losing
>games on time and this really sucks.
>However, Kiwi will keep using the existing code so that I have a chance to
>gather more data even if this means losing games or being kicked out of a
>tournament.
>I apologize to those that have downloaded the library and spent time on it: I
>have tested the code for weeks and never found any problem... this kind of
>things is really unpredictable, and frustrating... :-(

Hey, you are the lucky one. You can reproduce and partially understand
the bug. I have an own input thread, comparable to yours, and I may have
a similar problem. I have reports from tournaments where my engine lost
on time for no good reason. And I cannot reproduce this error at home.
Reading the input thread source again and again does not help. I just wait
for inspiration. If you ever find and solve your problem, please let us
know. Perhaps the same solution works for me.

Harald



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.