Messages in this thread | | | Date | Mon, 8 Feb 1999 16:02:11 +0100 (MET) | From | Roman Drahtmueller <> | Subject | Re: Real Time scheduler? |
| |
> Are there any patches available to incorporate a poor-mans real time > function into the scheduler. FreeBSD's "rtprio" is what I'm thinking of. > Basically it runs all "real time" processes in time shared fashion before > running any "non real time" processes.
Use something like this:
/* * resched (Roman Drahtmueller <draht@uni-freiburg.de> * * delivers a process to another scheduling class policy. * * CAUTION: Handle with care and read the manpage before you use it. * CPU-intesive processes will not return before they are * finished or blocked on I/O. (This means that it could * hang your machine, luser!) * * Use as you wish. The author is not responsible for * damages that could result from using this software. * Permission granted to distribute at will. * (!) */
#ifdef linux #include <getopt.h> #else /* Solaris: cc -lposix4 -o resched resched.c */ #include <stdlib.h> #endif #include <sched.h> #include <stdio.h>
extern int atoi(); void usage(void) { fprintf(stderr,"\nUsage: resched -p <priority> <-s|-f|-r> <pid>\n"); fprintf(stderr,"\t-s == SCHED_OTHER, -f == SCHED_FIFO, -r SCHED_RR\n"); fprintf(stderr,"Handle with care and read the documentation\n"); fprintf(stderr,"about scheduling classes before you use this program!\n\n"); }
int main(argc, argv) char **argv; { char c; struct sched_param *priority; int pid = -1, policy = SCHED_OTHER; priority->sched_priority = 1; while ((c = getopt(argc, argv, "p:fsrh")) != EOF) switch (c) { case 'p': priority->sched_priority = atoi(optarg); break; case 's': policy = SCHED_OTHER; break; case 'f': policy = SCHED_FIFO; break; case 'r': policy = SCHED_RR; break; case 'h': usage(); exit (1); default: policy = SCHED_OTHER; break; } if (argc-optind == 1) pid = atoi(argv[optind]); else if (argc-optind != 0) { usage(); exit(1); } if (policy == SCHED_OTHER ) priority->sched_priority = 0; printf("calling sched_setscheduler: pid: %i priority: %i policy = %i \n" ,pid,priority->sched_priority,policy); if (0 > sched_setscheduler(pid,policy,priority)) { perror("sched_setscheduler"); usage(); exit(-1); } exit (0); }
Roman. Computer Center University of Freiburg, Germany. "The whole world is about three drinks behind." (Humphrey Bogart)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |