Apply -niceEngines priority only to engines
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 17 Jun 2019 11:49:01 +0000 (13:49 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 17 Jun 2019 11:49:01 +0000 (13:49 +0200)
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.

backend.c
frontend.h
usystem.c
winboard/winboard.c

index b1a6155..47b426d 100644 (file)
--- 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) {
index a195f2e..2147dbc 100644 (file)
@@ -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));
index 743c701..0d817a3 100644 (file)
--- 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
index bd829b4..361f54f 100644 (file)
@@ -2069,6 +2069,7 @@ static int TranslatePieceToFontPiece( int piece )
         return PM_WSG;\r
     case WhiteLance:\r
 \r
+\r
         return PM_WL;\r
     case WhiteFalcon:\r
         return PM_WV;\r
@@ -9248,7 +9249,7 @@ void RunCommand(char *cmdLine)
    later.\r
 */\r
 int\r
-StartChildProcess(char *cmdLine, char *dir, ProcRef *pr)\r
+StartChildProcess(char *cmdLine, char *dir, ProcRef *pr, int priority)\r
 {\r
 #define BUFSIZE 4096\r
 \r
@@ -9357,7 +9358,7 @@ StartChildProcess(char *cmdLine, char *dir, ProcRef *pr)
 \r
   if (appData.niceEngines){ // [HGM] nice: adjust engine proc priority\r
     if(appData.debugMode) fprintf(debugFP, "nice engine proc to %d\n", appData.niceEngines);\r
-    SetPriorityClass(piProcInfo.hProcess, GetWin32Priority(appData.niceEngines));\r
+    SetPriorityClass(piProcInfo.hProcess, GetWin32Priority(priority));\r
   }\r
 \r
   /* Close the handles we don't need in the parent */\r
@@ -9487,7 +9488,7 @@ OpenTelnet(char *host, char *port, ProcRef *pr)
   } else {\r
     snprintf(cmdLine, MSG_SIZ, "%s %s %s", appData.telnetProgram, host, port);\r
   }\r
-  return StartChildProcess(cmdLine, "", pr);\r
+  return StartChildProcess(cmdLine, "", pr, 0);\r
 }\r
 \r
 \r