Re: [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17

Mark Hahn
2002-01-09T22:33:51Z

> no wonder, it should be 'nice -n -20 vmstat -n 1'. And you should also do

I keep a suid setrealtime wrapper around (UNSAFE!) for this kind of use:

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sched.h>

int main(int argc, char *argv[]) {
static struct sched_param sched_parms;
int pid, wrapper=0;

if (argc <= 1)
return 1;

pid = atoi(argv[1]);

if (!pid || argc != 2) {
wrapper = 1;
pid = getpid();
}

sched_parms.sched_priority = sched_get_priority_min(SCHED_FIFO);
if (sched_setscheduler(pid, SCHED_FIFO, &sched_parms) == -1) {
perror("cannot set realtime scheduling policy");
return 1;
}
if (wrapper) {
setuid(getuid());
execvp(argv[1],&argv[1]);
perror("exec failed");
return 1;
}
return 0;
}

regards, mark hahn.