Polling standard input from C++

Discussion of chess software programming and technical issues.

Moderator: Ras

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Polling standard input from C++

Post by bob »

mar wrote:
bob wrote:I am not sure you would want to run as root and install your own device driver that would let you do ANYTHING you want in the kernel... :)
Yes I expected a driver :) I guess we can agree that separate thread is not such a bad idea after all ;)
I did a separate thread in Cray Blitz in fact. But when I started Crafty, late 1994, MSDos was the game on the PC, and no threads. So I went to a polling model. But that model works quite well (select() with a zero timeout value which returns a zero if there is no input, a non-zero if there is). I keep thinking about rewriting, but there are things to decide, such as what kind of "thing" do you create, a real thread or a separate process (process makes it easier to "kill" it when you want since nothing is shared and nothing can be left in a painful state (locks set, etc)..

Maybe one of these days. Because it is certainly a bit cleaner.