Author: Martin Giepmans
Date: 17:23:35 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... :-( Recently I discovered similar problems with SpiderChess (written in Delphi) under win XP. I still have win ME on my own computer and played hundreds of games on the internet without any problem. But when others tested the engine under win XP there were suddenly all kinds of mysterious delays. And sometimes the engine refused to move. After a few weeks of fruitless experimenting with sleep(), changed priorities etc, etc, I removed the blocking input thread and implemented polling. Now everything works fine :). I still don't know what the cause of the problem was. Martin
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.