From: H.G.Muller Date: Mon, 17 Jun 2019 11:49:01 +0000 (+0200) Subject: Apply -niceEngines priority only to engines X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=4649214a853d69c14d2c22ea8d2709e41c5110e1;p=xboard.git Apply -niceEngines priority only to engines Child processes started to communicate with ICS should run at normal priority, and the caller of StartChildProcess now determines whether the CPU priority will be niced, depending on the task of the process. --- diff --git a/backend.c b/backend.c index b1a6155..47b426d 100644 --- a/backend.c +++ b/backend.c @@ -1884,7 +1884,7 @@ establish () appData.remoteUser, appData.telnetProgram, appData.icsHost, appData.icsPort); } - return StartChildProcess(buf, "", &icsPR); + return StartChildProcess(buf, "", &icsPR, 0); } } else if (appData.useTelnet) { @@ -11182,7 +11182,7 @@ StartChessProgram (ChessProgramState *cps) cps->initDone = FALSE; if (strcmp(cps->host, "localhost") == 0) { - err = StartChildProcess(cps->program, cps->dir, &cps->pr); + err = StartChildProcess(cps->program, cps->dir, &cps->pr, appData.niceEngines); } else if (*appData.remoteShell == NULLCHAR) { err = OpenRcmd(cps->host, appData.remoteUser, cps->program, &cps->pr); } else { @@ -11193,7 +11193,7 @@ StartChessProgram (ChessProgramState *cps) snprintf(buf, sizeof(buf), "%s %s -l %s %s", appData.remoteShell, cps->host, appData.remoteUser, cps->program); } - err = StartChildProcess(buf, "", &cps->pr); + err = StartChildProcess(buf, "", &cps->pr, appData.niceEngines); } if (err != 0) { diff --git a/frontend.h b/frontend.h index a195f2e..2147dbc 100644 --- a/frontend.h +++ b/frontend.h @@ -141,7 +141,7 @@ void LeftClick P((ClickType c, int x, int y)); int RightClick P((ClickType c, int x, int y, int *col, int *row)); void Wheel P((int dir, int x, int y)); -int StartChildProcess P((char *cmdLine, char *dir, ProcRef *pr)); +int StartChildProcess P((char *cmdLine, char *dir, ProcRef *pr, int priority)); void DestroyChildProcess P((ProcRef pr, int/*boolean*/ signal)); void InterruptChildProcess P((ProcRef pr)); char *BufferCommandOutput P((char *command, int size)); diff --git a/usystem.c b/usystem.c index 743c701..0d817a3 100644 --- a/usystem.c +++ b/usystem.c @@ -413,7 +413,7 @@ HostName () int -StartChildProcess (char *cmdLine, char *dir, ProcRef *pr) +StartChildProcess (char *cmdLine, char *dir, ProcRef *pr, int priority) { char *argv[64], *p; int i, pid; @@ -462,7 +462,7 @@ StartChildProcess (char *cmdLine, char *dir, ProcRef *pr) exit(1); } - nice(appData.niceEngines); // [HGM] nice: adjust priority of engine proc + nice(priority); // [HGM] nice: adjust priority of engine proc execvp(argv[0], argv); @@ -561,7 +561,7 @@ OpenTelnet (char *host, char *port, ProcRef *pr) } else { snprintf(cmdLine, sizeof(cmdLine), "%s %s %s", appData.telnetProgram, host, port); } - return StartChildProcess(cmdLine, "", pr); + return StartChildProcess(cmdLine, "", pr, 0); } int diff --git a/winboard/winboard.c b/winboard/winboard.c index bd829b4..361f54f 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -2069,6 +2069,7 @@ static int TranslatePieceToFontPiece( int piece ) return PM_WSG; case WhiteLance: + return PM_WL; case WhiteFalcon: return PM_WV; @@ -9248,7 +9249,7 @@ void RunCommand(char *cmdLine) later. */ int -StartChildProcess(char *cmdLine, char *dir, ProcRef *pr) +StartChildProcess(char *cmdLine, char *dir, ProcRef *pr, int priority) { #define BUFSIZE 4096 @@ -9357,7 +9358,7 @@ StartChildProcess(char *cmdLine, char *dir, ProcRef *pr) if (appData.niceEngines){ // [HGM] nice: adjust engine proc priority if(appData.debugMode) fprintf(debugFP, "nice engine proc to %d\n", appData.niceEngines); - SetPriorityClass(piProcInfo.hProcess, GetWin32Priority(appData.niceEngines)); + SetPriorityClass(piProcInfo.hProcess, GetWin32Priority(priority)); } /* Close the handles we don't need in the parent */ @@ -9487,7 +9488,7 @@ OpenTelnet(char *host, char *port, ProcRef *pr) } else { snprintf(cmdLine, MSG_SIZ, "%s %s %s", appData.telnetProgram, host, port); } - return StartChildProcess(cmdLine, "", pr); + return StartChildProcess(cmdLine, "", pr, 0); }