base/sched/liblxrt/init.c

Go to the documentation of this file.
00001 /* 00002 * Copyright (C) Pierre Cloutier <pcloutier@PoseidonControls.com> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the version 2 of the GNU Lesser 00006 * General Public License as published by the Free Software 00007 * Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 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 }

Generated on Thu Nov 20 11:49:52 2008 for RTAI API by doxygen 1.3.8