00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#include <stdio.h>
00020
#include <stdlib.h>
00021
#include <unistd.h>
00022
#include <sys/types.h>
00023
#include <sys/user.h>
00024
#include <sys/mman.h>
00025
#include <sys/stat.h>
00026
#include <fcntl.h>
00027
#include <sched.h>
00028
00029 void init_linux_scheduler(
int sched,
int pri)
00030 {
00031
struct sched_param mysched;
00032
00033
if(sched != SCHED_RR && sched != SCHED_FIFO) {
00034 puts(
"Invalid scheduling scheme");
00035 exit(1);
00036 }
00037
00038
if((pri < sched_get_priority_min(sched)) || (pri > sched_get_priority_max(sched))) {
00039 puts(
"Invalid priority");
00040 exit(2);
00041 }
00042
00043 mysched.sched_priority = pri ;
00044
if( sched_setscheduler( 0, SCHED_FIFO, &mysched ) == -1 ) {
00045 puts(
"Error in setting the Linux scheduler");
00046 perror(
"errno");
00047 exit(3);
00048 }
00049 }