A Nice routine

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

A Nice routine

Post by sje »

A Nice routine

If you are using your computer for running your chess program and at the same time for browsing TalkChess, you might want to have your chess program running at a lower priority. You can do this manually with the renice command, or you can build the same functionality into your program. The routine is:

Code: Select all

void Nice(void)
{
  const int rc = setpriority(PRIO_PROCESS, 0, 20);
  
  if (rc != 0)
    Die("Nice", "Bad setpriority");
}
For details: http://www.unix.com/man-page/Linux/2/setpriority/
User avatar
hgm
Posts: 27807
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A Nice routine

Post by hgm »

Of course you can also instruct the GUI to run the engines at lower priority. E.g. with XBoard using the option -niceEngines N.
User avatar
pocopito
Posts: 238
Joined: Tue Jul 12, 2011 1:31 pm

Re: A Nice routine

Post by pocopito »

Maybe cpulimit is worth bearing in mind too:

http://freecode.com/projects/cpulimit
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: A Nice routine

Post by syzygy »

Let's open a thread for each posix function.
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: A Nice routine

Post by Dann Corbit »

hgm wrote:Of course you can also instruct the GUI to run the engines at lower priority. E.g. with XBoard using the option -niceEngines N.
That is a much better way of doing it. Arena has this feature also.