From 9f6b1d3251e3a639a3cb8e331c904d7a0ad205aa Mon Sep 17 00:00:00 2001 From: Petr Baudis <pasky@ucw.cz> Date: Wed, 7 Mar 2012 17:51:02 +0100 Subject: [PATCH] compctl --run: Automatically nice started computations --- common.h | 3 +++ compctl.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/common.h b/common.h index dd7ca6a..a00b36f 100644 --- a/common.h +++ b/common.h @@ -15,6 +15,9 @@ size_t static_minfree = 512*1048576UL; size_t static_maxfree = 2048*1048576UL; double split_ratio = 0.5; +/* Default nice value for processes started using compctl --run. */ +#define COMPNICE 12 + /* Other common definitions. */ /* See README for the high-level protocol description. */ diff --git a/compctl.c b/compctl.c index 5571257..204f262 100644 --- a/compctl.c +++ b/compctl.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/resource.h> #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> @@ -104,6 +105,9 @@ run(int argc, char *argv[]) } free(line); + if (setpriority(PRIO_PROCESS, 0, COMPNICE) < 0) + perror("Warning: setpriority()"); + char *argvx[argc + 1]; for (int i = 0; i < argc; i++) argvx[i] = argv[i]; -- GitLab